123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- package controllers
- import (
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- )
- // 品种
- type ChartPermissionController struct {
- BaseCommonController
- }
- type ChartPermissionAuthController struct {
- BaseAuthController
- }
- // @Title 获取所有品种
- // @Description 获取用户详情接口
- // @Success 200 {object} models.ChartPermissionResp
- // @router /all [get]
- func (this *ChartPermissionAuthController) Detail() {
- 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 condition string
- var userType int
- if user.CompanyId > 1 {
- total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- userType = 0
- } else {
- companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail.Status == "永续" {
- userType = 1
- }
- }
- }
- if userType == 1 {
- condition += ` AND permission_name != '研选'`
- }
- condition += ` AND permission_name != '医药'`
- list, err := models.GetChartPermissionAll(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.ChartPermissionResp)
- for k, v := range list {
- //研选订阅包不进行展示
- if v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- continue
- }
- //固收不进行展示
- if v.ChartPermissionId == utils.GU_SHOU_ID_CHART {
- continue
- }
- //周期不进行展示
- if v.PermissionName == utils.ZHOU_QI_NAME {
- continue
- }
- if userType == 1 {
- if v.PermissionName != "研选" {
- resp.List = append(resp.List, v)
- }
- } else {
- if v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
- v.PermissionName = "买方研选"
- }
- resp.List = append(resp.List, v)
- }
- if services.GetShowSustainable() && v.PermissionName == "研选" {
- resp.List[k].IsShowSustainable = true
- }
- }
- //resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取报告所有品种
- // @Description 获取报告所有品种接口
- // @Success 200 {object} models.ChartPermissionResp
- // @router /reportall [get]
- func (this *ChartPermissionAuthController) ReportDetail() {
- 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 condition string
- var userType int
- if user.CompanyId > 1 {
- total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if total == 0 {
- userType = 0
- } else {
- companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail.Status == "永续" {
- userType = 1
- }
- }
- }
- if userType == 1 {
- condition += ` AND permission_name != '买方研选'`
- }
- list, err := models.GetChartPermissionReportAll(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.ChartPermissionResp)
- for k, v := range list {
- if userType == 1 {
- if v.PermissionName != "研选" {
- resp.List = append(resp.List, v)
- }
- } else {
- resp.List = append(resp.List, v)
- }
- if services.GetShowSustainable() && v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
- resp.List[k].IsShowSustainable = true
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取策略下的所有分类
- // @Description 获取策略下的所有分类接口
- // @Param ChartPermissionId query int false "行业id"
- // @Success 200 {object} models.ReportMappingResp
- // @router /strategyAll [get]
- func (this *ChartPermissionAuthController) StrategyDetail() {
- 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
- }
- //默认给策略的ID
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- if chartPermissionId == 0 {
- chartPermissionId = utils.CE_LUE_ID
- }
- uid := user.UserId
- list, err := models.GetReportMappingStrategyHomeAllByCygx(chartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- count, err := models.GetUserIsReadThisNewCategoryArticleCount(v.CategoryId, uid)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- Newdetail, err := models.GetNewArticleByCategoryId(v.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
- list[k].IsRed = true
- }
- }
- cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ReportMappingHomeResp)
- if chartPermissionId != utils.GU_SHOU_ID_CHART && chartPermissionId != utils.ZHOU_QI_ID {
- if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
- item := new(models.ReportMappingHome)
- item.CategoryId = utils.TIME_LINE_ID
- item.SubCategoryName = utils.TIME_LINE_NAME
- item.MatchTypeName = utils.TIME_LINE_NAME
- item.ListGroup = 1
- resp.List = append(resp.List, item)
- }
- }
- cfGushou, err := models.GetConfigByCode(utils.CYGX_GUSHOU_TIME_LINE_STATUS)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if chartPermissionId == utils.GU_SHOU_ID_CHART {
- if cfGushou.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
- item := new(models.ReportMappingHome)
- item.CategoryId = utils.TIME_LINE_ID
- item.SubCategoryName = utils.TIME_LINE_NAME
- item.MatchTypeName = utils.TIME_LINE_NAME
- item.ListGroup = 1
- resp.List = append(resp.List, item)
- }
- }
- for _, v := range list {
- resp.List = append(resp.List, v)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取所有品种(无需token)
- // @Description 获取所有品种(无需token)
- // @Success 200 {object} models.ChartPermissionResp
- // @router /allPublic [get]
- func (this *ChartPermissionController) DetailPublic() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- var condition string
- list, err := models.GetChartPermissionAll(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.ChartPermissionResp)
- for k, v := range list {
- resp.List = append(resp.List, v)
- if services.GetShowSustainable() && v.PermissionName == "研选" {
- resp.List[k].IsShowSustainable = true
- }
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取报告所有品种7.0版本
- // @Description 获取报告所有品种接口7.0版本
- // @Success 200 {object} models.ChartPermissionResp
- // @router /reportallV7 [get]
- func (this *ChartPermissionAuthController) ReportDetailV7() {
- 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 condition string
- //var userType int
- //if user.CompanyId > 1 {
- // total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- // }
- // if total == 0 {
- // userType = 0
- // } else {
- // companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
- // if err != nil {
- // br.Msg = "获取信息失败!"
- // br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- // return
- // }
- // if companyDetail.Status == "永续" {
- // userType = 1
- // }
- // }
- //}
- condition += ` AND chart_permission_id NOT IN (31,52)`
- list, err := models.GetChartPermissionReportAll(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.ChartPermissionResp)
- for k, v := range list {
- //if userType == 1 {
- // if v.PermissionName != "研选" {
- // resp.List = append(resp.List, v)
- // }
- //} else {
- // resp.List = append(resp.List, v)
- //}
- resp.List = append(resp.List, v)
- //if strings.Contains(v.PermissionName,"")
- if services.GetShowSustainable() && v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
- resp.List[k].IsShowSustainable = true
- }
- }
- //item := new(models.ChartPermission)
- //item.PermissionName = utils.GU_SHOU_NAME
- //item.ChartPermissionId = utils.GU_SHOU_ID
- //resp.List = append(resp.List, item)
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
- // @Description 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
- // @Success 200 {object} models.ChartPermissionResp
- // @router /noyx [get]
- func (this *ChartPermissionAuthController) Noyx() {
- 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 condition string
- condition += ` AND permission_name IN ('医药1','消费','科技','智造','策略','固收','周期') `
- list, err := models.GetChartPermissionReportAll(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.ChartPermissionResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|