作者 yangfu

用户获取

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