123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- package controllers
- import (
- "encoding/json"
- "hongze/hongze_web_mfyx/models"
- "hongze/hongze_web_mfyx/services"
- "hongze/hongze_web_mfyx/utils"
- )
- type TagController struct {
- BaseAuthController
- }
- type BaseTagController struct {
- BaseCommonController
- }
- // @Title 获取标签列表-自定义顺序
- // @Description 获取标签列表-自定义顺序接口
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /list/custom [get]
- func (this *TagController) TagCustomizeList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.User
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var condition string
- var resp models.CygxTagListResp
- hasPermission, err := services.GetUserHasPermissionSimple(sysUser)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- if hasPermission > 1 {
- list := make([]*models.CygxTagList, 0)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- list, err := models.GetCygxTagList(condition)
- if err != nil {
- br.Msg = "获取标签失败"
- br.ErrMsg = "获取标签信息失败,Err:" + err.Error()
- return
- }
- for _, v := range list {
- if v.ArticleTypes != "" {
- v.CheckList = append(v.CheckList, "A")
- }
- if v.ActivityTypes != "" {
- v.CheckList = append(v.CheckList, "B")
- }
- if v.Industries != "" {
- v.CheckList = append(v.CheckList, "C")
- }
- if v.SubjectNames != "" {
- v.CheckList = append(v.CheckList, "D")
- }
- //固定标签默认都属于,前端互斥使用
- if v.TagType > 0 {
- v.CheckList = []string{"A", "B", "C", "D"}
- }
- }
- //var condition string
- condition = ` AND permission_name IN ('医药','消费','科技','智造','策略') `
- listPermission, err := models.GetChartPermissionReportAll(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- item := new(models.ChartPermissionResp)
- item.ChartPermissionId = utils.GU_SHOU_ID
- item.PermissionName = utils.GU_SHOU_NAME
- listPermission = append(listPermission, item)
- resp.List = list
- resp.ListPermission = listPermission
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 记录点击信息
- // @Description 记录点击信息
- // @Param request body cygx.CygxTagIdReq true "type json string"
- // @Success 200 Ret=200 发布成功
- // @router /add/history [post]
- func (this *TagController) History() {
- 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.CygxTagIdReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- tagId := req.TagId
- if tagId == 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误,id不可为空"
- return
- }
- go services.AddCygxTagHistory(user, tagId)
- br.Ret = 200
- br.Success = true
- br.Msg = "记录成功"
- }
- // @Title 首页标签列表
- // @Description 首页标签列表接口
- // @Success 200 {object} cygx.CygxTagListLabelResp
- // @router /list/label [get]
- func (this *BaseTagController) ListLabel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- resp := new(models.CygxTagListLabelResp)
- key := "mfyx_tag_list"
- conf, e := models.GetConfigByCode(key)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error()
- return
- }
- if conf.ConfigValue == "" {
- br.Msg = "获取失败"
- br.ErrMsg = "首页头部导航配置值有误"
- return
- }
- if e = json.Unmarshal([]byte(conf.ConfigValue), &resp); e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|