|
@@ -0,0 +1,154 @@
|
|
|
+package controllers
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/services"
|
|
|
+ "hongze/hongze_cygx/utils"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+//专项调研活动
|
|
|
+type ActivitySpecialCoAntroller struct {
|
|
|
+ BaseAuthController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 专项产业调研列表
|
|
|
+// @Description 获取专项产业调研列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
|
|
|
+// @router /list [get]
|
|
|
+func (this *ActivitySpecialCoAntroller) SpecialList() {
|
|
|
+ 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"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //uid := user.UserId
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ userType, permissionStr, err := services.GetUserType(user.CompanyId)
|
|
|
+ fmt.Println(permissionStr)
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ //活动可见限制
|
|
|
+ slicePer := strings.Split(permissionStr, ",")
|
|
|
+ var permissionSqlStr string
|
|
|
+ for _, v := range slicePer {
|
|
|
+ if userType == 1 {
|
|
|
+ if !strings.Contains(v, "研选") {
|
|
|
+ permissionSqlStr += "'" + v + "',"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ permissionSqlStr += "'" + v + "',"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
|
|
|
+ permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
|
|
|
+ permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
|
|
|
+
|
|
|
+ condition, err = services.HandleActivityLabelSpecialPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ total, err := models.GetActivitySpecialCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //list, errList := models.GetCygxActivitySpecialDetailList(condition, pars, uid, startSize, pageSize)
|
|
|
+ //if errList != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
+ list, errList := services.GetActivityLabelSpecialConfirmList(user, startSize, pageSize, 0)
|
|
|
+ if errList != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + errList.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ detail, err := models.GetConfigByCode("city_img_url")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detailChart, err := models.GetConfigByCode("chart_img_url")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ addressList := strings.Split(detail.ConfigValue, "{|}")
|
|
|
+ mapAddress := make(map[string]string)
|
|
|
+ chartList := strings.Split(detailChart.ConfigValue, "{|}")
|
|
|
+ mapChart := make(map[string]string)
|
|
|
+ var cityName string
|
|
|
+ var chartName string
|
|
|
+ var imgUrl string
|
|
|
+ var imgUrlChart string
|
|
|
+ for _, v := range addressList {
|
|
|
+ vslice := strings.Split(v, "_")
|
|
|
+ cityName = vslice[0]
|
|
|
+ imgUrl = vslice[len(vslice)-1]
|
|
|
+ mapAddress[cityName] = imgUrl
|
|
|
+ }
|
|
|
+ for _, v := range chartList {
|
|
|
+ vslice := strings.Split(v, "_")
|
|
|
+ chartName = vslice[0]
|
|
|
+ imgUrlChart = vslice[len(vslice)-1]
|
|
|
+ mapChart[chartName] = imgUrlChart
|
|
|
+ }
|
|
|
+ for k, v := range list {
|
|
|
+ //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
|
|
|
+ if mapChart[v.ChartPermissionName] != "" {
|
|
|
+ list[k].ImgUrl = mapChart[v.ChartPermissionName]
|
|
|
+ }
|
|
|
+ list[k].ActivityTypeName = "专项调研"
|
|
|
+ }
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(models.GetCygxActivitySpecialDetailListResp)
|
|
|
+ count, err := models.GetCygxUserFollowSpecial(user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if count == 1 && user.UserId > 0 {
|
|
|
+ resp.IsFollow = true
|
|
|
+ }
|
|
|
+ if user.Mobile != "" {
|
|
|
+ resp.IsBindingMobile = true
|
|
|
+ }
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+
|
|
|
+}
|