123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- package controllers
- import (
- "eta/eta_api/models"
- "eta/eta_api/models/company"
- "eta/eta_api/services"
- "eta/eta_api/utils"
- )
- // CompanyPermissionController 客户权限管理
- type CompanyPermissionController struct {
- BaseAuthController
- }
- // List
- // @Title 获取权限设置基础信息
- // @Description 获取权限设置基础信息接口
- // @Param CompanyType query string true "客户类型:传空字符串或者不传为全部,'ficc','权益'"
- // @Param NoUpgrade query bool false "是否不展示升级权限,默认为 false"
- // @Success 200 {object} company.PermissionSetResp
- // @router /permission/list [get]
- func (this *CompanyPermissionController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- // 非自用无需查询
- resp := new(company.PermissionSetResp)
- if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox && utils.BusinessCode != utils.BusinessCodeDebug {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- // Tips:目前这个接口权益在添加客户、申请转正、领取客户、续约申请均有用到
- companyType := this.GetString("CompanyType")
- var productId int
- roleTypeCode := sysUser.RoleTypeCode
- productId = services.GetProductId(roleTypeCode)
- // FICC
- if productId == utils.COMPANY_PRODUCT_FICC_ID || companyType == utils.COMPANY_PRODUCT_FICC_NAME {
- /*for _, v := range utils.PermissionFiccClassifyArr {
- checkList := make([]int, 0)
- p := new(company.PermissionSetList)
- p.ClassifyName = v
- items, err := company.GetPermissionSetItems(utils.COMPANY_PRODUCT_FICC_ID, v)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- p.Items = items
- if v == "宏观经济" {
- checkList = append(checkList, 1)
- }
- p.CheckList = checkList
- resp.List = append(resp.List, p)
- }*/
- list, err := services.GetChartPermissionEnabledList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // PermissionVariety
- // @Title 品种
- // @Description 品种接口
- // @Param CompanyType query string true "客户类型:传空字符串或者不传为全部,'ficc','权益'"
- // @Success 200 {object} company.PermissionVarietyResp
- // @router /permission/variety [get]
- func (this *CompanyPermissionController) PermissionVariety() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox && utils.BusinessCode != utils.BusinessCodeDebug {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- return
- }
- companyType := this.GetString("CompanyType")
- var productId int
- resp := new(company.PermissionVarietyResp)
- roleTypeCode := sysUser.RoleTypeCode
- if roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
- productId = 2
- } else if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
- productId = 1
- } else {
- productId = 0
- }
- if productId == 1 {
- for k, v := range utils.PermissionFiccClassifyArr {
- p := new(company.PermissionVarietyList)
- p.ClassifyName = v
- p.ChartPermissionId = k + 100
- items, err := company.GetPermissionVarietyItems(productId, v)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- p.Items = items
- resp.List = append(resp.List, p)
- }
- } else if productId == 2 {
- v := "权益"
- p := new(company.PermissionVarietyList)
- p.ClassifyName = v
- p.ChartPermissionId = 105
- items, err := company.GetPermissionVarietyItems(productId, v)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- p.Items = items
- resp.List = append(resp.List, p)
- } else {
- if companyType == utils.COMPANY_PRODUCT_FICC_NAME {
- for k, v := range utils.PermissionFiccClassifyArr {
- p := new(company.PermissionVarietyList)
- p.ClassifyName = v
- p.ChartPermissionId = k + 100
- items, err := company.GetPermissionVarietyItems(1, v)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- p.Items = items
- resp.List = append(resp.List, p)
- }
- } else if companyType == utils.COMPANY_PRODUCT_RAI_NAME {
- v := "权益"
- p := new(company.PermissionVarietyList)
- p.ClassifyName = v
- p.ChartPermissionId = 105
- items, err := company.GetPermissionVarietyItems(2, v)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
- return
- }
- p.Items = items
- resp.List = append(resp.List, p)
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|