sys_admin.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package system
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type AdminItem struct {
  8. AdminId int `description:"系统用户id"`
  9. AdminName string `description:"系统用户名称"`
  10. RealName string `description:"系统用户姓名"`
  11. Password string
  12. LastUpdatedPasswordTime string `json:"-"`
  13. Enabled int `description:"1:有效,0:禁用"`
  14. Email string `description:"系统用户邮箱"`
  15. LastLoginTime string
  16. CreatedTime time.Time
  17. LastUpdatedTime string
  18. Role string `description:"系统用户角色"`
  19. Mobile string `description:"手机号"`
  20. RoleType int `description:"角色类型:1需要录入指标,0:不需要"`
  21. RoleId int `description:"角色id"`
  22. RoleName string `description:"角色名称"`
  23. RoleTypeCode string `description:"角色编码"`
  24. DepartmentId int `description:"部门id"`
  25. DepartmentName string `json:"-" description:"部门名称"`
  26. TeamId int `description:"三级id"`
  27. GroupId int `description:"分组id"`
  28. GroupName string `json:"-" description:"分组名称"`
  29. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
  30. Position string `description:"职位"`
  31. DepartmentGroup string `description:"部门分组"`
  32. LabelVal int `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
  33. ResearchGroupName string `description:"研究方向分组名称"`
  34. Province string `description:"省"`
  35. ProvinceCode string `description:"省编码"`
  36. City string `description:"市"`
  37. CityCode string `description:"市编码"`
  38. }
  39. type AdminRespItem struct {
  40. AdminId int `description:"系统用户id"`
  41. AdminName string `description:"系统用户名称"`
  42. RealName string `description:"系统用户姓名"`
  43. Password string
  44. LastUpdatedPasswordTime string `json:"-"`
  45. Enabled int `description:"1:有效,0:禁用"`
  46. Email string `description:"系统用户邮箱"`
  47. LastLoginTime string
  48. CreatedTime time.Time
  49. LastUpdatedTime string
  50. Role string `description:"系统用户角色"`
  51. Mobile string `description:"手机号"`
  52. RoleType int `description:"角色类型:1需要录入指标,0:不需要"`
  53. RoleId int `description:"角色id"`
  54. RoleName string `description:"角色名称"`
  55. RoleTypeCode string `description:"角色编码"`
  56. DepartmentId int `description:"部门id"`
  57. DepartmentName string `json:"-" description:"部门名称"`
  58. parentId int `description:"父级id"`
  59. GroupId int `description:"分组id"`
  60. GroupName string `json:"-" description:"分组名称"`
  61. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
  62. Position string `description:"职位"`
  63. DepartmentGroup string `description:"部门分组"`
  64. LabelVal int `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
  65. }
  66. type SysuserListResp struct {
  67. List []*AdminItem
  68. Paging *paging.PagingItem `description:"分页数据"`
  69. }
  70. type SysuserAddReq struct {
  71. AdminName string `description:"系统用户名称"`
  72. AdminAvatar string `description:"用户头像"`
  73. RealName string `description:"系统用户姓名"`
  74. Password string `description:"密码"`
  75. Mobile string `description:"手机号"`
  76. RoleId int `description:"角色id"`
  77. DepartmentId int `description:"部门id"`
  78. GroupId int `description:"分组id"`
  79. TeamId int `description:"小组id"`
  80. //Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
  81. Position string `description:"职位"`
  82. ResearchGroupIds string `description:"研究方向分组IDs"`
  83. Province string `description:"省"`
  84. ProvinceCode string `description:"省编码"`
  85. City string `description:"市"`
  86. CityCode string `description:"市编码"`
  87. }
  88. type SysuserEditReq struct {
  89. AdminId int `description:"系统用户id"`
  90. AdminName string `description:"系统用户名称"`
  91. AdminAvatar string `description:"用户头像"`
  92. RealName string `description:"系统用户姓名"`
  93. Password string `description:"密码"`
  94. Mobile string `description:"手机号"`
  95. RoleId int `description:"角色id"`
  96. DepartmentId int `description:"部门id"`
  97. GroupId int `description:"分组id"`
  98. TeamId int `description:"小组id"`
  99. Enabled int `description:"1:有效,0:禁用"`
  100. //Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
  101. Position string `description:"职位"`
  102. ResearchGroupIds string `description:"研究方向分组IDs"`
  103. Province string `description:"省"`
  104. ProvinceCode string `description:"省编码"`
  105. City string `description:"市"`
  106. CityCode string `description:"市编码"`
  107. }
  108. // 用户状态编辑
  109. type SysuserEditEnabledReq struct {
  110. AdminId int `description:"系统用户id"`
  111. Enabled int `description:"1:有效,0:禁用"`
  112. }
  113. type SysuserDeleteReq struct {
  114. AdminId int `description:"系统用户id"`
  115. }
  116. func GetSysUserItems(condition string, pars []interface{}) (items []*AdminItem, err error) {
  117. o := orm.NewOrm()
  118. sql := `SELECT * FROM admin WHERE 1=1 `
  119. if condition != "" {
  120. sql += condition
  121. }
  122. sql += `ORDER BY last_updated_time DESC `
  123. _, err = o.Raw(sql, pars).QueryRows(&items)
  124. return
  125. }
  126. type OpenIdList struct {
  127. OpenId string
  128. AdminId int
  129. }
  130. // ResearcherAdminAndUser 研究员admin信息及wx_user信息
  131. type ResearcherAdminAndUser struct {
  132. UserId int `description:"用户ID"`
  133. UserName string `description:"用户名称"`
  134. AdminId int `description:"管理员ID"`
  135. AdminName string `description:"管理员姓名"`
  136. OpenId string `description:"openid"`
  137. }
  138. func GetSysUserItemsOrderByCreated(condition string, pars []interface{}) (items []*AdminItem, err error) {
  139. o := orm.NewOrm()
  140. sql := `SELECT * FROM admin WHERE 1=1 `
  141. if condition != "" {
  142. sql += condition
  143. }
  144. sql += ` ORDER BY created_time DESC `
  145. _, err = o.Raw(sql, pars).QueryRows(&items)
  146. return
  147. }
  148. func GetAdminList() (items []*AdminItem, err error) {
  149. sql := `SELECT * FROM admin`
  150. o := orm.NewOrm()
  151. _, err = o.Raw(sql).QueryRows(&items)
  152. return
  153. }