作者 yangfu

个人注册推荐人

... ... @@ -15,6 +15,8 @@ type UserSignUpCommand struct {
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
// 推荐人
Referrer string `cname:"推荐人" json:"referrer"`
}
func (companySignUpCommand *UserSignUpCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -84,6 +84,7 @@ func (authService *AuthService) UserSignUp(companySignUpCommand *command.UserSig
userInfo := &domain.UserInfo{
UserName: companySignUpCommand.Name,
Phone: companySignUpCommand.Phone,
Referer: companySignUpCommand.Referrer,
}
if _, err = signUpPersonService.SignUp(companySignUpCommand.Phone, companySignUpCommand.Password, userInfo); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -44,6 +44,7 @@ type UserBase struct {
type Favorite struct {
OrgItems []int64 `json:"orgItems"`
Referer string `json:"referer"`
}
type UserBaseRepository interface {
... ...
... ... @@ -10,4 +10,6 @@ type UserInfo struct {
Avatar string `json:"avatar,omitempty"`
// 邮箱
Email string `json:"email,omitempty"`
Referer string `json:"-"`
}
... ...
... ... @@ -35,6 +35,10 @@ func (ptr *PgCreateUserAccountService) CreateUserAccount(registerAccount string,
Status: int(domain.UserStatusEnable),
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Favorite: &domain.Favorite{
OrgItems: make([]int64, 0),
Referer: userInfo.Referer,
},
}
if existsUserBase, e := userBaseRepository.FindOne(map[string]interface{}{"account": registerAccount}); e == nil && existsUserBase != nil {
return existsUserBase, nil
... ...