This commit is contained in:
桀尼龟 2025-02-22 19:39:08 +08:00
parent af363868e8
commit fc2af96f89

View File

@ -627,7 +627,7 @@ func (a *AccountProvider) Info(ctx context.Context, in *account.InfoRequest) (*a
func (a *AccountProvider) UserList(ctx context.Context, in *account.UserListRequest) (*account.UserListResponse, error) {
var count int64
var users []*model.User
modelObj := model.DB.Model(&model.User{}).Preload("RealName")
modelObj := model.DB.Model(&model.User{}).Joins("RealName")
if in.Domain != "" {
modelObj.Where("domain = ? ", in.Domain)
}
@ -640,22 +640,22 @@ func (a *AccountProvider) UserList(ctx context.Context, in *account.UserListRequ
modelObj.Where("status != 1 ") //已实名
}
if in.Name != "" {
modelObj.Where("real_name.name like ? ", "%"+in.Name+"%")
modelObj.Where("RealName.name like ? ", "%"+in.Name+"%")
}
if in.DocumentType != 0 {
modelObj.Where("real_name.document_type = ? ", in.DocumentType)
modelObj.Where("RealName.document_type = ? ", in.DocumentType)
}
if in.AuditStatus != 0 {
modelObj.Where("status = ? ", in.AuditStatus)
}
if in.Sex != 0 {
modelObj.Where("real_name.sex = ? ", in.Sex)
modelObj.Where("RealName.sex = ?", in.Sex)
}
modelObj.Count(&count)
if in.Page > 0 && in.PageSize > 0 {
modelObj.Limit(int(in.PageSize)).Offset(page.GetOffset(in.Page, in.PageSize))
}
modelObj.Find(&users)
modelObj.Preload("RealName").Find(&users)
response := &account.UserListResponse{}