package controllers import ( "encoding/json" "eta/eta_data_push/models" "eta/eta_data_push/services" "strconv" ) // 分类 type ClassifyController struct { BaseAuthController } // @Title 获取分类接口 // @Description 获取分类接口 // @Success 200 {object} models.ClassifyListReq // @router /list [post] func (this *ClassifyController) ClassifyList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() var req models.ClassifyListReq err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.Source <= 0 { br.Msg = "渠道编码错误!" br.ErrMsg = "渠道编码错误,Source:" + strconv.Itoa(req.Source) return } list, err := services.GetClassifyList(req.Source) if err != nil { br.Msg = "获取数据失败!" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = list }