admin.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type Admin struct {
  7. AdminId int `orm:"column(admin_id);pk" description:"系统用户id"`
  8. AdminName string `description:"系统用户名称"`
  9. AdminAvatar string `description:"用户头像"`
  10. RealName string `description:"系统用户姓名"`
  11. Password string `json:"-"`
  12. LastUpdatedPasswordTime string `json:"-"`
  13. Enabled int
  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 `description:"部门名称"`
  26. GroupId int `description:"分组id"`
  27. GroupName string `description:"分组名称"`
  28. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,3:超级管理员,4:ficc销售组长"`
  29. Position string `description:"职位"`
  30. DisableTime time.Time `description:"禁用时间"`
  31. ChartPermission int8 `description:"图表权限id"`
  32. OpenId string `description:"弘则部门公众号的openid"`
  33. UnionId string `description:"微信公众平台唯一标识"`
  34. EdbPermission int8 `description:"指标库操作权限,0:只能操作 自己的,1:所有指标可操作"`
  35. MysteelChemicalPermission int8 `description:"钢联化工指标操作权限,0:只能操作 自己的,1:所有指标可操作"`
  36. PredictEdbPermission int8 `description:"预测指标库操作权限,0:只能操作 自己的,1:所有预测指标可操作"`
  37. Province string `description:"省"`
  38. ProvinceCode string `description:"省编码"`
  39. City string `description:"市"`
  40. CityCode string `description:"市编码"`
  41. EmployeeId string `description:"员工工号(钉钉/每刻报销)"`
  42. TelAreaCode string `description:"手机区号"`
  43. IsLdap int `description:"是否为域用户:0-系统账户;1-域用户"`
  44. }
  45. // GetSysAdminList 获取系统用户列表
  46. func GetSysAdminList(cond string, pars []interface{}) (items []*Admin, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT * FROM admin WHERE 1=1 `
  49. if cond != "" {
  50. sql += cond
  51. }
  52. _, err = o.Raw(sql, pars).QueryRows(&items)
  53. return
  54. }
  55. func GetSysAdminCount(adminName string) (count int, err error) {
  56. sql := `SELECT COUNT(1) AS count FROM admin WHERE admin_name=? `
  57. o := orm.NewOrm()
  58. err = o.Raw(sql, adminName).QueryRow(&count)
  59. return
  60. }
  61. func AddAdmin(item *Admin) (err error) {
  62. o := orm.NewOrm()
  63. adminId, err := o.Insert(item)
  64. item.AdminId = int(adminId)
  65. return
  66. }