no message
This commit is contained in:
parent
c90b44b2c5
commit
59989de706
@ -64,8 +64,8 @@ func (this *FileController) OnUpload(c *gin.Context) {
|
||||
dx := img.Bounds().Dx()
|
||||
// resize to width 1000 using Lanczos resampling
|
||||
// and preserve aspect ratio
|
||||
if(dx > 800){
|
||||
dx = dx / 2;
|
||||
if dx > 800 {
|
||||
dx = dx / 2
|
||||
}
|
||||
m := resize.Resize(uint(dx), 0, img, resize.Lanczos3)
|
||||
|
||||
@ -212,7 +212,6 @@ func (this *FileController) OnThumbnail(c *gin.Context) {
|
||||
c.Writer.Write(bytes)
|
||||
}
|
||||
|
||||
|
||||
func (this *FileController) OnDownLoad(c *gin.Context) {
|
||||
resp := RespBase{Msg: "FAIL", Status: 211}
|
||||
|
||||
|
89
controller/plan.go
Normal file
89
controller/plan.go
Normal file
@ -0,0 +1,89 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"background/db"
|
||||
"background/model"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PlanController struct {
|
||||
}
|
||||
|
||||
func (this *PlanController) GetPlan(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (this *PlanController) GetPlanDates(c *gin.Context) {
|
||||
type Req struct {
|
||||
Date string `json:"date"`
|
||||
}
|
||||
var req Req
|
||||
|
||||
resp := RespBase{
|
||||
Msg: "ERROR",
|
||||
Status: 23,
|
||||
}
|
||||
defer c.JSON(200, &resp)
|
||||
e := c.BindJSON(&req)
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
plan := []model.Plan{}
|
||||
e = db.GetOrm().Model(&plan).Where("date = ?", req.Date).Find(&plan).Error
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
}
|
||||
resp.Status = 0
|
||||
resp.Msg = "OK"
|
||||
resp.Data = plan
|
||||
return
|
||||
}
|
||||
|
||||
func (this *PlanController) AddPlan(c *gin.Context) {
|
||||
var req model.Plan
|
||||
resp := RespBase{Msg: "r", Status: 0, Data: nil}
|
||||
defer c.JSON(200, &resp)
|
||||
e := c.BindJSON(&req)
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
e = db.GetOrm().Create(&req).Error
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp.Msg = "OK"
|
||||
resp.Status = 0
|
||||
}
|
||||
|
||||
func (this *PlanController) DelPlan(c *gin.Context) {
|
||||
resp := RespBase{Msg: "r", Status: 0, Data: nil}
|
||||
defer c.JSON(200, &resp)
|
||||
var e error
|
||||
iid := 0
|
||||
id := c.Query("id")
|
||||
if "" != id {
|
||||
iid, e = strconv.Atoi(id)
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
plan := model.Plan{}
|
||||
plan.ID = uint32(iid)
|
||||
e = db.GetOrm().Delete(&plan).Error
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
resp.Msg = "OK"
|
||||
resp.Status = 0
|
||||
}
|
8
main.go
8
main.go
@ -27,6 +27,7 @@ var (
|
||||
userController = controller.UserController{}
|
||||
mailContoller = controller.MailController{}
|
||||
fileController = controller.FileController{}
|
||||
planController = controller.PlanController{}
|
||||
)
|
||||
|
||||
func CORSMiddleware(c *gin.Context) {
|
||||
@ -149,7 +150,7 @@ func main() {
|
||||
api.POST("/hardware", controller.AddHardware) // 新增硬件
|
||||
api.GET("/hardware", controller.ReadHardWare) // 读取硬件
|
||||
api.DELETE("/hardware", controller.DeleteHardWare) // 读取硬件
|
||||
api.POST("/doc_search",)
|
||||
api.POST("/doc_search")
|
||||
api.PUT("/file", fileController.OnFileUploadFile) // 上传文件
|
||||
api.GET("/file", fileController.DownloadFile) // 下载 文件
|
||||
api.GET("/filelist", fileController.FileList) // 文件列表
|
||||
@ -174,6 +175,11 @@ func main() {
|
||||
api.POST("/getbooks", controller.GetPageBook) // 批量书籍
|
||||
api.POST("/delbook", controller.Delbook) // 删除书籍
|
||||
api.GET("/bookcount", controller.BookCount) // 删除书籍
|
||||
|
||||
api.POST("/get_plans", planController.GetPlanDates)
|
||||
api.PUT("/plan", planController.AddPlan)
|
||||
api.DELETE("/plan", planController.DelPlan)
|
||||
|
||||
}
|
||||
|
||||
openapi := r.Group("openapi")
|
||||
|
@ -9,13 +9,11 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
|
||||
type Plan struct {
|
||||
ID uint32 `gorm:"column:id;primary_key" json:"id"`
|
||||
StartTime utils.OrmTime `gorm:"column:start_time" json:"start_time"`
|
||||
EndTime utils.OrmTime `gorm:"column:end_time" json:"end_time"`
|
||||
Date utils.OrmTime `gorm:"column:date" json:"date"`
|
||||
Date string `gorm:"column:date" json:"date"`
|
||||
Content string `gorm:"column:content" json:"content"`
|
||||
}
|
||||
|
||||
@ -23,7 +21,6 @@ func (m *Plan) TableName() string {
|
||||
return "plan"
|
||||
}
|
||||
|
||||
|
||||
type Users struct {
|
||||
ID int64 `sql:"id" json:"id"`
|
||||
UserName string `sql:"user_name" json:"user_name"`
|
||||
|
Loading…
Reference in New Issue
Block a user