正在显示
21 个修改的文件
包含
135 行增加
和
217 行删除
pkg/application/auth/command/qrcode_bind.go
0 → 100644
@@ -77,6 +77,7 @@ func (svr AuthService) AuthLoginPwd(loginCommand *command.LoginPwdCommand) (inte | @@ -77,6 +77,7 @@ func (svr AuthService) AuthLoginPwd(loginCommand *command.LoginPwdCommand) (inte | ||
77 | Phone: loginCommand.Username, | 77 | Phone: loginCommand.Username, |
78 | Password: loginCommand.Password, | 78 | Password: loginCommand.Password, |
79 | SessionMode: loginCommand.SessionMode, | 79 | SessionMode: loginCommand.SessionMode, |
80 | + DeviceType: loginCommand.DeviceType, | ||
80 | } | 81 | } |
81 | if len(loginCommand.CaptchaChallenge) > 0 { | 82 | if len(loginCommand.CaptchaChallenge) > 0 { |
82 | geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second) | 83 | geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second) |
@@ -98,6 +99,7 @@ func (svr AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (inte | @@ -98,6 +99,7 @@ func (svr AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (inte | ||
98 | Phone: loginCommand.Phone, | 99 | Phone: loginCommand.Phone, |
99 | Captcha: loginCommand.Code, | 100 | Captcha: loginCommand.Code, |
100 | SessionMode: loginCommand.SessionMode, | 101 | SessionMode: loginCommand.SessionMode, |
102 | + DeviceType: loginCommand.DeviceType, | ||
101 | } | 103 | } |
102 | return svr.AuthLogin(login) | 104 | return svr.AuthLogin(login) |
103 | } | 105 | } |
@@ -105,14 +107,23 @@ func (svr AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (inte | @@ -105,14 +107,23 @@ func (svr AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (inte | ||
105 | //AuthLoginQrcode 扫码登录 | 107 | //AuthLoginQrcode 扫码登录 |
106 | func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) (interface{}, error) { | 108 | func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) (interface{}, error) { |
107 | qrmsg := domain.QrcodeMessage{} | 109 | qrmsg := domain.QrcodeMessage{} |
110 | + failLoginData := map[string]interface{}{ | ||
111 | + "isLogin": false, | ||
112 | + "access": struct{}{}, | ||
113 | + } | ||
108 | err := qrmsg.ParseToken(queryParam.Key) | 114 | err := qrmsg.ParseToken(queryParam.Key) |
109 | if err != nil { | 115 | if err != nil { |
110 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 116 | + log.Logger.Error(err.Error()) |
117 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效") | ||
111 | } | 118 | } |
112 | qrCache := cache.LoginQrcodeCache{} | 119 | qrCache := cache.LoginQrcodeCache{} |
113 | qrmsgCache, err := qrCache.Get(qrmsg.Id) | 120 | qrmsgCache, err := qrCache.Get(qrmsg.Id) |
114 | if err != nil { | 121 | if err != nil { |
115 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 122 | + log.Logger.Error(err.Error()) |
123 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效") | ||
124 | + } | ||
125 | + if !qrmsgCache.IsLogin { | ||
126 | + return failLoginData, nil | ||
116 | } | 127 | } |
117 | loginToken := domain.LoginToken{ | 128 | loginToken := domain.LoginToken{ |
118 | UserId: qrmsgCache.UserId, | 129 | UserId: qrmsgCache.UserId, |
@@ -126,6 +137,7 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) | @@ -126,6 +137,7 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) | ||
126 | if err != nil { | 137 | if err != nil { |
127 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 138 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
128 | } | 139 | } |
140 | + qrCache.Remove(qrmsgCache.Id) | ||
129 | _ = accessToken | 141 | _ = accessToken |
130 | result, err := svr.getToken(loginToken) | 142 | result, err := svr.getToken(loginToken) |
131 | data := map[string]interface{}{ | 143 | data := map[string]interface{}{ |
@@ -135,6 +147,28 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) | @@ -135,6 +147,28 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) | ||
135 | return data, nil | 147 | return data, nil |
136 | } | 148 | } |
137 | 149 | ||
150 | +//AuthLoginQrcodeBind 扫码登录-绑定 | ||
151 | +func (svr AuthService) AuthLoginQrcodeBinding(bindingCmd *command.QrcodeBindingCommand) (interface{}, error) { | ||
152 | + qrmsg := domain.QrcodeMessage{} | ||
153 | + err := qrmsg.ParseToken(bindingCmd.Key) | ||
154 | + if err != nil { | ||
155 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效,请重试") | ||
156 | + } | ||
157 | + qrCache := cache.LoginQrcodeCache{} | ||
158 | + qrmsgCache, err := qrCache.Get(qrmsg.Id) | ||
159 | + if err != nil { | ||
160 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
161 | + } | ||
162 | + if err := qrmsgCache.BindUser(bindingCmd.Operator); err != nil { | ||
163 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
164 | + } | ||
165 | + if err := qrCache.Save(*qrmsgCache); err != nil { | ||
166 | + log.Logger.Error(err.Error()) | ||
167 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录失败,请重试") | ||
168 | + } | ||
169 | + return struct{}{}, nil | ||
170 | +} | ||
171 | + | ||
138 | //SendSmsCaptcha 发送验证码短信 | 172 | //SendSmsCaptcha 发送验证码短信 |
139 | func (svr AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error { | 173 | func (svr AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error { |
140 | smsServeGateway := sms_serve.NewHttplibHttplibSmsServe() | 174 | smsServeGateway := sms_serve.NewHttplibHttplibSmsServe() |
@@ -199,6 +233,7 @@ func (svr AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke | @@ -199,6 +233,7 @@ func (svr AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke | ||
199 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 233 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
200 | } | 234 | } |
201 | loginToken.Platform = accessTokenCommand.LoginPlatform | 235 | loginToken.Platform = accessTokenCommand.LoginPlatform |
236 | + loginToken.SessionMode = accessTokenCommand.SessionMode | ||
202 | result, err := svr.getToken(*loginToken) | 237 | result, err := svr.getToken(*loginToken) |
203 | return result["token"], err | 238 | return result["token"], err |
204 | } | 239 | } |
1 | -package service | ||
2 | - | ||
3 | -import ( | ||
4 | - "github.com/linmadan/egglib-go/core/application" | ||
5 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/org/dto" | ||
6 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/org/query" | ||
7 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
8 | -) | ||
9 | - | ||
10 | -type OrgService struct { | ||
11 | -} | ||
12 | - | ||
13 | -//DepartmentsUsers 部门用户列表 | ||
14 | -func (srv OrgService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsUsersQuery) (interface{}, error) { | ||
15 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
16 | - departmentsUsersQuery.Operator) | ||
17 | - orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{ | ||
18 | - OrgId: departmentsUsersQuery.Operator.OrgId, | ||
19 | - }) | ||
20 | - if err != nil { | ||
21 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | - } | ||
23 | - | ||
24 | - users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
25 | - //Offset: 0, | ||
26 | - //Limit: 999, | ||
27 | - CompanyId: departmentsUsersQuery.Operator.CompanyId, | ||
28 | - OrganizationId: departmentsUsersQuery.Operator.OrgId, | ||
29 | - }) | ||
30 | - if err != nil { | ||
31 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
32 | - } | ||
33 | - departmentUsersDto := &dto.DepartmentUsersDto{} | ||
34 | - if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil { | ||
35 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
36 | - } | ||
37 | - return departmentUsersDto, nil | ||
38 | -} | ||
39 | - | ||
40 | -func NewOrgService(options map[string]interface{}) *OrgService { | ||
41 | - newOrgService := &OrgService{} | ||
42 | - return newOrgService | ||
43 | -} |
1 | package dto | 1 | package dto |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
6 | +) | ||
4 | 7 | ||
5 | type DepartmentUsersDto struct { | 8 | type DepartmentUsersDto struct { |
6 | Departments []*Department `json:"departments,omitempty"` | 9 | Departments []*Department `json:"departments,omitempty"` |
@@ -12,6 +15,7 @@ type Department struct { | @@ -12,6 +15,7 @@ type Department struct { | ||
12 | DepartmentName string `json:"departmentName"` | 15 | DepartmentName string `json:"departmentName"` |
13 | Users []User `json:"users"` | 16 | Users []User `json:"users"` |
14 | } | 17 | } |
18 | + | ||
15 | type User struct { | 19 | type User struct { |
16 | UserID int `json:"userId"` | 20 | UserID int `json:"userId"` |
17 | UserCode string `json:"userCode"` | 21 | UserCode string `json:"userCode"` |
@@ -34,6 +38,7 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat | @@ -34,6 +38,7 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat | ||
34 | mapDepartment[-1] = &Department{ | 38 | mapDepartment[-1] = &Department{ |
35 | DepartmentID: -1, | 39 | DepartmentID: -1, |
36 | DepartmentName: "共创部门", | 40 | DepartmentName: "共创部门", |
41 | + Users: make([]User, 0), | ||
37 | } | 42 | } |
38 | 43 | ||
39 | for i := range subDepartment.Orgs { | 44 | for i := range subDepartment.Orgs { |
@@ -57,7 +62,7 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat | @@ -57,7 +62,7 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat | ||
57 | "phone": user.UserInfo.Phone, | 62 | "phone": user.UserInfo.Phone, |
58 | }, | 63 | }, |
59 | } | 64 | } |
60 | - if user.Department == nil { | 65 | + if (user.UserType & domain.UserTypeCooperation) > 0 { |
61 | mapDepartment[-1].Users = append(mapDepartment[-1].Users, u) | 66 | mapDepartment[-1].Users = append(mapDepartment[-1].Users, u) |
62 | continue | 67 | continue |
63 | } | 68 | } |
@@ -4,6 +4,8 @@ import ( | @@ -4,6 +4,8 @@ import ( | ||
4 | "github.com/google/uuid" | 4 | "github.com/google/uuid" |
5 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/command" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/command" |
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/dto" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/query" | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" |
@@ -135,3 +137,30 @@ func (srv UserService) DestroyAccount(destroyAccountCommand *command.DestroyAcco | @@ -135,3 +137,30 @@ func (srv UserService) DestroyAccount(destroyAccountCommand *command.DestroyAcco | ||
135 | } | 137 | } |
136 | return result, err | 138 | return result, err |
137 | } | 139 | } |
140 | + | ||
141 | +//DepartmentsUsers 部门用户列表 | ||
142 | +func (srv UserService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsUsersQuery) (interface{}, error) { | ||
143 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
144 | + departmentsUsersQuery.Operator) | ||
145 | + orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{ | ||
146 | + OrgId: departmentsUsersQuery.Operator.OrgId, | ||
147 | + }) | ||
148 | + if err != nil { | ||
149 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
150 | + } | ||
151 | + | ||
152 | + users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
153 | + //Offset: 0, | ||
154 | + //Limit: 999, | ||
155 | + CompanyId: departmentsUsersQuery.Operator.CompanyId, | ||
156 | + OrganizationId: departmentsUsersQuery.Operator.OrgId, | ||
157 | + }) | ||
158 | + if err != nil { | ||
159 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
160 | + } | ||
161 | + departmentUsersDto := &dto.DepartmentUsersDto{} | ||
162 | + if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil { | ||
163 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
164 | + } | ||
165 | + return departmentUsersDto, nil | ||
166 | +} |
1 | -package dto | ||
2 | - | ||
3 | -import ( | ||
4 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
5 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
6 | -) | ||
7 | - | ||
8 | -type DepartmentUsersDto struct { | ||
9 | - Departments []*Department `json:"departments"` | ||
10 | -} | ||
11 | - | ||
12 | -type Department struct { | ||
13 | - DepartmentID int64 `json:"departmentId,string"` | ||
14 | - DepartmentName string `json:"departmentName"` | ||
15 | - Users []User `json:"users"` | ||
16 | -} | ||
17 | -type User struct { | ||
18 | - UserID int `json:"userId,string"` | ||
19 | - UserCode string `json:"userCode"` | ||
20 | - UserInfo map[string]interface{} `json:"userInfo"` | ||
21 | -} | ||
22 | - | ||
23 | -func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error { | ||
24 | - var mapDepartment = make(map[int64]*Department) | ||
25 | - mapDepartment[-1] = &Department{ | ||
26 | - DepartmentID: -1, | ||
27 | - DepartmentName: "共创部门", | ||
28 | - Users: make([]User, 0), | ||
29 | - } | ||
30 | - dto.Departments = append(dto.Departments, mapDepartment[-1]) | ||
31 | - | ||
32 | - for i := range subDepartment.Orgs { | ||
33 | - org := subDepartment.Orgs[i] | ||
34 | - dep := &Department{ | ||
35 | - DepartmentID: int64(org.OrgID), | ||
36 | - DepartmentName: org.OrgName, | ||
37 | - Users: make([]User, 0), | ||
38 | - } | ||
39 | - dto.Departments = append(dto.Departments, dep) | ||
40 | - mapDepartment[dep.DepartmentID] = dep | ||
41 | - } | ||
42 | - | ||
43 | - for i := range userSearch.Users { | ||
44 | - user := userSearch.Users[i] | ||
45 | - u := User{ | ||
46 | - UserID: user.UserId, | ||
47 | - UserCode: user.UserCode, | ||
48 | - UserInfo: map[string]interface{}{ | ||
49 | - "userName": user.UserInfo.UserName, | ||
50 | - "phone": user.UserInfo.Phone, | ||
51 | - }, | ||
52 | - } | ||
53 | - if (user.UserType & domain.UserTypeCooperation) > 0 { | ||
54 | - mapDepartment[-1].Users = append(mapDepartment[-1].Users, u) | ||
55 | - continue | ||
56 | - } | ||
57 | - if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok { | ||
58 | - v.Users = append(v.Users, u) | ||
59 | - } | ||
60 | - } | ||
61 | - return nil | ||
62 | -} |
1 | -package query | ||
2 | - | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - "github.com/beego/beego/v2/core/validation" | ||
6 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
7 | -) | ||
8 | - | ||
9 | -//获取自定义菜单列表 | ||
10 | -type DepartmentsUsersQuery struct { | ||
11 | - //操作人 | ||
12 | - Operator domain.Operator `json:"-"` | ||
13 | -} | ||
14 | - | ||
15 | -func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) { | ||
16 | - | ||
17 | -} | ||
18 | - | ||
19 | -func (departmentsUsersQuery *DepartmentsUsersQuery) ValidateQuery() error { | ||
20 | - valid := validation.Validation{} | ||
21 | - b, err := valid.Valid(departmentsUsersQuery) | ||
22 | - if err != nil { | ||
23 | - return err | ||
24 | - } | ||
25 | - if !b { | ||
26 | - for _, validErr := range valid.Errors { | ||
27 | - return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | - } | ||
29 | - } | ||
30 | - return nil | ||
31 | -} |
@@ -147,33 +147,6 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub | @@ -147,33 +147,6 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub | ||
147 | }, nil | 147 | }, nil |
148 | } | 148 | } |
149 | 149 | ||
150 | -//DepartmentsUsers 部门用户列表 | ||
151 | -func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsUsersQuery) (interface{}, error) { | ||
152 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
153 | - departmentsUsersQuery.Operator) | ||
154 | - orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{ | ||
155 | - OrgId: departmentsUsersQuery.Operator.OrgId, | ||
156 | - }) | ||
157 | - if err != nil { | ||
158 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
159 | - } | ||
160 | - | ||
161 | - users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
162 | - //Offset: 0, | ||
163 | - //Limit: 999, | ||
164 | - CompanyId: departmentsUsersQuery.Operator.CompanyId, | ||
165 | - OrganizationId: departmentsUsersQuery.Operator.OrgId, | ||
166 | - }) | ||
167 | - if err != nil { | ||
168 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
169 | - } | ||
170 | - departmentUsersDto := &dto.DepartmentUsersDto{} | ||
171 | - if err := departmentUsersDto.LoadDto(orgs, users); err != nil { | ||
172 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
173 | - } | ||
174 | - return departmentUsersDto, nil | ||
175 | -} | ||
176 | - | ||
177 | func NewOrgsService(options map[string]interface{}) *OrgsService { | 150 | func NewOrgsService(options map[string]interface{}) *OrgsService { |
178 | newOrgsService := &OrgsService{} | 151 | newOrgsService := &OrgsService{} |
179 | return newOrgsService | 152 | return newOrgsService |
@@ -79,3 +79,16 @@ func (qrmsg *QrcodeMessage) ParseToken(str string) error { | @@ -79,3 +79,16 @@ func (qrmsg *QrcodeMessage) ParseToken(str string) error { | ||
79 | } | 79 | } |
80 | return nil | 80 | return nil |
81 | } | 81 | } |
82 | + | ||
83 | +func (qrmsg *QrcodeMessage) BindUser(operator Operator) error { | ||
84 | + if qrmsg.IsLogin { | ||
85 | + return fmt.Errorf("登录中") | ||
86 | + } | ||
87 | + qrmsg.UserId = operator.UserId | ||
88 | + qrmsg.OrgId = operator.OrgId | ||
89 | + qrmsg.CompanyId = operator.CompanyId | ||
90 | + qrmsg.UserBaseId = operator.UserBaseId | ||
91 | + qrmsg.Account = operator.Phone | ||
92 | + qrmsg.IsLogin = true | ||
93 | + return nil | ||
94 | +} |
@@ -20,7 +20,7 @@ func (lq LoginQrcodeCache) Save(qrcode domain.QrcodeMessage) error { | @@ -20,7 +20,7 @@ func (lq LoginQrcodeCache) Save(qrcode domain.QrcodeMessage) error { | ||
20 | nowTime := time.Now().Unix() | 20 | nowTime := time.Now().Unix() |
21 | exp := qrcode.ExpiresAt - nowTime | 21 | exp := qrcode.ExpiresAt - nowTime |
22 | if exp <= 0 { | 22 | if exp <= 0 { |
23 | - exp = 60 * 60 * 2 | 23 | + exp = 60 * 5 |
24 | } | 24 | } |
25 | key := lq.keyString(qrcode.Id) | 25 | key := lq.keyString(qrcode.Id) |
26 | bt, _ := json.Marshal(qrcode) | 26 | bt, _ := json.Marshal(qrcode) |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | 7 | ||
8 | func TransformToLoginAccessDomainModelFromPgModels(loginAccessModel *models.LoginAccess) (*domain.LoginAccess, error) { | 8 | func TransformToLoginAccessDomainModelFromPgModels(loginAccessModel *models.LoginAccess) (*domain.LoginAccess, error) { |
9 | return &domain.LoginAccess{ | 9 | return &domain.LoginAccess{ |
10 | + LoginAccessId: loginAccessModel.LoginAccessId, | ||
10 | Account: loginAccessModel.Account, | 11 | Account: loginAccessModel.Account, |
11 | Platform: loginAccessModel.Platform, | 12 | Platform: loginAccessModel.Platform, |
12 | CompanyId: loginAccessModel.CompanyId, | 13 | CompanyId: loginAccessModel.CompanyId, |
@@ -22,6 +22,7 @@ func (controller *AuthController) LoginPwd() { | @@ -22,6 +22,7 @@ func (controller *AuthController) LoginPwd() { | ||
22 | authService := service.AuthService{} | 22 | authService := service.AuthService{} |
23 | loginCmd := &command.LoginPwdCommand{} | 23 | loginCmd := &command.LoginPwdCommand{} |
24 | Must(controller.Unmarshal(loginCmd)) | 24 | Must(controller.Unmarshal(loginCmd)) |
25 | + loginCmd.DeviceType = controller.GetDeviceType() | ||
25 | data, err := authService.AuthLoginPwd(loginCmd) | 26 | data, err := authService.AuthLoginPwd(loginCmd) |
26 | controller.Response(data, err) | 27 | controller.Response(data, err) |
27 | } | 28 | } |
@@ -30,6 +31,7 @@ func (controller *AuthController) LoginSms() { | @@ -30,6 +31,7 @@ func (controller *AuthController) LoginSms() { | ||
30 | authService := service.AuthService{} | 31 | authService := service.AuthService{} |
31 | loginCmd := &command.LoginSmsCommand{} | 32 | loginCmd := &command.LoginSmsCommand{} |
32 | Must(controller.Unmarshal(loginCmd)) | 33 | Must(controller.Unmarshal(loginCmd)) |
34 | + loginCmd.DeviceType = controller.GetDeviceType() | ||
33 | data, err := authService.AuthLoginSms(loginCmd) | 35 | data, err := authService.AuthLoginSms(loginCmd) |
34 | controller.Response(data, err) | 36 | controller.Response(data, err) |
35 | } | 37 | } |
@@ -164,14 +166,24 @@ func (controller *AuthController) GetQrcode() { | @@ -164,14 +166,24 @@ func (controller *AuthController) GetQrcode() { | ||
164 | controller.Response(data, err) | 166 | controller.Response(data, err) |
165 | } | 167 | } |
166 | 168 | ||
167 | -func (controller *AuthController) QrcodeLoginStatus() { | 169 | +func (controller *AuthController) LoginQrcode() { |
168 | authService := service.AuthService{} | 170 | authService := service.AuthService{} |
169 | cmd := &query.QrcodeLoginStatusQuery{} | 171 | cmd := &query.QrcodeLoginStatusQuery{} |
170 | Must(controller.Unmarshal(cmd)) | 172 | Must(controller.Unmarshal(cmd)) |
173 | + cmd.DeviceType = controller.GetDeviceType() | ||
171 | data, err := authService.AuthLoginQrcode(cmd) | 174 | data, err := authService.AuthLoginQrcode(cmd) |
172 | controller.Response(data, err) | 175 | controller.Response(data, err) |
173 | } | 176 | } |
174 | 177 | ||
178 | +func (controller *AuthController) QrcodeBinding() { | ||
179 | + authService := service.AuthService{} | ||
180 | + cmd := &command.QrcodeBindingCommand{} | ||
181 | + Must(controller.Unmarshal(cmd)) | ||
182 | + cmd.Operator = controller.GetOperator() | ||
183 | + data, err := authService.AuthLoginQrcodeBinding(cmd) | ||
184 | + controller.Response(data, err) | ||
185 | +} | ||
186 | + | ||
175 | func (controller *AuthController) CheckSmsCode() { | 187 | func (controller *AuthController) CheckSmsCode() { |
176 | authService := service.AuthService{} | 188 | authService := service.AuthService{} |
177 | cmd := &command.CheckSmsCodeCommand{} | 189 | cmd := &command.CheckSmsCodeCommand{} |
@@ -98,6 +98,10 @@ func (controller *BaseController) GetOperator() domain.Operator { | @@ -98,6 +98,10 @@ func (controller *BaseController) GetOperator() domain.Operator { | ||
98 | return op | 98 | return op |
99 | } | 99 | } |
100 | 100 | ||
101 | +func (controller *BaseController) GetDeviceType() string { | ||
102 | + return controller.Ctx.Input.Header("x-mmm-devicetype") | ||
103 | +} | ||
104 | + | ||
101 | func Must(err error) { | 105 | func Must(err error) { |
102 | if err != nil { | 106 | if err != nil { |
103 | log.Logger.Error(err.Error()) | 107 | log.Logger.Error(err.Error()) |
1 | -package mobile_client | ||
2 | - | ||
3 | -import ( | ||
4 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/org/query" | ||
5 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/org/service" | ||
6 | -) | ||
7 | - | ||
8 | -type OrgController struct { | ||
9 | - baseController | ||
10 | -} | ||
11 | - | ||
12 | -func (controller *OrgController) DepartmentUsers() { | ||
13 | - orgService := service.OrgService{} | ||
14 | - departmentsUsersQuery := &query.DepartmentsUsersQuery{} | ||
15 | - err := controller.Unmarshal(departmentsUsersQuery) | ||
16 | - if err != nil { | ||
17 | - controller.Response(nil, err) | ||
18 | - return | ||
19 | - } | ||
20 | - departmentsUsersQuery.Operator = controller.GetOperator() | ||
21 | - data, err := orgService.DepartmentsUsers(departmentsUsersQuery) | ||
22 | - controller.Response(data, err) | ||
23 | -} |
@@ -2,6 +2,7 @@ package mobile_client | @@ -2,6 +2,7 @@ package mobile_client | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/command" | 4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/command" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/query" | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/service" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/service" |
6 | ) | 7 | ) |
7 | 8 | ||
@@ -84,3 +85,16 @@ func (controller *UserController) DestroyAccount() { | @@ -84,3 +85,16 @@ func (controller *UserController) DestroyAccount() { | ||
84 | data, err := authService.DestroyAccount(cmd) | 85 | data, err := authService.DestroyAccount(cmd) |
85 | controller.Response(data, err) | 86 | controller.Response(data, err) |
86 | } | 87 | } |
88 | + | ||
89 | +func (controller *UserController) DepartmentUsers() { | ||
90 | + orgService := service.UserService{} | ||
91 | + departmentsUsersQuery := &query.DepartmentsUsersQuery{} | ||
92 | + err := controller.Unmarshal(departmentsUsersQuery) | ||
93 | + if err != nil { | ||
94 | + controller.Response(nil, err) | ||
95 | + return | ||
96 | + } | ||
97 | + departmentsUsersQuery.Operator = controller.GetOperator() | ||
98 | + data, err := orgService.DepartmentsUsers(departmentsUsersQuery) | ||
99 | + controller.Response(data, err) | ||
100 | +} |
@@ -82,16 +82,3 @@ func (controller *OrgsController) OrgGetSubDepartment() { | @@ -82,16 +82,3 @@ func (controller *OrgsController) OrgGetSubDepartment() { | ||
82 | data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery) | 82 | data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery) |
83 | controller.Response(data, err) | 83 | controller.Response(data, err) |
84 | } | 84 | } |
85 | - | ||
86 | -func (controller *OrgsController) DepartmentUsers() { | ||
87 | - orgService := service.OrgsService{} | ||
88 | - departmentsUsersQuery := &query.DepartmentsUsersQuery{} | ||
89 | - err := controller.Unmarshal(departmentsUsersQuery) | ||
90 | - if err != nil { | ||
91 | - controller.Response(nil, err) | ||
92 | - return | ||
93 | - } | ||
94 | - departmentsUsersQuery.Operator = controller.GetOperator() | ||
95 | - data, err := orgService.DepartmentsUsers(departmentsUsersQuery) | ||
96 | - controller.Response(data, err) | ||
97 | -} |
@@ -9,7 +9,8 @@ func init() { | @@ -9,7 +9,8 @@ func init() { | ||
9 | //web.Router("/v1/auth/login", &controllers.AuthController{}, "Post:Login") | 9 | //web.Router("/v1/auth/login", &controllers.AuthController{}, "Post:Login") |
10 | web.Router("/v1/auth/login/pwd", &controllers.AuthController{}, "Post:LoginPwd") | 10 | web.Router("/v1/auth/login/pwd", &controllers.AuthController{}, "Post:LoginPwd") |
11 | web.Router("/v1/auth/login/sms", &controllers.AuthController{}, "Post:LoginSms") | 11 | web.Router("/v1/auth/login/sms", &controllers.AuthController{}, "Post:LoginSms") |
12 | - web.Router("/v1/auth/login/qrcode", &controllers.AuthController{}, "Post:QrcodeLoginStatus") | 12 | + web.Router("/v1/auth/login/qrcode", &controllers.AuthController{}, "Post:LoginQrcode") |
13 | + web.Router("/v1/auth/login/qrcode-binding", &controllers.AuthController{}, "Post:QrcodeBinding") | ||
13 | web.Router("/v1/auth/captcha-init", &controllers.AuthController{}, "Get:CaptchaInit") | 14 | web.Router("/v1/auth/captcha-init", &controllers.AuthController{}, "Get:CaptchaInit") |
14 | web.Router("/v1/auth/qrcode-init", &controllers.AuthController{}, "Post:GetQrcode") | 15 | web.Router("/v1/auth/qrcode-init", &controllers.AuthController{}, "Post:GetQrcode") |
15 | web.Router("/v1/auth/sms-code", &controllers.AuthController{}, "Post:SendSmsCode") | 16 | web.Router("/v1/auth/sms-code", &controllers.AuthController{}, "Post:SendSmsCode") |
1 | -package routers | ||
2 | - | ||
3 | -import ( | ||
4 | - "github.com/beego/beego/v2/server/web" | ||
5 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client" | ||
6 | -) | ||
7 | - | ||
8 | -func init() { | ||
9 | - web.Router("/v1/app/orgs/department-users", &mobile_client.OrgController{}, "Post:DepartmentUsers") | ||
10 | -} |
@@ -17,4 +17,9 @@ func init() { | @@ -17,4 +17,9 @@ func init() { | ||
17 | web.Router("/v1/user/change-phone", &mobile_client.UserController{}, "Post:ChangePhone") | 17 | web.Router("/v1/user/change-phone", &mobile_client.UserController{}, "Post:ChangePhone") |
18 | web.Router("/v1/user/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo") | 18 | web.Router("/v1/user/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo") |
19 | web.Router("/v1/user/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount") | 19 | web.Router("/v1/user/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount") |
20 | + web.Router("/v1/user/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") | ||
21 | + | ||
22 | + // 特殊处理 | ||
23 | + web.Router("/v1/app/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") | ||
24 | + web.Router("/v1/web/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") | ||
20 | } | 25 | } |
@@ -12,5 +12,4 @@ func init() { | @@ -12,5 +12,4 @@ func init() { | ||
12 | web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet") | 12 | web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet") |
13 | web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable") | 13 | web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable") |
14 | web.Router("/v1/web/orgs/departments", &web_client.OrgsController{}, "Post:OrgGetSubDepartment") | 14 | web.Router("/v1/web/orgs/departments", &web_client.OrgsController{}, "Post:OrgGetSubDepartment") |
15 | - web.Router("/v1/web/orgs/department-users", &web_client.OrgsController{}, "Post:DepartmentUsers") | ||
16 | } | 15 | } |
-
请 注册 或 登录 后发表评论