123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- package controllers
- import (
- "eta/eta_mobile/models"
- "eta/eta_mobile/models/company"
- "eta/eta_mobile/services"
- "eta/eta_mobile/utils"
- )
- type CompanyPermissionController struct {
- BaseAuthController
- }
- 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
- }
-
- companyType := this.GetString("CompanyType")
- var productId int
- roleTypeCode := sysUser.RoleTypeCode
- productId = services.GetProductId(roleTypeCode)
-
- if productId == utils.COMPANY_PRODUCT_FICC_ID || companyType == utils.COMPANY_PRODUCT_FICC_NAME {
-
- 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
- }
- 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
- }
|