正在显示
8 个修改的文件
包含
77 行增加
和
12 行删除
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + | ||
| 6 | + "github.com/beego/beego/v2/core/validation" | ||
| 7 | +) | ||
| 8 | + | ||
| 3 | type CompanySignUpCommand struct { | 9 | type CompanySignUpCommand struct { |
| 4 | - CompanyName string | ||
| 5 | - Contacts string | ||
| 6 | - IndustryCategory string | ||
| 7 | - Password string | ||
| 8 | - Phone string | ||
| 9 | - Scale string | 10 | + CompanyName string `json:"companyName"` |
| 11 | + Contacts string `json:"contacts"` | ||
| 12 | + IndustryCategory string `json:"industryCategory"` | ||
| 13 | + Password string `json:"password"` | ||
| 14 | + Phone string `json:"phone"` | ||
| 15 | + Scale string `json:"scale"` | ||
| 16 | + SmsCode string `json:"smsCode"` | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func (orgAddCommand *CompanySignUpCommand) Valid(validation *validation.Validation) { | ||
| 20 | + | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func (orgAddCommand *CompanySignUpCommand) ValidateCommand() error { | ||
| 24 | + valid := validation.Validation{} | ||
| 25 | + b, err := valid.Valid(orgAddCommand) | ||
| 26 | + if err != nil { | ||
| 27 | + return err | ||
| 28 | + } | ||
| 29 | + if !b { | ||
| 30 | + for _, validErr := range valid.Errors { | ||
| 31 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + return nil | ||
| 10 | } | 35 | } |
| @@ -29,6 +29,10 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti | @@ -29,6 +29,10 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti | ||
| 29 | 29 | ||
| 30 | //CompanySignUp 公司注册 | 30 | //CompanySignUp 公司注册 |
| 31 | func (srv *CommonService) CompanySignUp(signUpCommand *command.CompanySignUpCommand) (interface{}, error) { | 31 | func (srv *CommonService) CompanySignUp(signUpCommand *command.CompanySignUpCommand) (interface{}, error) { |
| 32 | + if err := signUpCommand.ValidateCommand(); err != nil { | ||
| 33 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 34 | + } | ||
| 35 | + //校验验证码 | ||
| 32 | creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(0, 0, 0) | 36 | creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(0, 0, 0) |
| 33 | _, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{ | 37 | _, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{ |
| 34 | CompanyName: signUpCommand.CompanyName, | 38 | CompanyName: signUpCommand.CompanyName, |
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + | ||
| 6 | + "github.com/beego/beego/v2/core/validation" | ||
| 7 | +) | ||
| 8 | + | ||
| 3 | type LoginCommand struct { | 9 | type LoginCommand struct { |
| 4 | - Phone string `json:"phone"` | ||
| 5 | - GrantType string `json:"grantType"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录) | 10 | + Phone string `json:"phone" valid:"Required"` |
| 11 | + GrantType string `json:"grantType" valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录) | ||
| 6 | Password string `json:"password"` | 12 | Password string `json:"password"` |
| 7 | Captcha string `json:"captcha"` | 13 | Captcha string `json:"captcha"` |
| 8 | } | 14 | } |
| 15 | + | ||
| 16 | +func (orgAddCommand *LoginCommand) Valid(validation *validation.Validation) { | ||
| 17 | + | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func (orgAddCommand *LoginCommand) ValidateCommand() error { | ||
| 21 | + valid := validation.Validation{} | ||
| 22 | + b, err := valid.Valid(orgAddCommand) | ||
| 23 | + if err != nil { | ||
| 24 | + return err | ||
| 25 | + } | ||
| 26 | + if !b { | ||
| 27 | + for _, validErr := range valid.Errors { | ||
| 28 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + return nil | ||
| 32 | +} |
| @@ -140,7 +140,8 @@ loopUser1: | @@ -140,7 +140,8 @@ loopUser1: | ||
| 140 | } | 140 | } |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | - //记录上一次的登录公司组织信息不可用 ,重登录置记录 | 143 | + //记录上一次的登录公司组织信息不可用 ,重置登录记录 |
| 144 | + //使用找到的第一个可用的公司组织 | ||
| 144 | if !currentOrgIsOK { | 145 | if !currentOrgIsOK { |
| 145 | loopUser2: | 146 | loopUser2: |
| 146 | for _, v := range userSeachResult.Users { | 147 | for _, v := range userSeachResult.Users { |
| @@ -181,6 +182,7 @@ loopUser1: | @@ -181,6 +182,7 @@ loopUser1: | ||
| 181 | if err := transactionContext.CommitTransaction(); err != nil { | 182 | if err := transactionContext.CommitTransaction(); err != nil { |
| 182 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 183 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 183 | } | 184 | } |
| 185 | + //后处理redis缓存 | ||
| 184 | tokenCache := cache.LoginTokenCache{} | 186 | tokenCache := cache.LoginTokenCache{} |
| 185 | tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp) | 187 | tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp) |
| 186 | tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp) | 188 | tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp) |
| @@ -291,6 +293,7 @@ loopUser1: | @@ -291,6 +293,7 @@ loopUser1: | ||
| 291 | if err := transactionContext.CommitTransaction(); err != nil { | 293 | if err := transactionContext.CommitTransaction(); err != nil { |
| 292 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 294 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 293 | } | 295 | } |
| 296 | + //后处理redis缓存 | ||
| 294 | tokenCache := cache.LoginTokenCache{} | 297 | tokenCache := cache.LoginTokenCache{} |
| 295 | tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp) | 298 | tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp) |
| 296 | tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp) | 299 | tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp) |
| 1 | +package service |
pkg/infrastructure/cache/catcha.go
已删除
100644 → 0
| @@ -2,6 +2,7 @@ package common_controller | @@ -2,6 +2,7 @@ package common_controller | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/linmadan/egglib-go/web/beego" | 4 | "github.com/linmadan/egglib-go/web/beego" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/command" | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service" |
| 7 | ) | 8 | ) |
| @@ -17,3 +18,11 @@ func (controller *CommonController) GetDictionaryByCode() { | @@ -17,3 +18,11 @@ func (controller *CommonController) GetDictionaryByCode() { | ||
| 17 | data, err := commonService.GetDictionaryByCode(&queryParm) | 18 | data, err := commonService.GetDictionaryByCode(&queryParm) |
| 18 | controller.Response(data, err) | 19 | controller.Response(data, err) |
| 19 | } | 20 | } |
| 21 | + | ||
| 22 | +func (controller *CommonController) CompanySignUp() { | ||
| 23 | + commonService := service.NewCommonService(nil) | ||
| 24 | + queryParm := command.CompanySignUpCommand{} | ||
| 25 | + _ = controller.Unmarshal(queryParm) | ||
| 26 | + data, err := commonService.CompanySignUp(&queryParm) | ||
| 27 | + controller.Response(data, err) | ||
| 28 | +} |
| @@ -2,10 +2,12 @@ package routers | @@ -2,10 +2,12 @@ package routers | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/server/web" | 4 | "github.com/beego/beego/v2/server/web" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/common_controller" | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client" |
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | func init() { | 9 | func init() { |
| 10 | + web.Router("/v1/app/users/regist/company", &common_controller.CommonController{}, "Post:CompanySignUp") | ||
| 9 | web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login") | 11 | web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login") |
| 10 | web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken") | 12 | web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken") |
| 11 | web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken") | 13 | web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken") |
-
请 注册 或 登录 后发表评论