diff --git a/services/sale/run.toml b/services/sale/run.toml index 26ee240..6f83ec6 100644 --- a/services/sale/run.toml +++ b/services/sale/run.toml @@ -2,7 +2,7 @@ login_out_time=43200 #api接口超时时间分 login_refresh_out_time=83200 name = "sale-service" - listenOn = "0.0.0.0:10700" + listenOn = "0.0.0.0:10300" mode = "dev" [log] path = "logs" @@ -53,5 +53,7 @@ [encrypt] data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a" + [services] - chore = "chore-service" \ No newline at end of file + chore = "chore-service" + user = "user-service" \ No newline at end of file diff --git a/services/user/internal/dao/const.go b/services/user/internal/dao/const.go index 9f13c13..242206e 100644 --- a/services/user/internal/dao/const.go +++ b/services/user/internal/dao/const.go @@ -27,5 +27,9 @@ const ( SubjectTypeStore = "store" SubjectTypeUser = "user" + GenderMale uint8 = 1 + GenderFemale uint8 = 2 + GenderUnknown uint8 = 3 + ExtraJsonEmpty = "{}" ) diff --git a/services/user/internal/dao/user.go b/services/user/internal/dao/user.go index 5b724b3..3c28d64 100644 --- a/services/user/internal/dao/user.go +++ b/services/user/internal/dao/user.go @@ -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"` diff --git a/services/user/internal/logic/authHelper.go b/services/user/internal/logic/authHelper.go index fc4e244..96a6175 100644 --- a/services/user/internal/logic/authHelper.go +++ b/services/user/internal/logic/authHelper.go @@ -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 } diff --git a/services/user/internal/logic/userItemsLogic.go b/services/user/internal/logic/userItemsLogic.go index 60c2d43..572917f 100644 --- a/services/user/internal/logic/userItemsLogic.go +++ b/services/user/internal/logic/userItemsLogic.go @@ -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,