admin.go 1.7 KB

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