Skip to content

Commit

Permalink
fix: user list return username
Browse files Browse the repository at this point in the history
  • Loading branch information
tangtaoit committed Nov 1, 2023
1 parent 4cf0271 commit 4ef4e64
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/user/db_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func (m *managerDB) queryUserListWithPage(pageSize, page uint64, onelineStatus i
// return users, err

var users []*managerUserModel
selectStm := m.session.Select("user.uid,user.name,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid,max(user_online.online) online").From("user").LeftJoin("user_online", "user.uid=user_online.uid")
selectStm := m.session.Select("user.uid,user.name,user.username,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid,max(user_online.online) online").From("user").LeftJoin("user_online", "user.uid=user_online.uid")
if onelineStatus != -1 {
selectStm = selectStm.Where("user_online.online=?", onelineStatus)
}
selectStm = selectStm.GroupBy("user.uid,user.name,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid")
selectStm = selectStm.GroupBy("user.uid,user.name,user.username,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid")

// select from user left join user_online on user.uid=user_online.uid where user_online.online=1 group by user.uid,user.name,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at limit 100
_, err := selectStm.Offset((page-1)*pageSize).Limit(pageSize).OrderDir("user.created_at", false).Load(&users)
Expand All @@ -48,11 +48,11 @@ func (m *managerDB) queryUserListWithPage(pageSize, page uint64, onelineStatus i
// onelineStatus 在线状态 -1 为所有 0. 离线 1. 在线
func (m *managerDB) queryUserListWithPageAndKeyword(keyword string, onelineStatus int, pageSize, page uint64) ([]*managerUserModel, error) {
var users []*managerUserModel
selectStm := m.session.Select("user.uid,user.name,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid,max(user_online.online) online").From("user").LeftJoin("user_online", "user.uid=user_online.uid").Where("user.name like ? or user.uid like ? or user.phone like ? or user.short_no like ?", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
selectStm := m.session.Select("user.uid,user.name,user.username,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid,max(user_online.online) online").From("user").LeftJoin("user_online", "user.uid=user_online.uid").Where("user.name like ? or user.uid like ? or user.phone like ? or user.short_no like ?", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
if onelineStatus != -1 {
selectStm = selectStm.Where("user_online.online=?", onelineStatus)
}
selectStm = selectStm.GroupBy("user.uid,user.name,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid")
selectStm = selectStm.GroupBy("user.uid,user.name,,user.username,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at,user.gitee_uid,user.github_uid,user.wx_openid")

// select from user left join user_online on user.uid=user_online.uid where user_online.online=1 group by user.uid,user.name,user.status,user.phone,user.short_no,user.sex,user.is_destroy,user.created_at limit 100
_, err := selectStm.Offset((page-1)*pageSize).Limit(pageSize).OrderDir("user.created_at", false).Load(&users)
Expand Down

0 comments on commit 4ef4e64

Please sign in to comment.