chart_permission.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package crm
  2. import (
  3. "hongze/fms_api/global"
  4. "time"
  5. )
  6. // ChartPermission CRM系统-权限表
  7. type ChartPermission struct {
  8. ChartPermissionId int `gorm:"primaryKey;column:chart_permission_id" json:"chart_permission_id" description:"权限ID"`
  9. ChartPermissionName string `gorm:"column:chart_permission_name" json:"chart_permission_name" description:"名称"`
  10. PermissionName string `gorm:"column:permission_name" json:"permission_name" description:"权限名"`
  11. Sort int `gorm:"column:sort" json:"sort" description:"排序"`
  12. Enabled int `gorm:"column:enabled" json:"enabled" description:"是否可用"`
  13. CreatedTime time.Time `gorm:"column:created_time" json:"created_time" description:"创建时间"`
  14. LastUpdatedTime time.Time `gorm:"column:last_updated_time" json:"last_updated_time" description:"更新时间"`
  15. TeleconferenceSort int `gorm:"column:teleconference_sort" json:"teleconference_sort" description:"电话会类型排序"`
  16. Remark string `gorm:"column:remark" json:"remark" description:"备注"`
  17. ClassifyName string `gorm:"column:classify_name" json:"classify_name" description:"分类名称"`
  18. ProductName string `gorm:"column:product_name" json:"product_name" description:"产品名称"`
  19. ProductID int `gorm:"column:product_id" json:"product_id" description:"产品ID"`
  20. ImageURL string `gorm:"column:image_url" json:"image_url" description:"图片地址"`
  21. ShowType int `gorm:"column:show_type" json:"show_type" description:"1:查研观向小程序展示"`
  22. IsOther int `gorm:"column:is_other" json:"is_other" description:"是否是其他,用于查研观向小程序后台展示"`
  23. IsReport int `gorm:"column:is_report" json:"is_report" description:"是否是报告,用于查研观向小程序前台报告展示"`
  24. CygxAuth int `gorm:"column:cygx_auth" json:"cygx_auth" description:"是否是权限,用于查研观向小程序前台权限校验"`
  25. YbImgUrl string `gorm:"column:yb_img_url" json:"yb_img_url" description:"研报小程序报告列表icon"`
  26. PriceDrivenState int `gorm:"column:price_driven_state" json:"price_driven_state" description:"品种价格驱动开启状态 0-关闭 1-开启"`
  27. ParentId int `gorm:"column:parent_id;default:0;NOT NULL;comment:'父级权限id'" json:"parent_id"`
  28. IsPublic int `gorm:"column:is_public;default:0;NOT NULL;comment:'是否是公有权限1:公有权限,0私有权限'" json:"is_public"`
  29. }
  30. func (cp *ChartPermission) TableName() string {
  31. return "chart_permission"
  32. }
  33. func (cp *ChartPermission) List(condition string, pars []interface{}) (list []*ChartPermission, err error) {
  34. list = make([]*ChartPermission, 0)
  35. err = global.MYSQL["report"].Model(cp).
  36. Where(condition, pars...).
  37. Order("sort ASC").
  38. Find(&list).Error
  39. return
  40. }
  41. type PermissionSetResp struct {
  42. List []*PermissionSetList
  43. }
  44. type PermissionSetList struct {
  45. ClassifyName string `json:"classify_name" description:"分类"`
  46. Items []*PermissionSetItem `json:"items"`
  47. CheckList []int `json:"check_list"`
  48. }
  49. type PermissionSetItem struct {
  50. ChartPermissionId int `json:"chart_permission_id" description:"权限id"`
  51. PermissionName string `json:"permission_name" description:"权限名称"`
  52. PermissionType int `json:"permission_type" description:"1主观,2客观"`
  53. Checked bool `json:"checked" description:"选中状态"`
  54. ClassifyName string `json:"classify_name" description:"分类名称"`
  55. ParentId int `description:"父级权限id"`
  56. IsPublic int `description:"是否是公有权限1:公有权限,0私有权限"`
  57. }
  58. func GetPermissionSetItemsByCondition(condition string, pars []interface{}) (items []*PermissionSetItem, err error) {
  59. items = make([]*PermissionSetItem, 0)
  60. err = global.MYSQL["report"].
  61. Table("chart_permission").
  62. Where(condition, pars...).
  63. Order("sort ASC").
  64. Find(&items).Error
  65. return
  66. }
  67. // ContractPermissionListReq CRM系统合同权限-列表请求体
  68. type ContractPermissionListReq struct {
  69. ProductId int `json:"product_id" form:"product_id" description:"产品: 1-FICC; 2-权益"`
  70. }
  71. type CompanyPermissionLookItem struct {
  72. ChartPermissionId int `description:"权限id"`
  73. PermissionName string `description:"权限名称"`
  74. StartDate string `description:"权限开始日期"`
  75. EndDate string `description:"权限结束日期"`
  76. Status string `description:"'正式','试用','关闭'"`
  77. ExpireDay string `description:"到期天数"`
  78. ClassifyName string `description:"分类"`
  79. PermissionType int `description:"1主观,2客观"`
  80. PermissionTypeName string `description:"主观、客观"`
  81. Checked bool `description:"选中状态"`
  82. Remark string `description:"备注"`
  83. IsMerge bool `description:"是否合并行业, 给前端的标识, 暂时仅权益使用"`
  84. RaiBothHas bool `description:"权益-是否主客观都有"`
  85. IsUpgrade int `description:"是否升级,1是,0否"`
  86. ParentId int `description:"父级权限id"`
  87. IsPublic int `description:"是否是公有权限1:公有权限,0私有权限"`
  88. }
  89. func GetPermissionLookItems(productId int, classifyName string) (items []*CompanyPermissionLookItem, err error) {
  90. items = make([]*CompanyPermissionLookItem, 0)
  91. err = global.MYSQL["report"].Table("chart_permission").
  92. Where("enabled = 1 AND product_id = ? AND classify_name = ? AND parent_id>0", productId, classifyName).
  93. Order("sort ASC").
  94. Find(&items).Error
  95. return
  96. }
  97. func GetSecondPermissionLookItemsByProductId(productId int) (items []*CompanyPermissionLookItem, err error) {
  98. items = make([]*CompanyPermissionLookItem, 0)
  99. err = global.MYSQL["report"].Table("chart_permission").
  100. Where("enabled = 1 AND product_id = ? AND parent_id>0", productId).
  101. Order("sort ASC").
  102. Find(&items).Error
  103. return
  104. }