123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- package controllers
- import (
- "encoding/json"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/services"
- "hongze/hongze_clpt/utils"
- "strings"
- )
- type ConfigController struct {
- BaseAuthController
- }
- type BaseConfigController struct {
- BaseCommonController
- }
- // @Title 相关内容是否展示
- // @Description 相关内容是否展示接口
- // @Param request body models.IsShow true "type json string"
- // @Success 200
- // @router /isShow [get]
- func (this *ConfigController) IsShow() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- var resp models.IsShow
- resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
- resp.IsShowResearchPoints = true
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 关于我们
- // @Description 关于我们接口
- // @Param request body models.IsShow true "type json string"
- // @Success 200
- // @router /aboutUs [get]
- func (this *ConfigController) AboutUs() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- var aboutUs = new(models.AboutUs)
- aboutUs.Title = utils.ABOUT_US_TITLE
- aboutUs.Url = utils.ABOUT_US_URL
- br.Ret = 200
- br.Success = true
- br.Data = aboutUs
- }
- // @Title 关于我们浏览记录
- // @Description 关于我们浏览记录接口
- // @Success 200
- // @router /aboutUs/addHistory [post]
- func (this *ConfigController) AboutUsAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- go services.AddCygxAboutUsVideoHistory(user)
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功!"
- }
- // @Title 买方研选产品介绍(无需token)
- // @Description 买方研选产品介绍接口(无需token)
- // @Success 200 {object} models.ConfigImgListResp
- // @router /research/introduce [get]
- func (this *BaseConfigController) ResearchIntroduce() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- conf, err := models.GetConfigByCode("research_introduce_img_url_pc")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
- return
- }
- if conf.ConfigValue == "" {
- br.Msg = "获取失败"
- br.ErrMsg = "买方研选产品介绍信息失败"
- return
- }
- list := new(*models.ConfigImgListResp)
- if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
- return
- }
- br.Msg = "获取成功!"
- br.Ret = 200
- br.Success = true
- br.Data = list
- }
- // @Title 买方研选报价单(无需token)
- // @Description 买方研选报价单(无需token)
- // @Success 200 {object} models.ConfigImgListResp
- // @router /research/quotation [get]
- func (this *BaseConfigController) ResearchQuotation() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- conf, err := models.GetConfigByCode("research_quotation_img_url_pc")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
- return
- }
- if conf.ConfigValue == "" {
- br.Msg = "获取失败"
- br.ErrMsg = "买方研选产品介绍信息失败"
- return
- }
- list := new(*models.ConfigImgListResp)
- if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
- return
- }
- br.Msg = "获取成功!"
- br.Ret = 200
- br.Success = true
- br.Data = list
- }
- // @Title 买方研选升级新资源海报(无需token)
- // @Description 买方研选升级新资源海报(无需token)
- // @Success 200 {object} models.ConfigImgListResp
- // @router /research/hb [get]
- func (this *BaseConfigController) ResearchHb() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- detail, err := models.GetConfigByCode("research_hb_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "买方研选升级新资源海报信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.ConfigImgHbResp)
- list := strings.Split(detail.ConfigValue, "{|}")
- if len(list) == 0 {
- list = make([]string, 0)
- }
- resp.HbImg = list[0]
- resp.ButtonImg = list[len(list)-1]
- br.Msg = "获取成功!"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
|