public.go 6.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package logic
  2. import (
  3. "fmt"
  4. "hongze/hongze_yb/models/tables/chart_permission"
  5. "hongze/hongze_yb/utils"
  6. )
  7. type ApplyVariety struct {
  8. PermissionName string `json:"permission_name" description:"权限名称"`
  9. Name string `json:"name" description:"品种名称"`
  10. PicUrl string `json:"pic_url" description:"品种图片"`
  11. }
  12. // GetApplyVarietyList 获取所有可以申请的品种权限
  13. func GetApplyVarietyList() (list []ApplyVariety, err error) {
  14. // 查询所有的二级品种,按照顺序排序,
  15. permissionImgMap := make(map[string]string, 0)
  16. permissionImgMap["宏观经济"] = "https://hzstatic.hzinsights.com/static/yb_variety/宏观经济.png"
  17. permissionImgMap["利率债"] = "https://hzstatic.hzinsights.com/static/yb_variety/利率债.png"
  18. permissionImgMap["原油"] = "https://hzstatic.hzinsights.com/static/yb_variety/原油.png"
  19. permissionImgMap["PTA"] = "https://hzstatic.hzinsights.com/static/yb_variety/PTA.png"
  20. permissionImgMap["MEG"] = "https://hzstatic.hzinsights.com/static/yb_variety/MEG.png"
  21. permissionImgMap["织造终端"] = "https://hzstatic.hzinsights.com/static/yb_variety/织造终端.png"
  22. permissionImgMap["甲醇"] = "https://hzstatic.hzinsights.com/static/yb_variety/甲醇.png"
  23. permissionImgMap["聚烯烃"] = "https://hzstatic.hzinsights.com/static/yb_variety/聚烯烃.png"
  24. permissionImgMap["沥青"] = "https://hzstatic.hzinsights.com/static/yb_variety/沥青.png"
  25. permissionImgMap["苯乙烯"] = "https://hzstatic.hzinsights.com/static/yb_variety/苯乙烯.png"
  26. permissionImgMap["PVC"] = "https://hzstatic.hzinsights.com/static/yb_variety/PVC.png"
  27. permissionImgMap["聚酯"] = "https://hzstatic.hzinsights.com/static/yb_variety/聚酯.png"
  28. permissionImgMap["钢材"] = "https://hzstatic.hzinsights.com/static/yb_variety/钢材.png"
  29. permissionImgMap["铁矿"] = "https://hzstatic.hzinsights.com/static/yb_variety/铁矿.png"
  30. permissionImgMap["玻璃纯碱"] = "https://hzstatic.hzinsights.com/static/yb_variety/玻璃纯碱.png"
  31. permissionImgMap["双焦"] = "https://hzstatic.hzinsights.com/static/yb_variety/双焦(焦煤、焦炭).png"
  32. permissionImgMap["铜"] = "https://hzstatic.hzinsights.com/static/yb_variety/有色(铜、铝).png"
  33. permissionImgMap["铝"] = "https://hzstatic.hzinsights.com/static/yb_variety/有色(铜、铝).png"
  34. permissionImgMap["镍/不锈钢"] = "https://hzstatic.hzinsights.com/static/yb_variety/镍2不锈钢.png"
  35. permissionImgMap["锌"] = "https://hzstatic.hzinsights.com/static/yb_variety/有色锌.png"
  36. permissionImgMap["钴锂"] = "https://hzstatic.hzinsights.com/static/yb_variety/钴锂.png"
  37. allFiccPermissions, e := chart_permission.GetListByProductIdAndPermissionType(1)
  38. if e != nil {
  39. err = fmt.Errorf("获取品种权限失败 Err:%s", e.Error())
  40. return
  41. }
  42. for _, v := range allFiccPermissions {
  43. if v.ParentId > 0 {
  44. tmp := ApplyVariety{PermissionName: v.PermissionName, Name: v.PermissionName, PicUrl: utils.APPLY_VARIETY_IMG_DEFAULT}
  45. img, ok := permissionImgMap[v.PermissionName]
  46. if ok {
  47. tmp.PicUrl = img
  48. }
  49. list = append(list, tmp)
  50. }
  51. }
  52. /*list = append(list, ApplyVariety{PermissionName: "宏观经济", Name: "宏观经济", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/宏观经济.png"})
  53. list = append(list, ApplyVariety{PermissionName: "利率债", Name: "利率债", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/利率债.png"})
  54. list = append(list, ApplyVariety{PermissionName: "原油", Name: "原油", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/原油.png"})
  55. list = append(list, ApplyVariety{PermissionName: "PTA", Name: "PTA", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/PTA.png"})
  56. list = append(list, ApplyVariety{PermissionName: "MEG", Name: "MEG", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/MEG.png"})
  57. list = append(list, ApplyVariety{PermissionName: "织造终端", Name: "织造终端", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/织造终端.png"})
  58. list = append(list, ApplyVariety{PermissionName: "甲醇", Name: "甲醇", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/甲醇.png"})
  59. list = append(list, ApplyVariety{PermissionName: "聚烯烃", Name: "聚烯烃", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/聚烯烃.png"})
  60. list = append(list, ApplyVariety{PermissionName: "沥青", Name: "沥青", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/沥青.png"})
  61. list = append(list, ApplyVariety{PermissionName: "纯苯+苯乙烯", Name: "纯苯+苯乙烯", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/苯乙烯.png"})
  62. list = append(list, ApplyVariety{PermissionName: "PVC", Name: "PVC", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/PVC.png"})
  63. list = append(list, ApplyVariety{PermissionName: "聚酯", Name: "聚酯", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/聚酯.png"})
  64. list = append(list, ApplyVariety{PermissionName: "钢材", Name: "钢材", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/钢材.png"})
  65. list = append(list, ApplyVariety{PermissionName: "铁矿", Name: "铁矿", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/铁矿.png"})
  66. list = append(list, ApplyVariety{PermissionName: "玻璃纯碱", Name: "玻璃纯碱", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/玻璃纯碱.png"})
  67. list = append(list, ApplyVariety{PermissionName: "双焦(焦煤、焦炭)", Name: "双焦(焦煤、焦炭)", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/双焦(焦煤、焦炭).png"})
  68. list = append(list, ApplyVariety{PermissionName: "有色(铜、铝)", Name: "有色(铜、铝)", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/有色(铜、铝).png"})
  69. list = append(list, ApplyVariety{PermissionName: "镍+不锈钢", Name: "镍+不锈钢", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/镍2不锈钢.png"})
  70. list = append(list, ApplyVariety{PermissionName: "有色(锌)", Name: "有色(锌)", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/有色锌.png"})
  71. list = append(list, ApplyVariety{PermissionName: "钴锂", Name: "钴锂", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/钴锂.png"})*/
  72. //list = append(list, ApplyVariety{PermissionName: "苯乙烯", Name: "苯乙烯", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/苯乙烯.png"})
  73. //list = append(list, ApplyVariety{PermissionName: "橡胶", Name: "橡胶", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/橡胶.png"})
  74. //list = append(list, ApplyVariety{PermissionName: "策略", Name: "市场策略", PicUrl: "https://hzstatic.hzinsights.com/static/yb_variety/市场策略.png"})
  75. return
  76. }