From 9d304831712ba439c8219497627eb0a98f672c8d Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Sun, 21 Feb 2021 21:39:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A1=E5=88=92=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/plan.go | 18 +++++++++++++++++- main.go | 1 + model/model.go | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/controller/plan.go b/controller/plan.go index 864f408..fe1df68 100644 --- a/controller/plan.go +++ b/controller/plan.go @@ -98,7 +98,6 @@ func (m *ReqDate) TableName() string { } func (this *PlanController) PlanDay(c *gin.Context) { - var req ReqDate resp := RespBase{ Msg: "ERROR", @@ -123,3 +122,20 @@ func (this *PlanController) PlanDay(c *gin.Context) { resp.Msg = "OK" resp.Status = 0 } + +func (this *PlanController) Types(c *gin.Context) { + resp := RespBase{ + Msg: "ERROR", + Status: 23, + } + defer c.JSON(200, &resp) + rets := []model.PlanType{} + e := db.GetOrm().Model(&model.PlanType{}).Find(&rets).Error + if nil != e { + log.Print(e.Error()) + return + } + resp.Data = rets + resp.Msg = "OK" + resp.Status = 0 +} diff --git a/main.go b/main.go index 704874a..ea028e0 100644 --- a/main.go +++ b/main.go @@ -180,6 +180,7 @@ func main() { api.PUT("/plan", planController.AddPlan) // 添加计划 api.DELETE("/plan", planController.DelPlan) // 删除计划 api.POST("/plan_days", planController.PlanDay) // 获取本月有计划天数 + api.GET("/plan_types",planController.Types) api.GET("planDays") } diff --git a/model/model.go b/model/model.go index 593169b..2e4188b 100644 --- a/model/model.go +++ b/model/model.go @@ -15,8 +15,18 @@ type Plan struct { EndTime utils.OrmTime `gorm:"column:end_time" json:"end_time"` Date string `gorm:"column:date" json:"date"` Content string `gorm:"column:content" json:"content"` + Type uint32 `gorm:"column:type" json:"type"` } + +type PlanType struct { + ID uint32 `gorm:"column:id;primary_key" json:"id"` + TypeName string `gorm:"column:type_name;" json:"type_name"` +} + +func (m *PlanType) TableName() string { + return "plan_type" +} func (m *Plan) TableName() string { return "plan" }