作者 yangfu

用户获取

@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 type UserBaseDto struct { 7 type UserBaseDto struct {
8 // 用户基础数据id 8 // 用户基础数据id
9 UserBaseId int64 `json:"userBaseId,omitempty"` 9 UserBaseId int64 `json:"userBaseId,omitempty"`
  10 + UserType int `json:"userType"`
10 // 用户信息 11 // 用户信息
11 UserInfo *domain.UserInfo `json:"userInfo,omitempty"` 12 UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
12 // 手机号码 13 // 手机号码
@@ -28,5 +29,6 @@ type UserBaseDto struct { @@ -28,5 +29,6 @@ type UserBaseDto struct {
28 func (u *UserBaseDto) LoadDto(ub *domain.UserBase) { 29 func (u *UserBaseDto) LoadDto(ub *domain.UserBase) {
29 u.UserBaseId = ub.UserBaseId 30 u.UserBaseId = ub.UserBaseId
30 u.UserInfo = ub.UserInfo 31 u.UserInfo = ub.UserInfo
  32 + u.UserType = domain.UserTypeVisitor
31 u.Im = ub.Im 33 u.Im = ub.Im
32 } 34 }
@@ -9,11 +9,15 @@ import ( @@ -9,11 +9,15 @@ import (
9 ) 9 )
10 10
11 type UserInfoQuery struct { 11 type UserInfoQuery struct {
12 - Account string `cname:"账号" json:"account" valid:"Required"` 12 + Account string `cname:"账号" json:"account"`
  13 + UserBaseId int64 `cname:"用户编号" json:"userBaseId"`
13 } 14 }
14 15
15 func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) { 16 func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) {
16 //validation.SetError("CustomValid", "未实现的自定义认证") 17 //validation.SetError("CustomValid", "未实现的自定义认证")
  18 + if len(userInfoQuery.Account) == 0 && userInfoQuery.UserBaseId <= 0 {
  19 + validation.SetError("CustomValid", "参数不能为空")
  20 + }
17 } 21 }
18 22
19 func (userInfoQuery *UserInfoQuery) ValidateQuery() error { 23 func (userInfoQuery *UserInfoQuery) ValidateQuery() error {
@@ -319,8 +319,13 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in @@ -319,8 +319,13 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in
319 transactionContext.RollbackTransaction() 319 transactionContext.RollbackTransaction()
320 }() 320 }()
321 321
  322 + var userBase *domain.UserBase
322 userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0) 323 userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0)
323 - userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account}) 324 + if len(userInfoQuery.Account) > 0 {
  325 + userBase, err = userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account})
  326 + } else if userInfoQuery.UserBaseId > 0 {
  327 + userBase, err = userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userInfoQuery.UserBaseId})
  328 + }
324 if err != nil { 329 if err != nil {
325 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 330 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
326 } 331 }
@@ -14,6 +14,7 @@ const ( @@ -14,6 +14,7 @@ const (
14 const ( 14 const (
15 UserTypeEmployee = 1 15 UserTypeEmployee = 1
16 UserTypeCooperation = 2 16 UserTypeCooperation = 2
  17 + UserTypeVisitor = 4 // 游客
17 UserTypeCompanyAdmin = 1024 18 UserTypeCompanyAdmin = 1024
18 ) 19 )
19 20