xingzai 1 yıl önce
ebeveyn
işleme
49a19cc173
2 değiştirilmiş dosya ile 190 ekleme ve 0 silme
  1. 114 0
      controllers/collection.go
  2. 76 0
      models/apply_collection.go

+ 114 - 0
controllers/collection.go

@@ -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 = "记录成功"
+}

+ 76 - 0
models/apply_collection.go

@@ -0,0 +1,76 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CollectionBannerResp struct {
+	Title    string `description:"标题"`
+	IndexImg string `description:"小程序封面图"`
+	Path     string `description:"小程序路径"`
+}
+
+type CollectionBannerListResp struct {
+	ListA []*CollectionBannerResp
+	ListB []*CollectionBannerResp
+}
+
+type CollectionDetailResp struct {
+	HttpUrl string `description:"跳转地址"`
+}
+
+type ApplyCollectionReq struct {
+	Content string `description:"内容"`
+}
+
+// 精选看板申请表
+type CygxApplyCollection struct {
+	ApplyCollectionId int       `orm:"column(apply_collection_id);pk" description:"主键ID"`
+	UserId            int       `description:"用户ID"`         // 用户ID
+	Mobile            string    `description:"手机号"`          // 手机号
+	Email             string    `description:"邮箱"`           // 邮箱
+	CompanyId         int       `description:"公司ID"`         // 公司ID
+	CompanyName       string    `description:"公司名称"`         // 公司名称
+	RealName          string    `description:"用户实际名称"`       // 用户实际名称
+	SellerName        string    `description:"所属销售"`         // 所属销售
+	CreateTime        time.Time `description:"创建时间"`         // 创建时间
+	ModifyTime        time.Time `description:"修改时间"`         // 修改时间
+	RegisterPlatform  int       `description:"来源 1小程序,2:网页"` // 来源 1小程序,2:网页
+	Content           string    `description:" 内容"`          // 内容
+}
+
+// 精选看板申请表
+type CygxApplyCollectionResp struct {
+	ApplyCollectionId int       `gorm:"column:"`
+	UserId            int       `gorm:"column:"`                    // 用户ID
+	Mobile            string    `gorm:"column:"`                    // 手机号
+	Email             string    `gorm:"column:"`                    // 邮箱
+	CompanyId         int       `gorm:"column:;default:0"`          // 公司ID
+	CompanyName       string    `gorm:"column:"`                    // 公司名称
+	RealName          string    `gorm:"column:"`                    // 用户实际名称
+	SellerName        string    `gorm:"column:"`                    // 所属销售
+	CreateTime        time.Time `gorm:"column:"`                    // 创建时间
+	ModifyTime        time.Time `gorm:"column:"`                    // 修改时间
+	RegisterPlatform  int       `gorm:"column:;default:1;NOT NULL"` // 来源 1小程序,2:网页
+	Content           string    `gorm:"column:;NOT NULL"`           // 内容
+}
+
+// 添加信息
+func AddCygxApplyCollection(item *CygxApplyCollection) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 通过ID获取详情
+func GetCygxApplyCollectionDetail(applyCollectionId int) (item *CygxApplyCollectionResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_apply_collection  WHERE apply_collection_id=?  `
+	err = o.Raw(sql, applyCollectionId).QueryRow(&item)
+	return
+}
+
+type CygxApplyCollectionDetailResp struct {
+	Detail *CygxApplyCollectionResp
+}