蛋蛋星球 后台端
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.
 
 
 
 
 

70 lines
2.2 KiB

  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. users := make([]md.UserInfo, 0)
  8. session := engine.Table("user").Alias("a").
  9. Join("LEFT OUTER", []string{"user", "b"}, "a.parent_uid = b.id").
  10. Join("LEFT OUTER", "user_tag_records", "user_tag_records.uid = a.id")
  11. if req.ID != 0 {
  12. session = session.Where("a.id = ?", req.ID)
  13. }
  14. if req.Nickname != "" {
  15. session = session.Where("a.nickname = ?", req.Nickname)
  16. }
  17. if req.RecommendID != 0 {
  18. session = session.Where("a.parent_uid = ?", req.RecommendID)
  19. }
  20. if req.Tag != 0 {
  21. session = session.Where("a.tag_id = ?", req.Tag)
  22. }
  23. if req.Phone != "" {
  24. session = session.Where("a.phone = ?", req.Phone)
  25. }
  26. if req.InviteCode != "" {
  27. session = session.Where("a.system_invite_code = ? or a.custom_invite_code = ?", req.InviteCode, req.InviteCode)
  28. }
  29. if req.ParentPhone != "" {
  30. session = session.Where("b.phone= ?", req.ParentPhone)
  31. }
  32. if req.ParentInviteCode != "" {
  33. session = session.Where("b.system_invite_code = ? or b.custom_invite_code = ?", req.ParentInviteCode, req.ParentInviteCode)
  34. }
  35. if req.Sex != 0 {
  36. session = session.Where("a.sex = ?")
  37. }
  38. if req.UnionId != "" {
  39. session = session.Where("a.union_id = ?", req.UnionId)
  40. }
  41. if req.Level != 0 {
  42. session = session.Where("a.level = ?", req.Level)
  43. }
  44. if req.RegisterType != 0 {
  45. session = session.Where("a.register_type = ?", req.RegisterType)
  46. }
  47. if req.State != 0 {
  48. session = session.Where("a.state = ?", req.State)
  49. }
  50. if req.IsRealName != 0 {
  51. session = session.Where("a.is_real_name = ?", req.IsRealName)
  52. }
  53. if req.Memo != "" {
  54. session = session.Where("a.memo = ?", req.Memo)
  55. }
  56. if req.RegisterBefore != "" && req.RegisterAfter != "" {
  57. session = session.Where("a.create_at > ? and a.create_at < ?", req.RegisterBefore, req.RegisterAfter)
  58. }
  59. if req.LoginBefore != "" && req.LoginAfter != "" {
  60. session = session.Where("a.update_at > ? and a.update_at < ?", req.LoginBefore, req.LoginAfter)
  61. }
  62. total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).Asc("a.id").FindAndCount(&users)
  63. if err != nil {
  64. return nil, 0, err
  65. }
  66. return &users, total, nil
  67. }