作者 tangxuhui
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
  5 +)
  6 +
  7 +type UserBaseDto struct {
  8 + // 用户基础数据id
  9 + UserBaseId int64 `json:"userBaseId,omitempty"`
  10 + // 用户信息
  11 + UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
  12 + // 手机号码
  13 + //Account string `json:"phone,omitempty"`
  14 + // 密码
  15 + //Password string `json:"password,omitempty"`
  16 + // IM信息
  17 + Im *domain.Im `json:"im,omitempty"`
  18 + // 关联的用户 (冗余)
  19 + //RelatedUsers []int64 `json:"relatedUsers,omitempty"`
  20 + // 账号状态 1:正常 2.禁用 3:注销
  21 + //Status int `json:"status,omitempty"`
  22 + // 创建时间
  23 + //CreatedAt time.Time `json:"createdAt,omitempty"`
  24 + // 更新时间
  25 + //UpdatedAt time.Time `json:"updatedAt,omitempty"`
  26 +}
  27 +
  28 +func (u *UserBaseDto) LoadDto(ub *domain.UserBase) {
  29 + u.UserBaseId = ub.UserBaseId
  30 + u.UserInfo = ub.UserInfo
  31 + u.Im = ub.Im
  32 +}
@@ -9,8 +9,7 @@ import ( @@ -9,8 +9,7 @@ import (
9 ) 9 )
10 10
11 type UserInfoQuery struct { 11 type UserInfoQuery struct {
12 - // 用户Id 用户唯一标识  
13 - UserId int64 `cname:"用户Id 用户唯一标识" json:"userId"` 12 + Account string `cname:"账号" json:"account" valid:"Required"`
14 } 13 }
15 14
16 func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) { 15 func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) {
@@ -3,6 +3,7 @@ package service @@ -3,6 +3,7 @@ package service
3 import ( 3 import (
4 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/command" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/dto"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/query" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/query"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
@@ -317,10 +318,18 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in @@ -317,10 +318,18 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in
317 defer func() { 318 defer func() {
318 transactionContext.RollbackTransaction() 319 transactionContext.RollbackTransaction()
319 }() 320 }()
  321 +
  322 + userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0)
  323 + userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account})
  324 + if err != nil {
  325 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  326 + }
  327 + ubDto := &dto.UserBaseDto{}
  328 + ubDto.LoadDto(userBase)
320 if err := transactionContext.CommitTransaction(); err != nil { 329 if err := transactionContext.CommitTransaction(); err != nil {
321 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 330 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
322 } 331 }
323 - return nil, nil 332 + return ubDto, nil
324 } 333 }
325 334
326 func NewAuthService(options map[string]interface{}) *AuthService { 335 func NewAuthService(options map[string]interface{}) *AuthService {
@@ -202,6 +202,7 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int @@ -202,6 +202,7 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int
202 } 202 }
203 query.SetWhereByQueryOption("user_base_id=?", "userBaseId") 203 query.SetWhereByQueryOption("user_base_id=?", "userBaseId")
204 query.SetWhereByQueryOption("(user_type & ?)>0", "userType") 204 query.SetWhereByQueryOption("(user_type & ?)>0", "userType")
  205 + query.SetWhereByQueryOption("enable_status=?", "enableStatus")
205 query.SetWhereByQueryOption(fmt.Sprintf(`user_role @> '[{"roleId":%v}]'`, queryOptions["roleId"]), "roleId") 206 query.SetWhereByQueryOption(fmt.Sprintf(`user_role @> '[{"roleId":%v}]'`, queryOptions["roleId"]), "roleId")
206 207
207 if v, ok := queryOptions["depName"]; ok && len(v.(string)) > 0 { 208 if v, ok := queryOptions["depName"]; ok && len(v.(string)) > 0 {
@@ -62,6 +62,7 @@ func (controller *AuthController) DestroyAccount() { @@ -62,6 +62,7 @@ func (controller *AuthController) DestroyAccount() {
62 func (controller *AuthController) UserInfo() { 62 func (controller *AuthController) UserInfo() {
63 authService := service.NewAuthService(nil) 63 authService := service.NewAuthService(nil)
64 userInfoQuery := &query.UserInfoQuery{} 64 userInfoQuery := &query.UserInfoQuery{}
  65 + controller.Unmarshal(userInfoQuery)
65 data, err := authService.UserInfo(userInfoQuery) 66 data, err := authService.UserInfo(userInfoQuery)
66 controller.Response(data, err) 67 controller.Response(data, err)
67 } 68 }
@@ -13,4 +13,5 @@ func init() { @@ -13,4 +13,5 @@ func init() {
13 web.Router("/auth/reset-phone", &controllers.AuthController{}, "Post:PhoneAuthResetPhone") 13 web.Router("/auth/reset-phone", &controllers.AuthController{}, "Post:PhoneAuthResetPhone")
14 web.Router("/auth/destroy-account", &controllers.AuthController{}, "Post:DestroyAccount") 14 web.Router("/auth/destroy-account", &controllers.AuthController{}, "Post:DestroyAccount")
15 web.Router("/auth/refresh-im", &controllers.AuthController{}, "Post:RefreshIM") 15 web.Router("/auth/refresh-im", &controllers.AuthController{}, "Post:RefreshIM")
  16 + web.Router("/auth/user-base-info", &controllers.AuthController{}, "Post:UserInfo")
16 } 17 }