company_permission.go 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package company
  2. import (
  3. "eta_gn/eta_api/global"
  4. "time"
  5. )
  6. type ChartPermission struct {
  7. ChartPermissionId int `gorm:"primaryKey;column:chart_permission_id;type:bigint(20) unsigned;not null"` // 主键
  8. ChartPermissionName string `gorm:"column:chart_permission_name;type:varchar(20)"` // 名称
  9. PermissionName string `gorm:"column:permission_name;type:varchar(50);default:''"` // 权限名
  10. Sort int `gorm:"column:sort;type:int(10);default:1"` // 排序
  11. Enabled int `gorm:"column:enabled;type:tinyint(1);default:1"` // 是否可用
  12. CreatedTime time.Time `gorm:"index:created_time;column:created_time;type:datetime;default:CURRENT_TIMESTAMP"` // 创建时间
  13. LastUpdatedTime time.Time `gorm:"index:last_updated_time;column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP"`
  14. TeleconferenceSort int `gorm:"column:teleconference_sort;type:int(4);default:0"` // 电话会类型排序
  15. Remark string `gorm:"column:remark;type:varchar(30)"`
  16. ClassifyName string `gorm:"column:classify_name;type:varchar(50)"`
  17. ProductName string `gorm:"column:product_name;type:varchar(50);default:''"`
  18. ProductId int `gorm:"column:product_id;type:int(11);default:0"`
  19. ImageURL string `gorm:"column:image_url;type:varchar(255)"` // 图片地址
  20. ShowType int `gorm:"column:show_type;type:tinyint(4);default:0"` // 1:查研观向小程序展示
  21. IsOther int `gorm:"column:is_other;type:tinyint(2);not null;default:0"` // 是否是其他,用于查研观向小程序后台展示
  22. IsReport int `gorm:"index:is_report;column:is_report;type:tinyint(4);not null;default:0"` // 是否是报告,用于查研观向小程序前台报告展示
  23. CygxAuth int `gorm:"column:cygx_auth;type:tinyint(4);not null;default:0"` // 是否是权限,用于查研观向小程序前台权限校验
  24. PermissionType int `gorm:"column:permission_type;type:tinyint(2) unsigned;not null;default:0"` // 1主观,2客观
  25. YbImgURL string `gorm:"column:yb_img_url;type:varchar(255)"` // 研报小程序报告列表icon
  26. ProductPermissionName string `gorm:"column:product_permission_name;type:varchar(50);default:''"` // 种类权限名称
  27. PriceDrivenState int `gorm:"column:price_driven_state;type:tinyint(4);not null;default:1"` // 品种价格驱动状态 0-关闭 1-开启
  28. ImageURLM string `gorm:"column:image_url_m;type:varchar(255)"` // 图片地址(查研观向移动端)
  29. ParentId int `gorm:"column:parent_id;type:int(11);not null;default:0"` // 父级权限id
  30. IsPublic int `gorm:"column:is_public;type:tinyint(4);not null;default:0"` // 是否是公有权限1:公有权限,0私有权限
  31. Checked bool `description:"选中状态" gorm:"-"`
  32. }
  33. type PermissionSetItem struct {
  34. ChartPermissionId int `description:"权限id"`
  35. PermissionName string `description:"权限名称"`
  36. PermissionType int `description:"1主观,2客观"`
  37. Checked bool `description:"选中状态"`
  38. Child []*PermissionSetItem `description:"具体的主客观-方便前端的排版用的"`
  39. }
  40. type PermissionSetItemType struct {
  41. PermissionName string `description:"权限名称"`
  42. Checked bool `description:"选中状态"`
  43. CheckedMinate bool `description:"不确定状态"`
  44. NoClicking bool `description:"是否禁止点击"`
  45. Items []*PermissionLookItem
  46. }
  47. type PermissionSetList struct {
  48. PermissionName string `description:"分类"`
  49. Child []*PermissionSetItem
  50. CheckList []int
  51. }
  52. type PermissionSetListType struct {
  53. PermissionName string `description:"分类"`
  54. Child []*PermissionSetItemType
  55. CheckList []int
  56. }
  57. type PermissionSetResp struct {
  58. List []*PermissionSetList
  59. ListType []*PermissionSetListType `description:"主观客观列表"`
  60. }
  61. type PermissionLookItem struct {
  62. ChartPermissionId int `description:"权限id"`
  63. PermissionName string `description:"权限名称"`
  64. StartDate string `description:"权限开始日期"`
  65. EndDate string `description:"权限结束日期"`
  66. Status string `description:"'正式','试用','关闭'"`
  67. ExpireDay string `description:"到期天数"`
  68. ClassifyName string `description:"分类"`
  69. PermissionType int `description:"1主观,2客观"`
  70. PermissionTypeName string `description:"主观、客观"`
  71. Checked bool `description:"选中状态"`
  72. Remark string `description:"备注"`
  73. IsMerge bool `description:"是否合并行业, 给前端的标识, 暂时仅权益使用"`
  74. RaiBothHas bool `description:"权益-是否主客观都有"`
  75. IsUpgrade int `description:"是否升级,1是,0否"`
  76. Child []*PermissionLookItem `description:"子权限"`
  77. }
  78. type PermissionVarietyResp struct {
  79. List []*PermissionVarietyList
  80. }
  81. type PermissionVarietyItem struct {
  82. ChartPermissionId int `gorm:"column:chart_permission_id;type:bigint(20) unsigned;not null"`
  83. ClassifyName string `gorm:"column:classify_name;type:varchar(50)"`
  84. }
  85. type PermissionVarietyList struct {
  86. ChartPermissionId int `description:"父级id"`
  87. ClassifyName string `description:"分类"`
  88. Items []*PermissionVarietyItem
  89. }
  90. func GetPermissionVarietyItems(productId int, classifyName string) (items []*PermissionVarietyItem, err error) {
  91. sql := ` SELECT chart_permission_id, chart_permission_name, permission_name, sort, enabled, created_time, last_updated_time, teleconference_sort, remark, classify_name, product_name, product_id, image_url, show_type, is_other, is_report, cygx_auth, permission_type, yb_img_url, product_permission_name, price_driven_state, image_url_m, parent_id, is_public
  92. FROM chart_permission WHERE enabled=1 AND product_id=? AND classify_name=?
  93. GROUP BY permission_name,
  94. chart_permission_id, chart_permission_name, sort, enabled, created_time, last_updated_time, teleconference_sort, remark, classify_name, product_name, product_id, image_url, show_type, is_other, is_report, cygx_auth, permission_type, yb_img_url, product_permission_name, price_driven_state, image_url_m, parent_id, is_public
  95. ORDER BY sort ASC `
  96. err = global.DmSQL["rddp"].Raw(sql, productId, classifyName).Find(&items).Error
  97. return
  98. }
  99. // GetChartPermissionListById 根据权限id获取产品权限详情
  100. func GetChartPermissionListById(chartPermissionId int) (item *ChartPermission, err error) {
  101. sql := `SELECT * FROM chart_permission WHERE chart_permission_id =? `
  102. err = global.DmSQL["rddp"].Raw(sql, chartPermissionId).First(&item).Error
  103. return
  104. }
  105. func GetParentIdFromGroup(gid int) (items *int, err error) {
  106. sql := `SELECT parent_id FROM sys_group WHERE group_id=? `
  107. err = global.DEFAULT_DmSQL.Raw(sql, gid).Scan(&items).Error
  108. return
  109. }
  110. func GetGroupNamesById(gid int) (items *string, err error) {
  111. sql := `SELECT group_name FROM sys_group WHERE group_id=? `
  112. err = global.DEFAULT_DmSQL.Raw(sql, gid).Scan(&items).Error
  113. return
  114. }