蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_user_management.go 2.3 KiB

6 days ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package svc
  2. import (
  3. md "applet/app/md/institutional_management/member_center"
  4. "xorm.io/xorm"
  5. )
  6. func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserListReq) (*[]md.UserInfo, int64, error) {
  7. var users []md.UserInfo
  8. session := engine.SQL("SELECT a.*, user_tag_records.tag_id AS tag_id, b.phone AS parent_phone, b.system_invite_code AS parent_system_invite_code, b.custom_invite_code AS parent_custom_invite_code FROM `user` AS a, `user` AS b, `user_tag_records`" +
  9. "WHERE a.parent_uid = b.id AND user_tag_records.uid = a.id")
  10. if req.ID != 0 {
  11. session = session.Where("a.id = ?", req.ID)
  12. }
  13. if req.Nickname != "" {
  14. session = session.Where("a.nickname = ?", req.Nickname)
  15. }
  16. if req.RecommendID != 0 {
  17. session = session.Where("a.parent_uid = ?", req.RecommendID)
  18. }
  19. if req.Tag != 0 {
  20. session = session.Where("a.tag_id = ?", req.Tag)
  21. }
  22. if req.Phone != "" {
  23. session = session.Where("a.phone = ?", req.Phone)
  24. }
  25. if req.InviteCode != "" {
  26. session = session.Where("a.system_invite_code = ? or a.custom_invite_code = ?", req.InviteCode, req.InviteCode)
  27. }
  28. if req.ParentPhone != "" {
  29. session = session.Where("b.phone= ?", req.ParentPhone)
  30. }
  31. if req.ParentInviteCode != "" {
  32. session = session.Where("b.system_invite_code = ? or b.custom_invite_code = ?", req.ParentInviteCode, req.ParentInviteCode)
  33. }
  34. if req.Sex != 0 {
  35. session = session.Where("a.sex = ?")
  36. }
  37. if req.UnionId != "" {
  38. session = session.Where("a.union_id = ?", req.UnionId)
  39. }
  40. if req.Level != 0 {
  41. session = session.Where("a.level = ?", req.Level)
  42. }
  43. if req.RegisterType != 0 {
  44. session = session.Where("a.register_type = ?", req.RegisterType)
  45. }
  46. if req.State != 0 {
  47. session = session.Where("a.state = ?", req.State)
  48. }
  49. if req.IsRealName != 0 {
  50. session = session.Where("a.is_real_name = ?", req.IsRealName)
  51. }
  52. if req.Memo != "" {
  53. session = session.Where("a.memo = ?", req.Memo)
  54. }
  55. if req.RegisterBefore != "" && req.RegisterAfter != "" {
  56. session = session.Where("a.create_at > ? and a.create_at < ?", req.RegisterBefore, req.RegisterAfter)
  57. }
  58. if req.LoginBefore != "" && req.LoginAfter != "" {
  59. session = session.Where("a.update_at > ? and a.update_at < ?", req.LoginBefore, req.LoginAfter)
  60. }
  61. total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&users)
  62. if err != nil {
  63. return nil, 0, err
  64. }
  65. return &users, total, nil
  66. }