Selaa lähdekoodia

update

master
dengbiao 1 viikko sitten
vanhempi
commit
cff192c471
2 muutettua tiedostoa jossa 27 lisäystä ja 15 poistoa
  1. +6
    -6
      app/hdl/member_center/hdl_user_management.go
  2. +21
    -9
      app/svc/member_center/svc_user_management.go

+ 6
- 6
app/hdl/member_center/hdl_user_management.go Näytä tiedosto

@@ -75,13 +75,13 @@ func UserManagementGetUserList(c *gin.Context) {
},
}

users, total, err3 := svc.UserManagementGetUsers(db.Db, req)
users, total, err3 := svc.UserManagementGetUsers(req)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}
userIDs := make([]int64, len(*users))
for i, user := range *users {
userIDs := make([]int64, len(users))
for i, user := range users {
userIDs[i] = user.Id
}

@@ -102,9 +102,9 @@ func UserManagementGetUserList(c *gin.Context) {
return
}

userMap := make(map[int64]int, len(*users))
list := make([]md.UserManagementGetUserListNode, len(*users))
for i, user := range *users {
userMap := make(map[int64]int, len(users))
list := make([]md.UserManagementGetUserListNode, len(users))
for i, user := range users {
list[i] = md.UserManagementGetUserListNode{
ID: user.Id,
Sex: user.Sex,


+ 21
- 9
app/svc/member_center/svc_user_management.go Näytä tiedosto

@@ -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()


Ladataan…
Peruuta
Tallenna