|
|
@@ -6,14 +6,31 @@ import ( |
|
|
|
"applet/app/utils" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"fmt" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserListReq) (*[]md.UserInfo, int64, error) { |
|
|
|
users := make([]md.UserInfo, 0) |
|
|
|
session := engine.Table("user").Alias("a").Distinct("a.id"). |
|
|
|
func UserManagementGetUsers(req *md.UserManagementGetUserListReq) ([]*md.UserInfo, int64, error) { |
|
|
|
users := make([]*md.UserInfo, 0) |
|
|
|
pageSess := userManagementGetUsersBindQuery(db.Db, req) |
|
|
|
countSess := userManagementGetUsersBindQuery(db.Db, req) |
|
|
|
total, err := countSess.Distinct("a.id").Count(&md.UserInfo{}) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err.Error()) |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
|
|
|
|
err = pageSess.Distinct("a.*").Limit(req.Limit, (req.Page-1)*req.Limit).Asc("a.id").Find(&users) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
return users, total, nil |
|
|
|
} |
|
|
|
|
|
|
|
func userManagementGetUsersBindQuery(engine *xorm.Engine, req *md.UserManagementGetUserListReq) *xorm.Session { |
|
|
|
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 { |
|
|
@@ -67,13 +84,8 @@ func UserManagementGetUsers(engine *xorm.Engine, req *md.UserManagementGetUserLi |
|
|
|
if 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).Asc("a.id").FindAndCount(&users) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
return &users, total, nil |
|
|
|
return session |
|
|
|
} |
|
|
|
|
|
|
|
func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpdateUserInfoReq) (int64, error) { |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|