no message

master
zcy 2021-02-16 15:44:26 +08:00
parent 59989de706
commit 63d45eabcc
2 changed files with 41 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package controller
import (
"background/db"
"background/model"
"fmt"
"log"
"strconv"
@ -87,3 +88,38 @@ func (this *PlanController) DelPlan(c *gin.Context) {
resp.Msg = "OK"
resp.Status = 0
}
type ReqDate struct {
Date string `gorm:"date" json:"date"`
}
func (m *ReqDate) TableName() string {
return "plan"
}
func (this *PlanController) PlanDay(c *gin.Context) {
var req ReqDate
resp := RespBase{
Msg: "ERROR",
Status: 23,
}
defer c.JSON(200, &resp)
e := c.BindJSON(&req)
if nil != e {
log.Print(e.Error())
return
}
ret := make([]ReqDate, 1)
sql := fmt.Sprintf(`SELECT distinct plan.date FROM plan where DATE_FORMAT(plan.date,'%%Y-%%m')=DATE_FORMAT('%s','%%Y-%%m')`, req.Date)
log.Print(sql)
e = db.GetOrm().Raw(sql).Find(&ret).Error
if nil != e {
log.Print(e.Error())
return
}
resp.Data = ret
resp.Msg = "OK"
resp.Status = 0
}

View File

@ -176,10 +176,11 @@ func main() {
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)
api.POST("/get_plans", planController.GetPlanDates) // 获取当天的所有计划
api.PUT("/plan", planController.AddPlan) // 添加计划
api.DELETE("/plan", planController.DelPlan) // 删除计划
api.POST("/plan_days", planController.PlanDay) // 获取本月有计划天数
api.GET("planDays")
}
openapi := r.Group("openapi")