|
@@ -6,9 +6,10 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserListReq) (*[]md.UserInfo, int64, error) { |
|
|
func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserListReq) (*[]md.UserInfo, int64, error) { |
|
|
var users []md.UserInfo |
|
|
|
|
|
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`" + |
|
|
|
|
|
"WHERE a.parent_uid = b.id AND user_tag_records.uid = a.id") |
|
|
|
|
|
|
|
|
users := make([]md.UserInfo, 0) |
|
|
|
|
|
session := engine.Table("user").Alias("a"). |
|
|
|
|
|
Join("LEFT OUTER", []string{"user", "b"}, "a.parent_uid = b.id"). |
|
|
|
|
|
Join("LEFT OUTER", "user_tag_records", "user_tag_records.uid = a.id") |
|
|
if req.ID != 0 { |
|
|
if req.ID != 0 { |
|
|
session = session.Where("a.id = ?", req.ID) |
|
|
session = session.Where("a.id = ?", req.ID) |
|
|
} |
|
|
} |
|
@@ -60,7 +61,7 @@ func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserLi |
|
|
if req.LoginBefore != "" && req.LoginAfter != "" { |
|
|
if req.LoginBefore != "" && req.LoginAfter != "" { |
|
|
session = session.Where("a.update_at > ? and a.update_at < ?", req.LoginBefore, req.LoginAfter) |
|
|
session = session.Where("a.update_at > ? and a.update_at < ?", req.LoginBefore, req.LoginAfter) |
|
|
} |
|
|
} |
|
|
total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&users) |
|
|
|
|
|
|
|
|
total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).Asc("a.id").FindAndCount(&users) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, 0, err |
|
|
return nil, 0, err |
|
|
} |
|
|
} |
|
|