admin.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hongze_clpt/utils"
  5. "time"
  6. )
  7. type Admin struct {
  8. AdminId int `orm:"column(admin_id);pk" description:"系统用户id"`
  9. AdminName string `description:"系统用户名称"`
  10. AdminAvatar string `description:"用户头像"`
  11. RealName string `description:"系统用户姓名"`
  12. Password string `json:"-"`
  13. LastUpdatedPasswordTime string `json:"-"`
  14. Enabled int
  15. Email string `description:"系统用户邮箱"`
  16. LastLoginTime string
  17. CreatedTime time.Time
  18. LastUpdatedTime string
  19. Role string `description:"系统用户角色"`
  20. Mobile string `description:"手机号"`
  21. RoleType int `description:"角色类型:1需要录入指标,0:不需要"`
  22. RoleId int `description:"角色ID"`
  23. RoleName string `description:"角色名称"`
  24. RoleTypeCode string `description:"角色类型编码"`
  25. DepartmentId int `description:"部门id"`
  26. DepartmentName string `description:"部门名称"`
  27. GroupId int `description:"分组id"`
  28. GroupName string `description:"分组名称"`
  29. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
  30. Position string `description:"职位"`
  31. DisableTime time.Time `description:"禁用时间"`
  32. ChartPermission int8 `description:"图表权限id"`
  33. OpenId string `description:"弘则部门公众号的openid"`
  34. UnionId string `description:"微信公众平台唯一标识"`
  35. EdbPermission int8 `description:"指标库操作权限,0:只能操作 自己的,1:所有指标可操作"`
  36. MysteelChemicalPermission int8 `description:"钢联化工指标操作权限,0:只能操作 自己的,1:所有指标可操作"`
  37. PredictEdbPermission int8 `description:"预测指标库操作权限,0:只能操作 自己的,1:所有预测指标可操作"`
  38. Province string `description:"省"`
  39. ProvinceCode string `description:"省编码"`
  40. City string `description:"市"`
  41. CityCode string `description:"市编码"`
  42. }
  43. type AdminMobileResp struct {
  44. Mobile string `description:"手机号"`
  45. }
  46. // 获取销售所能查看到的手机号
  47. func GetAdminByRole() (items []*AdminMobileResp, err error) {
  48. o := orm.NewOrmUsingDB("weekly_report")
  49. sql := ` SELECT mobile FROM admin WHERE role = 'admin' `
  50. _, err = o.Raw(sql).QueryRows(&items)
  51. return
  52. }
  53. // 获取权益内部人员手机号
  54. func GetRaiAdmin() (items []*AdminMobileResp, err error) {
  55. o := orm.NewOrmUsingDB("weekly_report")
  56. sql := ` SELECT
  57. mobile
  58. FROM
  59. admin
  60. WHERE
  61. role_type_code LIKE '%rai%'
  62. AND group_id NOT IN ( 19, 10 )
  63. AND enabled = 1
  64. OR (
  65. department_name = '产品技术部'
  66. AND enabled = 1) `
  67. _, err = o.Raw(sql).QueryRows(&items)
  68. return
  69. }
  70. // 获取IT人员手机号
  71. func GetRaiAdminIt() (items []*AdminMobileResp, err error) {
  72. o := orm.NewOrmUsingDB("weekly_report")
  73. sql := ` SELECT
  74. mobile
  75. FROM
  76. admin
  77. WHERE
  78. department_id = 3
  79. AND enabled = 1 `
  80. _, err = o.Raw(sql).QueryRows(&items)
  81. return
  82. }
  83. // 根据角色名称获取手机号
  84. func GetAdminByRoleName(roleName string) (items []*AdminMobileResp, err error) {
  85. o := orm.NewOrmUsingDB("weekly_report")
  86. sql := `SELECT mobile FROM admin WHERE role_name =? ' `
  87. _, err = o.Raw(sql, roleName).QueryRows(&items)
  88. return
  89. }
  90. func GetSysAdminById(adminId int) (item *Admin, err error) {
  91. sql := `SELECT * FROM admin WHERE admin_id=? `
  92. o := orm.NewOrmUsingDB("weekly_report")
  93. err = o.Raw(sql, adminId).QueryRow(&item)
  94. return
  95. }
  96. // 根据多个ID获取管理员列表信息
  97. func GetAdminByAdminIds(adminId []int) (items []*AdminMobileResp, err error) {
  98. lenArr := len(adminId)
  99. if lenArr == 0 {
  100. return
  101. }
  102. o := orm.NewOrmUsingDB("weekly_report")
  103. sql := ` SELECT mobile FROM admin WHERE admin_id IN (` + utils.GetOrmInReplace(lenArr) + `)`
  104. _, err = o.Raw(sql, adminId).QueryRows(&items)
  105. return
  106. }