package controllers import ( "hongze/hongze_api/models" ) type ClassifyController struct { BaseAuthController } type ClassifyCommonController struct { BaseCommonController } // @Title 获取分类详情信息 // @Description 获取分类详情信息接口 // @Param ClassifyId query int true "分类id" // @Success 200 {object} models.ClassifyDetail // @router /detail [get] func (this *ClassifyController) Detail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() classifyId, err := this.GetInt("ClassifyId") if err != nil { br.Msg = "参数获取失败" br.ErrMsg = "参数获取失败,Err:" + err.Error() return } if classifyId <= 0 { br.Msg = "参数错误" br.ErrMsg = "参数错误,分类id小于等于0" return } item, err := models.GetClassifyDetailById(classifyId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } commentList, err := models.GetCustomerComment() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } item.CommentList = commentList br.Ret = 200 br.Success = true br.Msg = "获取数据成功" br.Data = item } // @Title 获取一级分类列表 // @Description 获取一级分类列表接口 // @Success 200 {object} models.Classify // @router /pc/list [get] func (this *ClassifyCommonController) List() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() item, err := models.GetClassifyList() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "获取数据成功" br.Data = item } // @Title 获取二级分类列表 // @Description 获取二级分类列表接口 // @Param ClassifyId query int true "分类id" // @Success 200 {object} models.ClassifyDetail // @router /pc/second/list [get] func (this *ClassifyCommonController) SecondList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() classifyId, err := this.GetInt("ClassifyId") if err != nil { br.Msg = "参数获取失败" br.ErrMsg = "参数获取失败,Err:" + err.Error() return } if classifyId <= 0 { br.Msg = "参数错误" br.ErrMsg = "参数错误,分类id小于等于0" return } item, err := models.GetClassifySecondList(classifyId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "获取数据成功" br.Data = item }