admin.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hongze_task/utils"
  5. )
  6. type Admin struct {
  7. AdminId int
  8. AdminName string `description:"系统用户名称"`
  9. RealName string `description:"系统用户姓名"`
  10. Password string `description:"密码"`
  11. Mobile string `description:"手机号"`
  12. RoleId int `description:"角色id"`
  13. RoleName string `description:"角色名称"`
  14. RoleTypeCode string `description:"角色编码"`
  15. DepartmentId int `description:"部门id"`
  16. GroupId int `description:"分组id"`
  17. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
  18. Position string `description:"职位"`
  19. OpenId string `description:"弘则部门公众号的openid"`
  20. }
  21. func GetAdminByAdminId(adminId int) (item *Admin, err error) {
  22. sql := `SELECT * FROM admin WHERE admin_id=? `
  23. err = orm.NewOrm().Raw(sql, adminId).QueryRow(&item)
  24. return
  25. }
  26. func GetAdminByAdminIds(adminIds []int) (items []*Admin, err error) {
  27. sql := `SELECT * FROM admin WHERE admin_id in (` + utils.GetOrmInReplace(len(adminIds)) + `) `
  28. _, err = orm.NewOrm().Raw(sql, adminIds).QueryRows(&items)
  29. return
  30. }
  31. type AdminView struct {
  32. AdminId int
  33. AdminName string `description:"系统用户名称"`
  34. RealName string `description:"系统用户姓名"`
  35. Password string `description:"密码"`
  36. Mobile string `description:"手机号"`
  37. RoleId int `description:"角色id"`
  38. RoleName string `description:"角色名称"`
  39. RoleTypeCode string `description:"角色编码"`
  40. DepartmentId int `description:"部门id"`
  41. GroupId int `description:"分组id"`
  42. GroupName string `description:"分组名称"`
  43. Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
  44. Position string `description:"职位"`
  45. }
  46. func GetAdminList() (list []*AdminView, err error) {
  47. sql := `SELECT * FROM admin `
  48. _, err = orm.NewOrm().Raw(sql).QueryRows(&list)
  49. return
  50. }