|
@@ -0,0 +1,114 @@
|
|
|
+package controllers
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_clpt/models"
|
|
|
+ "hongze/hongze_clpt/utils"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// Collection
|
|
|
+type CollectionController struct {
|
|
|
+ BaseAuthController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 精选看板、路演banner列表
|
|
|
+// @Description 精选看板、路演banner列表接口
|
|
|
+// @Success Ret=200 {object} cygx.CollectionBannerListResp
|
|
|
+// @router /banner/list [get]
|
|
|
+func (this *CollectionController) BannerList() {
|
|
|
+ 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.CollectionBannerListResp)
|
|
|
+ var listA []*models.CollectionBannerResp
|
|
|
+ var listB []*models.CollectionBannerResp
|
|
|
+ listA = []*models.CollectionBannerResp{
|
|
|
+ &models.CollectionBannerResp{Title: "B1", IndexImg: "https://hzstatic.hzinsights.com/banner/yx/web_1.png", Path: "/index/"},
|
|
|
+ &models.CollectionBannerResp{Title: "B2", IndexImg: "https://hzstatic.hzinsights.com/banner/yx/web_2.png", Path: ""},
|
|
|
+ }
|
|
|
+
|
|
|
+ listB = []*models.CollectionBannerResp{
|
|
|
+ &models.CollectionBannerResp{Title: "B2", IndexImg: "https://hzstatic.hzinsights.com/banner/yx/web_3.png", Path: "/index/"},
|
|
|
+ }
|
|
|
+ resp.ListA = listA
|
|
|
+ resp.ListB = listB
|
|
|
+ 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)
|
|
|
+ fmt.Println(newId)
|
|
|
+ //err = services.AddCygxBannerYxSurvey(user, content)
|
|
|
+ //services.SendCygxBannerYxSurveyTemplateMsg(user, content, int(newId))
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "申请失败"
|
|
|
+ br.ErrMsg = "申请失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "记录成功"
|
|
|
+}
|