|
@@ -8,7 +8,6 @@ import (
|
|
|
"hongze/hongze_yb/models/response"
|
|
|
"hongze/hongze_yb/models/tables/admin"
|
|
|
"hongze/hongze_yb/models/tables/chart_permission"
|
|
|
- "hongze/hongze_yb/models/tables/chart_permission_first"
|
|
|
"hongze/hongze_yb/models/tables/company"
|
|
|
"hongze/hongze_yb/models/tables/company_product"
|
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
@@ -628,23 +627,33 @@ type PermissionItem struct {
|
|
|
func GetFiccPermissionList() (list []*FiccPermissionList, err error) {
|
|
|
productId := 1
|
|
|
list = make([]*FiccPermissionList, 0)
|
|
|
- for _, v := range utils.PermissionFiccClassifyArr {
|
|
|
- classify := new(FiccPermissionList)
|
|
|
- classify.ClassifyName = v
|
|
|
- items, e := chart_permission.GetListByProductIdAndClassifyName(productId, v)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("获取品种权限失败 Err:" + e.Error())
|
|
|
- return
|
|
|
+ allFiccPermissions, e := chart_permission.GetListByProductIdAndPermissionType(productId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取品种权限失败 Err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionMap := make(map[int][]*chart_permission.ChartPermission, 0)
|
|
|
+ for _, v := range allFiccPermissions {
|
|
|
+ if v.ParentId > 0 {
|
|
|
+ permissionMap[v.ParentId] = append(permissionMap[v.ParentId], v)
|
|
|
}
|
|
|
- tmpItems := make([]*PermissionItem, 0)
|
|
|
- for _, iv := range items {
|
|
|
- item := new(PermissionItem)
|
|
|
- item.PermissionId = int(iv.ChartPermissionID)
|
|
|
- item.PermissionName = iv.PermissionName
|
|
|
- tmpItems = append(tmpItems, item)
|
|
|
+ }
|
|
|
+ for _, v := range allFiccPermissions {
|
|
|
+ if v.ParentId == 0 {
|
|
|
+ classify := new(FiccPermissionList)
|
|
|
+ classify.ClassifyName = v.PermissionName
|
|
|
+ classify.Items = make([]*PermissionItem, 0)
|
|
|
+ items, ok := permissionMap[int(v.ChartPermissionID)]
|
|
|
+ if ok {
|
|
|
+ for _, iv := range items {
|
|
|
+ item := new(PermissionItem)
|
|
|
+ item.PermissionId = int(iv.ChartPermissionID)
|
|
|
+ item.PermissionName = iv.PermissionName
|
|
|
+ classify.Items = append(classify.Items, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list = append(list, classify)
|
|
|
}
|
|
|
- classify.Items = tmpItems
|
|
|
- list = append(list, classify)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -669,50 +678,54 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
|
|
|
return
|
|
|
}
|
|
|
permissionMap := make(map[uint64]bool)
|
|
|
- permissionFirstMap := make(map[string]*response.PermissionFirstItem)
|
|
|
+ permissionFirstMap := make(map[int]*response.PermissionFirstItem)
|
|
|
|
|
|
//查询首页展示的图标
|
|
|
- permissionFirstList, err := chart_permission_first.GetIndexShowList()
|
|
|
+ permissionFirstList, err := chart_permission.GetFiccFirstListExceptTacticByProductId()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
for _, v := range permissionFirstList {
|
|
|
- permissionFirstMap[v.ClassifyName] = &response.PermissionFirstItem{
|
|
|
- Id: int(v.Id),
|
|
|
- Sort: v.YbIndexSort + 1000,
|
|
|
- YbIndexName: v.YbIndexName,
|
|
|
- YbIndexIcon: v.YbIndexIcon,
|
|
|
+ permissionFirstMap[int(v.ChartPermissionID)] = &response.PermissionFirstItem{
|
|
|
+ Id: int(v.ChartPermissionID),
|
|
|
+ Sort: v.Sort + 1000,
|
|
|
+ YbIndexName: v.PermissionName,
|
|
|
+ YbIndexIcon: "",
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for k, v := range permissionList {
|
|
|
- permissionMap[v.ChartPermissionID] = false
|
|
|
- for _, myPerId := range validPermissionIds {
|
|
|
- if int(v.ChartPermissionID) == myPerId {
|
|
|
- permissionMap[v.ChartPermissionID] = true
|
|
|
- permissionList[k].Sort = v.Sort - 1000
|
|
|
- if _, ok := permissionFirstMap[v.ClassifyName]; ok && !permissionFirstMap[v.ClassifyName].IsCheck {
|
|
|
- permissionFirstMap[v.ClassifyName].AuthOk = true
|
|
|
- permissionFirstMap[v.ClassifyName].Sort -= 1000
|
|
|
- permissionFirstMap[v.ClassifyName].IsCheck = true
|
|
|
+ if v.ParentId > 0 {
|
|
|
+ permissionMap[v.ChartPermissionID] = false
|
|
|
+ for _, myPerId := range validPermissionIds {
|
|
|
+ if int(v.ChartPermissionID) == myPerId {
|
|
|
+ permissionMap[v.ChartPermissionID] = true
|
|
|
+ permissionList[k].Sort = v.Sort - 1000
|
|
|
+ if _, ok := permissionFirstMap[v.ParentId]; ok && !permissionFirstMap[v.ParentId].IsCheck {
|
|
|
+ permissionFirstMap[v.ParentId].AuthOk = true
|
|
|
+ permissionFirstMap[v.ParentId].Sort -= 1000
|
|
|
+ permissionFirstMap[v.ParentId].IsCheck = true
|
|
|
+ }
|
|
|
+ break
|
|
|
}
|
|
|
- break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for _, v := range permissionList {
|
|
|
- temp := new(response.PermissionFiccSecondItem)
|
|
|
- temp.Sort = v.Sort
|
|
|
- temp.ChartPermissionID = int(v.ChartPermissionID)
|
|
|
- temp.ChartPermissionName = v.PermissionName
|
|
|
- temp.AuthOk = permissionMap[v.ChartPermissionID]
|
|
|
- temp.PirceDrivenState = v.PriceDrivenState
|
|
|
- if _, ok := permissionFirstMap[v.ClassifyName]; ok {
|
|
|
- permissionFirstMap[v.ClassifyName].List = append(permissionFirstMap[v.ClassifyName].List, temp)
|
|
|
- } else {
|
|
|
- permissionFirstMap[v.ClassifyName] = &response.PermissionFirstItem{
|
|
|
- List: []*response.PermissionFiccSecondItem{temp},
|
|
|
+ if v.ParentId > 0 {
|
|
|
+ temp := new(response.PermissionFiccSecondItem)
|
|
|
+ temp.Sort = v.Sort
|
|
|
+ temp.ChartPermissionID = int(v.ChartPermissionID)
|
|
|
+ temp.ChartPermissionName = v.PermissionName
|
|
|
+ temp.AuthOk = permissionMap[v.ChartPermissionID]
|
|
|
+ temp.PirceDrivenState = v.PriceDrivenState
|
|
|
+ if _, ok := permissionFirstMap[v.ParentId]; ok {
|
|
|
+ permissionFirstMap[v.ParentId].List = append(permissionFirstMap[v.ParentId].List, temp)
|
|
|
+ } else {
|
|
|
+ permissionFirstMap[v.ParentId] = &response.PermissionFirstItem{
|
|
|
+ List: []*response.PermissionFiccSecondItem{temp},
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -948,22 +961,22 @@ func GetBindFiccPermissions(user user.UserInfo) (ret response.BindPermissionFicc
|
|
|
for _, item := range validPermissionList {
|
|
|
validPermissionIds = append(validPermissionIds, item.ChartPermissionID)
|
|
|
}
|
|
|
- permissionList, err := chart_permission.GetFiccListExceptTacticByProductIdOrderSort()
|
|
|
+ permissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
permissionMap := make(map[uint64]bool)
|
|
|
- permissionFirstMap := make(map[string]*response.BindPermissionFiccItem)
|
|
|
+ permissionFirstMap := make(map[int]*response.BindPermissionFiccItem)
|
|
|
|
|
|
//查询首页展示的图标
|
|
|
- permissionFirstList, err := chart_permission_first.GetIndexShowListOrderSort()
|
|
|
+ permissionFirstList, err := chart_permission.GetFiccFirstListExceptTacticByProductId()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
for _, v := range permissionFirstList {
|
|
|
- permissionFirstMap[v.ClassifyName] = &response.BindPermissionFiccItem{
|
|
|
- Id: int(v.Id),
|
|
|
- ClassifyName: v.YbIndexName,
|
|
|
+ permissionFirstMap[int(v.ChartPermissionID)] = &response.BindPermissionFiccItem{
|
|
|
+ Id: int(v.ChartPermissionID),
|
|
|
+ ClassifyName: v.ChartPermissionName,
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -981,14 +994,14 @@ func GetBindFiccPermissions(user user.UserInfo) (ret response.BindPermissionFicc
|
|
|
temp := new(response.BindPermissionFiccSecondItem)
|
|
|
temp.ChartPermissionID = int(v.ChartPermissionID)
|
|
|
temp.ChartPermissionName = v.PermissionName
|
|
|
- if _, ok := permissionFirstMap[v.ClassifyName]; ok && permissionMap[v.ChartPermissionID] {
|
|
|
- permissionFirstMap[v.ClassifyName].List = append(permissionFirstMap[v.ClassifyName].List, temp)
|
|
|
+ if _, ok := permissionFirstMap[v.ParentId]; ok && permissionMap[v.ChartPermissionID] {
|
|
|
+ permissionFirstMap[v.ParentId].List = append(permissionFirstMap[v.ParentId].List, temp)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var list []*response.BindPermissionFiccItem
|
|
|
for _, v := range permissionFirstList {
|
|
|
- item := permissionFirstMap[v.ClassifyName]
|
|
|
+ item := permissionFirstMap[int(v.ChartPermissionID)]
|
|
|
if len(item.List) > 0 {
|
|
|
temp := new(response.BindPermissionFiccItem)
|
|
|
temp.Id = item.Id
|
|
@@ -1041,22 +1054,22 @@ func GetCommoditiesBindFiccPermissions(user user.UserInfo) (ret response.BindPer
|
|
|
for _, item := range validPermissionList {
|
|
|
validPermissionIds = append(validPermissionIds, item.ChartPermissionID)
|
|
|
}
|
|
|
- permissionList, err := chart_permission.GetFiccListExceptTacticByProductIdOrderSort()
|
|
|
+ permissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
permissionMap := make(map[uint64]bool)
|
|
|
- permissionFirstMap := make(map[string]*response.BindPermissionFiccItem)
|
|
|
+ permissionFirstMap := make(map[int]*response.BindPermissionFiccItem)
|
|
|
|
|
|
//查询首页展示的图标
|
|
|
- permissionFirstList, err := chart_permission_first.GetIndexShowListOrderSort()
|
|
|
+ permissionFirstList, err := chart_permission.GetFiccFirstListExceptTacticByProductId()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
for _, v := range permissionFirstList {
|
|
|
- permissionFirstMap[v.ClassifyName] = &response.BindPermissionFiccItem{
|
|
|
- Id: int(v.Id),
|
|
|
- ClassifyName: v.YbIndexName,
|
|
|
+ permissionFirstMap[int(v.ChartPermissionID)] = &response.BindPermissionFiccItem{
|
|
|
+ Id: int(v.ChartPermissionID),
|
|
|
+ ClassifyName: v.ChartPermissionName,
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1074,22 +1087,22 @@ func GetCommoditiesBindFiccPermissions(user user.UserInfo) (ret response.BindPer
|
|
|
temp := new(response.BindPermissionFiccSecondItem)
|
|
|
temp.ChartPermissionID = int(v.ChartPermissionID)
|
|
|
temp.ChartPermissionName = v.PermissionName
|
|
|
- if _, ok := permissionFirstMap[v.ClassifyName]; ok && permissionMap[v.ChartPermissionID] {
|
|
|
- permissionFirstMap[v.ClassifyName].List = append(permissionFirstMap[v.ClassifyName].List, temp)
|
|
|
+ if _, ok := permissionFirstMap[v.ParentId]; ok && permissionMap[v.ChartPermissionID] {
|
|
|
+ permissionFirstMap[v.ParentId].List = append(permissionFirstMap[v.ParentId].List, temp)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var list []*response.BindPermissionFiccItem
|
|
|
LOOP:
|
|
|
for _, v := range permissionFirstList {
|
|
|
- item := permissionFirstMap[v.ClassifyName]
|
|
|
+ item := permissionFirstMap[int(v.ChartPermissionID)]
|
|
|
if len(item.List) > 0 {
|
|
|
temp := new(response.BindPermissionFiccItem)
|
|
|
temp.Id = item.Id
|
|
|
temp.ClassifyName = item.ClassifyName
|
|
|
temp.List = item.List
|
|
|
//大宗商品分类内合并PTA&MEG
|
|
|
- if temp.ClassifyName == "化工" {
|
|
|
+ if temp.ClassifyName == "化工产业" {
|
|
|
count := 0
|
|
|
for i, secondItem := range temp.List {
|
|
|
if secondItem.ChartPermissionName == "PTA" || secondItem.ChartPermissionName == "MEG" {
|