sys_user.go 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package eta_trial
  2. /*
  3. type ETATrialAdmin struct {
  4. AdminId int `orm:"column(admin_id);pk" description:"系统用户id"`
  5. AdminName string `description:"系统用户名称"`
  6. AdminAvatar string `description:"用户头像"`
  7. RealName string `description:"系统用户姓名"`
  8. Password string `json:"-"`
  9. LastUpdatedPasswordTime string `json:"-"`
  10. Enabled int
  11. Email string `description:"系统用户邮箱"`
  12. LastLoginTime string
  13. CreatedTime time.Time
  14. LastUpdatedTime string
  15. Role string `description:"系统用户角色"`
  16. Mobile string `description:"手机号"`
  17. RoleType int `description:"角色类型:1需要录入指标,0:不需要"`
  18. RoleId int `description:"角色ID"`
  19. RoleName string `description:"角色名称"`
  20. RoleTypeCode string `description:"角色类型编码"`
  21. DepartmentId int `description:"部门id"`
  22. DepartmentName string `description:"部门名称"`
  23. GroupId int `description:"分组id"`
  24. GroupName string `description:"分组名称"`
  25. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,3:超级管理员,4:ficc销售组长"`
  26. Position string `description:"职位"`
  27. DisableTime time.Time `description:"禁用时间"`
  28. ChartPermission int8 `description:"图表权限id"`
  29. OpenId string `description:"弘则部门公众号的openid"`
  30. UnionId string `description:"微信公众平台唯一标识"`
  31. EdbPermission int8 `description:"指标库操作权限,0:只能操作 自己的,1:所有指标可操作"`
  32. MysteelChemicalPermission int8 `description:"钢联化工指标操作权限,0:只能操作 自己的,1:所有指标可操作"`
  33. }
  34. func (item *ETATrialAdmin) Update(cols []string) (err error) {
  35. o := orm.NewOrm()
  36. _, err = o.Update(item, cols...)
  37. return
  38. }
  39. func AddAdmin(item *ETATrialAdmin) (lastId int, err error) {
  40. o := orm.NewOrmUsingDB("weekly_trial")
  41. sql := `INSERT INTO admin ( admin_name, real_name, password, last_updated_password_time, enabled, last_login_time, created_time, last_updated_time, mobile, role_id, role_name, role_type_code, department_id, department_name, role, position) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )`
  42. _, err = o.Raw(sql, item.AdminName, item.RealName, item.Password, item.LastUpdatedPasswordTime, item.Enabled, item.LastLoginTime, item.CreatedTime, item.LastUpdatedTime, item.Mobile, item.RoleId, item.RoleName, item.RoleTypeCode, item.DepartmentId, item.DepartmentName, item.Role, item.Position).Exec()
  43. sql = `SELECT MAX(admin_id) FROM admin`
  44. err = o.Raw(sql).QueryRow(&lastId)
  45. return
  46. }
  47. func GetSysUserByRoleAndDepartment(role, dep string) (item *ETATrialAdmin, err error) {
  48. sql := `SELECT * FROM admin WHERE role_name=? AND department_name=? LIMIT 1`
  49. o := orm.NewOrmUsingDB("weekly_trial")
  50. err = o.Raw(sql, role, dep).QueryRow(&item)
  51. return
  52. }
  53. // GetSysAdminCountByMobile 查询系统中是否存在该手机号(如果有传入用户id,那么排除该用户)
  54. func GetSysAdminCountByMobile(mobile string, adminId int) (count int, err error) {
  55. sql := `SELECT COUNT(1) AS count FROM admin WHERE mobile=? `
  56. if adminId > 0 {
  57. sql += ` AND admin_id != ` + fmt.Sprint(adminId)
  58. }
  59. o := orm.NewOrmUsingDB("weekly_trial")
  60. err = o.Raw(sql, mobile).QueryRow(&count)
  61. return
  62. }
  63. func (item *ETATrialAdmin) TableName() string {
  64. return "admin"
  65. }
  66. func UpdateAdminEnable(mobile string) (err error) {
  67. sql := `UPDATE admin SET enabled=1 WHERE mobile=? `
  68. o := orm.NewOrmUsingDB("weekly_trial")
  69. _, err = o.Raw(sql, mobile).Exec()
  70. return
  71. }*/