feat: backuser list
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 1s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 21s
CI / task (push) Successful in 0s
CI / user (push) Successful in 18s
CI / wecom (push) Successful in 0s
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 1s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 21s
CI / task (push) Successful in 0s
CI / user (push) Successful in 18s
CI / wecom (push) Successful in 0s
This commit is contained in:
@@ -27,5 +27,9 @@ const (
|
||||
SubjectTypeStore = "store"
|
||||
SubjectTypeUser = "user"
|
||||
|
||||
GenderMale uint8 = 1
|
||||
GenderFemale uint8 = 2
|
||||
GenderUnknown uint8 = 3
|
||||
|
||||
ExtraJsonEmpty = "{}"
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ type UserCreate struct {
|
||||
type UserListItem struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
HeadPortrait string `json:"head_portrait"`
|
||||
Avatar string `json:"avatar"`
|
||||
Mobile string `json:"mobile"`
|
||||
OriginMobile string `json:"origin_mobile"`
|
||||
Gender uint8 `json:"gender"`
|
||||
|
||||
@@ -133,7 +133,7 @@ func resolveOrCreateWechatUser(ctx context.Context, db *gorm.DB, openid, unionid
|
||||
if userId < utils.NumberOne {
|
||||
userModel := model.UserModel{}.Init()
|
||||
userModel.Base = userModel.Base.WithTX(tx)
|
||||
add := dao.UserCreate{Status: dao.StatusEnabled}
|
||||
add := dao.UserCreate{Status: dao.StatusEnabled, Gender: dao.GenderUnknown}
|
||||
if err := userModel.Create(&add); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
@@ -49,10 +50,23 @@ func (l *UserItemsLogic) UserItems(in *user.UserItemsReq) (*user.Response, error
|
||||
size = modelbase.DefaultSize
|
||||
}
|
||||
|
||||
prefix := modelbase.Prefix()
|
||||
existsSQL := fmt.Sprintf(`EXISTS (
|
||||
SELECT 1 FROM %suser_client uc
|
||||
INNER JOIN %sclient c ON c.code = uc.client_code
|
||||
WHERE uc.user_id = %susers.id
|
||||
AND uc.status = %d
|
||||
AND c.status = %d
|
||||
AND c.subject_type = ?
|
||||
)`, prefix, prefix, prefix, dao.StatusEnabled, dao.StatusEnabled)
|
||||
|
||||
params := modelbase.Params{
|
||||
Order: "id DESC",
|
||||
Page: page,
|
||||
Size: size,
|
||||
Other: map[string]string{
|
||||
existsSQL: dao.SubjectTypeUser,
|
||||
},
|
||||
}
|
||||
if v.Mobile != utils.StringEmpty {
|
||||
phone := utils.GetSearchPhone(v.Mobile)
|
||||
@@ -73,15 +87,16 @@ func (l *UserItemsLogic) UserItems(in *user.UserItemsReq) (*user.Response, error
|
||||
|
||||
items := make([]dao.UserListItem, 0, len(list))
|
||||
for _, row := range list {
|
||||
headPortrait, _ := utils.BuildImageURL(row.Avatar).(string)
|
||||
mobile := row.Mobile
|
||||
if plain, dErr := utils.DecryptPhone(row.Mobile); dErr == nil {
|
||||
mobile = utils.DecryptPhoneReplace(plain)
|
||||
if len(row.Mobile) >= 72 {
|
||||
if plain, dErr := utils.DecryptPhone(row.Mobile); dErr == nil {
|
||||
mobile = utils.DecryptPhoneReplace(plain)
|
||||
}
|
||||
}
|
||||
items = append(items, dao.UserListItem{
|
||||
Id: row.Id,
|
||||
Name: row.Name,
|
||||
HeadPortrait: headPortrait,
|
||||
Avatar: row.Avatar,
|
||||
Mobile: mobile,
|
||||
OriginMobile: row.Mobile,
|
||||
Gender: row.Gender,
|
||||
|
||||
Reference in New Issue
Block a user