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" }