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