package controllers import ( "encoding/json" "hongze/hongze_clpt/models" "hongze/hongze_clpt/services" "hongze/hongze_clpt/utils" "time" ) // Collection type CollectionController struct { BaseAuthController } type BaseCollectionController struct { BaseCommonController } // @Title 精选看板、路演banner列表 // @Description 精选看板、路演banner列表接口 // @Success Ret=200 {object} cygx.CollectionBannerListResp // @router /banner/list [get] func (this *BaseCollectionController) BannerList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() resp := new(models.CollectionBannerListResp) var listA []*models.CollectionBannerResp listB := new(models.CollectionBannerResp) listA = []*models.CollectionBannerResp{ &models.CollectionBannerResp{Title: "策略系列培训视频", IndexImg: "https://hzstatic.hzinsights.com/cygx/banner/web/lyhf.png", Path: "https://web.hzinsights.com/internal/article/43"}, } listB.Title = "专题看板" listB.IndexImg = "https://hzstatic.hzinsights.com/cygx/banner/web/jxkb.png" listB.IsShowSustainable = true resp.ListA = listA resp.ListB = listB br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 精选看板跳转详情地址 // @Description 精选看板跳转详情地址接口 // @Success Ret=200 {object} cygx.CollectionBannerListResp // @router /detail [get] func (this *CollectionController) Detail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } resp := new(models.CollectionDetailResp) br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 提交精选看板申请接口 // @Description 提交精选看板申请接口 // @Param request body cygx.CygxBannerIdReq true "type json string" // @Success 200 Ret=200 提交成功 // @router /apply/add [post] func (this *CollectionController) ApplyAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req models.ApplyCollectionReq err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } content := req.Content if content == "" { br.Msg = "内容不能为空" br.ErrMsg = "内容不能为空" return } item := new(models.CygxApplyCollection) item.UserId = user.UserId item.CreateTime = time.Now() item.ModifyTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.Content = content item.RegisterPlatform = utils.REGISTER_PLATFORM sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return } item.RealName = user.RealName if sellerItem != nil { item.SellerName = sellerItem.RealName } newId, err := models.AddCygxApplyCollection(item) go services.SendCygxApplyCollectionTemplateMsg(user, content, int(newId)) if err != nil { br.Msg = "申请失败" br.ErrMsg = "申请失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "记录成功" }