作者 yangfu

个人注册推荐人

@@ -15,6 +15,8 @@ type UserSignUpCommand struct { @@ -15,6 +15,8 @@ type UserSignUpCommand struct {
15 Phone string `cname:"手机号码" json:"phone" valid:"Required"` 15 Phone string `cname:"手机号码" json:"phone" valid:"Required"`
16 // 密码 16 // 密码
17 Password string `cname:"密码" json:"password" valid:"Required"` 17 Password string `cname:"密码" json:"password" valid:"Required"`
  18 + // 推荐人
  19 + Referrer string `cname:"推荐人" json:"referrer"`
18 } 20 }
19 21
20 func (companySignUpCommand *UserSignUpCommand) Valid(validation *validation.Validation) { 22 func (companySignUpCommand *UserSignUpCommand) Valid(validation *validation.Validation) {
@@ -84,6 +84,7 @@ func (authService *AuthService) UserSignUp(companySignUpCommand *command.UserSig @@ -84,6 +84,7 @@ func (authService *AuthService) UserSignUp(companySignUpCommand *command.UserSig
84 userInfo := &domain.UserInfo{ 84 userInfo := &domain.UserInfo{
85 UserName: companySignUpCommand.Name, 85 UserName: companySignUpCommand.Name,
86 Phone: companySignUpCommand.Phone, 86 Phone: companySignUpCommand.Phone,
  87 + Referer: companySignUpCommand.Referrer,
87 } 88 }
88 if _, err = signUpPersonService.SignUp(companySignUpCommand.Phone, companySignUpCommand.Password, userInfo); err != nil { 89 if _, err = signUpPersonService.SignUp(companySignUpCommand.Phone, companySignUpCommand.Password, userInfo); err != nil {
89 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 90 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -44,6 +44,7 @@ type UserBase struct { @@ -44,6 +44,7 @@ type UserBase struct {
44 44
45 type Favorite struct { 45 type Favorite struct {
46 OrgItems []int64 `json:"orgItems"` 46 OrgItems []int64 `json:"orgItems"`
  47 + Referer string `json:"referer"`
47 } 48 }
48 49
49 type UserBaseRepository interface { 50 type UserBaseRepository interface {
@@ -10,4 +10,6 @@ type UserInfo struct { @@ -10,4 +10,6 @@ type UserInfo struct {
10 Avatar string `json:"avatar,omitempty"` 10 Avatar string `json:"avatar,omitempty"`
11 // 邮箱 11 // 邮箱
12 Email string `json:"email,omitempty"` 12 Email string `json:"email,omitempty"`
  13 +
  14 + Referer string `json:"-"`
13 } 15 }
@@ -35,6 +35,10 @@ func (ptr *PgCreateUserAccountService) CreateUserAccount(registerAccount string, @@ -35,6 +35,10 @@ func (ptr *PgCreateUserAccountService) CreateUserAccount(registerAccount string,
35 Status: int(domain.UserStatusEnable), 35 Status: int(domain.UserStatusEnable),
36 CreatedAt: time.Now(), 36 CreatedAt: time.Now(),
37 UpdatedAt: time.Now(), 37 UpdatedAt: time.Now(),
  38 + Favorite: &domain.Favorite{
  39 + OrgItems: make([]int64, 0),
  40 + Referer: userInfo.Referer,
  41 + },
38 } 42 }
39 if existsUserBase, e := userBaseRepository.FindOne(map[string]interface{}{"account": registerAccount}); e == nil && existsUserBase != nil { 43 if existsUserBase, e := userBaseRepository.FindOne(map[string]interface{}{"account": registerAccount}); e == nil && existsUserBase != nil {
40 return existsUserBase, nil 44 return existsUserBase, nil