正在显示
8 个修改的文件
包含
230 行增加
和
52 行删除
@@ -69,7 +69,13 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | @@ -69,7 +69,13 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | ||
69 | err = protocol.NewCustomMessage(1, "登录方式不支持!") | 69 | err = protocol.NewCustomMessage(1, "登录方式不支持!") |
70 | break | 70 | break |
71 | } | 71 | } |
72 | - rsp.AuthCode, _ = utils.GenerateToken(partnerInfo.Id, request.Phone, protocol.AuthCodeExpire*time.Second) | 72 | + userClaim := utils.UserTokenClaims{ |
73 | + UserId: partnerInfo.Id, | ||
74 | + Phone: partnerInfo.Account, | ||
75 | + AdminType: int(protocolx.AdminTypePartner), | ||
76 | + CompanyId: 1, //默认公司 | ||
77 | + } | ||
78 | + rsp.AuthCode, _ = utils.GenerateTokenWithClaim(userClaim, protocol.AuthCodeExpire*time.Second) | ||
73 | 79 | ||
74 | if _, err = InitOrUpdateUserIMInfo(partnerInfo.Id, partnerInfo.PartnerName, transactionContext); err != nil { | 80 | if _, err = InitOrUpdateUserIMInfo(partnerInfo.Id, partnerInfo.PartnerName, transactionContext); err != nil { |
75 | log.Error(err) | 81 | log.Error(err) |
@@ -133,13 +139,11 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | @@ -133,13 +139,11 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | ||
133 | claim *utils.UserTokenClaims | 139 | claim *utils.UserTokenClaims |
134 | transactionContext, _ = factory.CreateTransactionContext(nil) | 140 | transactionContext, _ = factory.CreateTransactionContext(nil) |
135 | PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | 141 | PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) |
136 | - //PartnerSubAccountRepository, _ = factory.CreatePartnerSubAccountRepository(transactionContext) | ||
137 | - UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | 142 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) |
138 | 143 | ||
139 | partnerInfo *domain.PartnerInfo | 144 | partnerInfo *domain.PartnerInfo |
140 | - //partnerSubAccount *domain.PartnerSubAccount | ||
141 | - user *domain.Users | ||
142 | - userId int64 | 145 | + user *domain.Users |
146 | + userId int64 | ||
143 | ) | 147 | ) |
144 | 148 | ||
145 | if err = transactionContext.StartTransaction(); err != nil { | 149 | if err = transactionContext.StartTransaction(); err != nil { |
@@ -159,27 +163,22 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | @@ -159,27 +163,22 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | ||
159 | return | 163 | return |
160 | } | 164 | } |
161 | 165 | ||
162 | - //验证用户有效 | ||
163 | - //var e error | ||
164 | - //if partnerSubAccount, e = PartnerSubAccountRepository.FindOne(map[string]interface{}{"account": claim.Phone}); e == nil { | ||
165 | - // partnerInfo, e = PartnerInfoService.FindOne(map[string]interface{}{"id": partnerSubAccount.PartnerId}) | ||
166 | - //} else { | ||
167 | - // partnerInfo, e = PartnerInfoService.FindOne(map[string]interface{}{"account": claim.Phone}) | ||
168 | - //} | ||
169 | switch claim.AdminType { | 166 | switch claim.AdminType { |
170 | - case 1: | ||
171 | - if user, err = UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": claim.CompanyId, "status": 1}); err != nil || user != nil { | 167 | + case int(protocolx.AdminTypePartner): |
168 | + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": claim.CompanyId, "status": 1}); err != nil || partnerInfo == nil { | ||
169 | + log.Error(err) | ||
172 | err = protocol.NewErrWithMessage(4140, err) | 170 | err = protocol.NewErrWithMessage(4140, err) |
173 | return | 171 | return |
174 | } | 172 | } |
175 | - userId = user.Id | 173 | + userId = partnerInfo.Id |
176 | break | 174 | break |
177 | - case 2: | ||
178 | - if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": claim.Id, "companyId": claim.CompanyId, "status": 1}); err != nil || partnerInfo == nil { | 175 | + case int(protocolx.AdminTypeManager): |
176 | + if user, err = UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": claim.CompanyId, "status": 1}); err != nil || user == nil { | ||
177 | + log.Error(err) | ||
179 | err = protocol.NewErrWithMessage(4140, err) | 178 | err = protocol.NewErrWithMessage(4140, err) |
180 | return | 179 | return |
181 | } | 180 | } |
182 | - userId = partnerInfo.Id | 181 | + userId = user.Id |
183 | break | 182 | break |
184 | default: | 183 | default: |
185 | err = protocol.NewErrWithMessage(4140, err) | 184 | err = protocol.NewErrWithMessage(4140, err) |
@@ -192,8 +191,14 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | @@ -192,8 +191,14 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | ||
192 | // err = protocol.NewErrWithMessage(4140, err) | 191 | // err = protocol.NewErrWithMessage(4140, err) |
193 | // return | 192 | // return |
194 | //} | 193 | //} |
195 | - rsp.AccessToken, _ = utils.GenerateTokenWithAdminType(userId, claim.Phone, claim.AdminType, protocol.TokenExpire*time.Second) | ||
196 | - rsp.RefreshToken, _ = utils.GenerateTokenWithAdminType(userId, claim.Phone, claim.AdminType, protocol.RefreshTokenExipre*time.Second) | 194 | + userClaim := utils.UserTokenClaims{ |
195 | + UserId: userId, | ||
196 | + Phone: claim.Phone, | ||
197 | + AdminType: claim.AdminType, | ||
198 | + CompanyId: claim.CompanyId, | ||
199 | + } | ||
200 | + rsp.AccessToken, _ = utils.GenerateTokenWithClaim(userClaim, protocol.TokenExpire*time.Second) | ||
201 | + rsp.RefreshToken, _ = utils.GenerateTokenWithClaim(userClaim, protocol.RefreshTokenExipre*time.Second) | ||
197 | rsp.ExpiresIn = protocol.TokenExpire | 202 | rsp.ExpiresIn = protocol.TokenExpire |
198 | 203 | ||
199 | //newAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(claim.UserId), | 204 | //newAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(claim.UserId), |
@@ -390,8 +395,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | @@ -390,8 +395,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | ||
390 | //根据simnum + cid | 395 | //根据simnum + cid |
391 | userClaims := utils.UserTokenClaims{ | 396 | userClaims := utils.UserTokenClaims{ |
392 | UserId: userId, | 397 | UserId: userId, |
393 | - CompanyId: claim.CompanyId, | ||
394 | - AdminType: claim.AdminType, | 398 | + CompanyId: int64(request.Cid), |
399 | + AdminType: request.IdType, | ||
395 | Phone: claim.Phone, | 400 | Phone: claim.Phone, |
396 | } | 401 | } |
397 | rsp.AuthCode, _ = utils.GenerateTokenWithClaim(userClaims, protocol.AuthCodeExpire*time.Second) | 402 | rsp.AuthCode, _ = utils.GenerateTokenWithClaim(userClaims, protocol.AuthCodeExpire*time.Second) |
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
11 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 11 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
12 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" | ||
12 | "strconv" | 13 | "strconv" |
13 | "strings" | 14 | "strings" |
14 | ) | 15 | ) |
@@ -20,8 +21,10 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | @@ -20,8 +21,10 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | ||
20 | transactionContext, _ = factory.CreateTransactionContext(nil) | 21 | transactionContext, _ = factory.CreateTransactionContext(nil) |
21 | CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext) | 22 | CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext) |
22 | PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | 23 | PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) |
24 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
23 | ImInfoRepository, _ = factory.CreateImInfoRepository(transactionContext) | 25 | ImInfoRepository, _ = factory.CreateImInfoRepository(transactionContext) |
24 | company *domain.Company | 26 | company *domain.Company |
27 | + user *domain.Users | ||
25 | ) | 28 | ) |
26 | if err = transactionContext.StartTransaction(); err != nil { | 29 | if err = transactionContext.StartTransaction(); err != nil { |
27 | return nil, err | 30 | return nil, err |
@@ -30,33 +33,71 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | @@ -30,33 +33,71 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | ||
30 | transactionContext.RollbackTransaction() | 33 | transactionContext.RollbackTransaction() |
31 | }() | 34 | }() |
32 | rsp = &protocol.UserInfoResponse{} | 35 | rsp = &protocol.UserInfoResponse{} |
33 | - if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { | ||
34 | - err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
35 | - return | ||
36 | - } | ||
37 | - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": 1}); err != nil { | ||
38 | - return | 36 | + |
37 | + funcPartnerInfo := func() { | ||
38 | + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { | ||
39 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
40 | + return | ||
41 | + } | ||
42 | + if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { | ||
43 | + return | ||
44 | + } | ||
45 | + rsp.User = protocol.User{ | ||
46 | + Id: partnerInfo.Id, | ||
47 | + PartnerName: partnerInfo.PartnerName, | ||
48 | + Phone: partnerInfo.Account, | ||
49 | + CooperateCompany: protocol.Company{ | ||
50 | + Id: company.Id, | ||
51 | + Name: company.Name, | ||
52 | + Phone: company.Phone, | ||
53 | + }, | ||
54 | + JoinWay: partnerInfo.PartnerCategoryInfo(), | ||
55 | + District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName}, | ||
56 | + SerialNo: partnerInfo.Id, | ||
57 | + CooperateTime: partnerInfo.CooperateTime.Unix() * 1000, | ||
58 | + } | ||
59 | + if len(partnerInfo.Salesman) > 0 { | ||
60 | + rsp.User.Salesman = map[string]interface{}{"uname": partnerInfo.Salesman[0].Name, "phone": partnerInfo.Salesman[0].Telephone} | ||
61 | + } else { | ||
62 | + rsp.User.Salesman = map[string]interface{}{} | ||
63 | + } | ||
39 | } | 64 | } |
40 | - rsp.User = protocol.User{ | ||
41 | - Id: partnerInfo.Id, | ||
42 | - PartnerName: partnerInfo.PartnerName, | ||
43 | - Phone: partnerInfo.Account, | ||
44 | - CooperateCompany: protocol.Company{ | ||
45 | - Id: company.Id, | ||
46 | - Name: company.Name, | ||
47 | - Phone: company.Phone, | ||
48 | - }, | ||
49 | - JoinWay: partnerInfo.PartnerCategoryInfo(), | ||
50 | - District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName}, | ||
51 | - SerialNo: partnerInfo.Id, | ||
52 | - CooperateTime: partnerInfo.CooperateTime.Unix() * 1000, | 65 | + funcManagerInfo := func() { |
66 | + if user, err = UsersRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { | ||
67 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
68 | + return | ||
69 | + } | ||
70 | + if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { | ||
71 | + return | ||
72 | + } | ||
73 | + rsp.User = protocol.User{ | ||
74 | + Id: user.Id, | ||
75 | + PartnerName: user.Name, | ||
76 | + Phone: user.Phone, | ||
77 | + CooperateCompany: protocol.Company{ | ||
78 | + Id: company.Id, | ||
79 | + Name: company.Name, | ||
80 | + Phone: company.Phone, | ||
81 | + }, | ||
82 | + //JoinWay: partnerInfo.PartnerCategoryInfo(), | ||
83 | + //District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName}, | ||
84 | + //SerialNo: partnerInfo.Id, | ||
85 | + //CooperateTime: partnerInfo.CooperateTime.Unix() * 1000, | ||
86 | + } | ||
53 | } | 87 | } |
54 | - if len(partnerInfo.Salesman) > 0 { | ||
55 | - rsp.User.Salesman = map[string]interface{}{"uname": partnerInfo.Salesman[0].Name, "phone": partnerInfo.Salesman[0].Telephone} | ||
56 | - } else { | ||
57 | - rsp.User.Salesman = map[string]interface{}{} | 88 | + switch header.AdminType { |
89 | + case int(protocolx.AdminTypePartner): | ||
90 | + funcPartnerInfo() | ||
91 | + break | ||
92 | + case int(protocolx.AdminTypeManager): | ||
93 | + funcManagerInfo() | ||
94 | + break | ||
95 | + default: | ||
96 | + funcPartnerInfo() | ||
97 | + break | ||
58 | } | 98 | } |
59 | - if imInfo, e := ImInfoRepository.FindOne(map[string]interface{}{"user_id": partnerInfo.Id}); e == nil && imInfo != nil { | 99 | + |
100 | + if imInfo, e := ImInfoRepository.FindOne(map[string]interface{}{"user_id": header.SimNum}); e == nil && imInfo != nil { | ||
60 | rsp.User.ImToken = imInfo.ImToken | 101 | rsp.User.ImToken = imInfo.ImToken |
61 | rsp.User.AccountID, _ = strconv.ParseInt(imInfo.ImId, 10, 64) | 102 | rsp.User.AccountID, _ = strconv.ParseInt(imInfo.ImId, 10, 64) |
62 | rsp.User.CsAccountID = fmt.Sprintf("%v", imInfo.CustomerImId) | 103 | rsp.User.CsAccountID = fmt.Sprintf("%v", imInfo.CustomerImId) |
@@ -221,3 +262,109 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass | @@ -221,3 +262,109 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass | ||
221 | err = transactionContext.CommitTransaction() | 262 | err = transactionContext.CommitTransaction() |
222 | return | 263 | return |
223 | } | 264 | } |
265 | + | ||
266 | +func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp interface{}, err error) { | ||
267 | + var ( | ||
268 | + partnerInfo *domain.PartnerInfo | ||
269 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
270 | + CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext) | ||
271 | + PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | ||
272 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
273 | + company *domain.Company | ||
274 | + user *domain.Users | ||
275 | + ) | ||
276 | + if err = transactionContext.StartTransaction(); err != nil { | ||
277 | + return nil, err | ||
278 | + } | ||
279 | + defer func() { | ||
280 | + transactionContext.RollbackTransaction() | ||
281 | + }() | ||
282 | + rsp = &protocol.UserInfoResponse{} | ||
283 | + | ||
284 | + type xcompany struct { | ||
285 | + Id int64 `json:"id"` | ||
286 | + Name string `json:"name"` | ||
287 | + Phone string `json:"phone"` | ||
288 | + //合作区域 | ||
289 | + District interface{} `json:"district"` | ||
290 | + //合作编码 | ||
291 | + SerialNo int64 `json:"serialNo"` | ||
292 | + //合作时间 | ||
293 | + CooperateTime int64 `json:"cooperationTime"` | ||
294 | + Salesman interface{} `json:"salesman"` | ||
295 | + } | ||
296 | + type xuser struct { | ||
297 | + Id int64 `json:"uid"` | ||
298 | + //用户名称 | ||
299 | + PartnerName string `json:"uname"` | ||
300 | + //手机号 | ||
301 | + Phone string `json:"phone"` | ||
302 | + //合作公司 | ||
303 | + CooperateCompany xcompany `json:"company"` | ||
304 | + } | ||
305 | + rspMap := make(map[string]interface{}) | ||
306 | + funcPartnerInfo := func() { | ||
307 | + if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { | ||
308 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
309 | + return | ||
310 | + } | ||
311 | + if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { | ||
312 | + return | ||
313 | + } | ||
314 | + | ||
315 | + u := xuser{ | ||
316 | + Id: partnerInfo.Id, | ||
317 | + PartnerName: partnerInfo.PartnerName, | ||
318 | + Phone: partnerInfo.Account, | ||
319 | + CooperateCompany: xcompany{ | ||
320 | + Id: company.Id, | ||
321 | + Name: company.Name, | ||
322 | + Phone: company.Phone, | ||
323 | + SerialNo: partnerInfo.Id, | ||
324 | + CooperateTime: partnerInfo.CooperateTime.Unix() * 1000, | ||
325 | + //JoinWay: partnerInfo.PartnerCategoryInfo(), | ||
326 | + District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName}, | ||
327 | + }, | ||
328 | + } | ||
329 | + if len(partnerInfo.Salesman) > 0 { | ||
330 | + u.CooperateCompany.Salesman = map[string]interface{}{"uname": partnerInfo.Salesman[0].Name, "phone": partnerInfo.Salesman[0].Telephone} | ||
331 | + } else { | ||
332 | + u.CooperateCompany.Salesman = map[string]interface{}{} | ||
333 | + } | ||
334 | + rspMap["User"] = u | ||
335 | + rsp = rspMap | ||
336 | + } | ||
337 | + funcManagerInfo := func() { | ||
338 | + if user, err = UsersRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { | ||
339 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
340 | + return | ||
341 | + } | ||
342 | + if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { | ||
343 | + return | ||
344 | + } | ||
345 | + rspMap["User"] = xuser{ | ||
346 | + Id: user.Id, | ||
347 | + PartnerName: user.Name, | ||
348 | + Phone: user.Phone, | ||
349 | + CooperateCompany: xcompany{ | ||
350 | + Id: company.Id, | ||
351 | + Name: company.Name, | ||
352 | + Phone: company.Phone, | ||
353 | + }, | ||
354 | + } | ||
355 | + rsp = rspMap | ||
356 | + } | ||
357 | + switch header.AdminType { | ||
358 | + case int(protocolx.AdminTypePartner): | ||
359 | + funcPartnerInfo() | ||
360 | + break | ||
361 | + case int(protocolx.AdminTypeManager): | ||
362 | + funcManagerInfo() | ||
363 | + break | ||
364 | + default: | ||
365 | + funcPartnerInfo() | ||
366 | + break | ||
367 | + } | ||
368 | + err = transactionContext.CommitTransaction() | ||
369 | + return | ||
370 | +} |
@@ -25,9 +25,11 @@ func ParseJWTToken(token string) (*UserTokenClaims, error) { | @@ -25,9 +25,11 @@ func ParseJWTToken(token string) (*UserTokenClaims, error) { | ||
25 | } | 25 | } |
26 | if tokenClaims != nil { | 26 | if tokenClaims != nil { |
27 | if claim, ok := tokenClaims.Claims.(*UserTokenClaims); ok && tokenClaims.Valid { | 27 | if claim, ok := tokenClaims.Claims.(*UserTokenClaims); ok && tokenClaims.Valid { |
28 | - // TODO:多类型用户登录 | ||
29 | - claim.CompanyId = 1 | ||
30 | - claim.AdminType = 1 | 28 | + // TODO:版本兼容 |
29 | + //if claim.CompanyId==0{ | ||
30 | + // claim.CompanyId = 1 | ||
31 | + // claim.AdminType = 1 | ||
32 | + //} | ||
31 | return claim, nil | 33 | return claim, nil |
32 | } | 34 | } |
33 | } | 35 | } |
@@ -82,6 +82,7 @@ func (this *BaseController) GetRequestHeader(ctx *context.Context) *protocol.Req | @@ -82,6 +82,7 @@ func (this *BaseController) GetRequestHeader(ctx *context.Context) *protocol.Req | ||
82 | h.UserId = claim.UserId | 82 | h.UserId = claim.UserId |
83 | h.CompanyId = claim.CompanyId | 83 | h.CompanyId = claim.CompanyId |
84 | h.AdminType = claim.AdminType | 84 | h.AdminType = claim.AdminType |
85 | + h.SimNum, _ = strconv.Atoi(claim.Phone) | ||
85 | } | 86 | } |
86 | } | 87 | } |
87 | return h | 88 | return h |
@@ -151,3 +151,23 @@ func (this *UserController) ChangePassword() { | @@ -151,3 +151,23 @@ func (this *UserController) ChangePassword() { | ||
151 | } | 151 | } |
152 | msg = protocol.NewReturnResponse(data, err) | 152 | msg = protocol.NewReturnResponse(data, err) |
153 | } | 153 | } |
154 | + | ||
155 | +//UserInfo | ||
156 | +//@router /userInfo [post] | ||
157 | +func (this *UserController) UserInfoV2() { | ||
158 | + var msg *protocol.ResponseMessage | ||
159 | + defer func() { | ||
160 | + this.Resp(msg) | ||
161 | + }() | ||
162 | + var request *protocol.UserInfoRequest | ||
163 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
164 | + msg = protocol.BadRequestParam(2) | ||
165 | + return | ||
166 | + } | ||
167 | + if b, m := this.Valid(request); !b { | ||
168 | + msg = m | ||
169 | + return | ||
170 | + } | ||
171 | + header := this.GetRequestHeader(this.Ctx) | ||
172 | + msg = protocol.NewReturnResponse(user.UserInfoV2(header, request)) | ||
173 | +} |
@@ -18,7 +18,8 @@ func CheckJWTToken(ctx *context.Context) { | @@ -18,7 +18,8 @@ func CheckJWTToken(ctx *context.Context) { | ||
18 | strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") || | 18 | strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") || |
19 | strings.HasSuffix(ctx.Request.RequestURI, "smsCode") || | 19 | strings.HasSuffix(ctx.Request.RequestURI, "smsCode") || |
20 | strings.HasSuffix(ctx.Request.RequestURI, "centerCompanys") || | 20 | strings.HasSuffix(ctx.Request.RequestURI, "centerCompanys") || |
21 | - strings.HasSuffix(ctx.Request.RequestURI, "centerCompanys") { | 21 | + strings.HasSuffix(ctx.Request.RequestURI, "companys") || |
22 | + strings.HasSuffix(ctx.Request.RequestURI, "loginV2") { | ||
22 | return | 23 | return |
23 | } | 24 | } |
24 | defer func() { | 25 | defer func() { |
@@ -37,7 +37,8 @@ func init() { | @@ -37,7 +37,8 @@ func init() { | ||
37 | } | 37 | } |
38 | 38 | ||
39 | func InitV2() { | 39 | func InitV2() { |
40 | - nsV2 := beego.NewNamespace("v2") // , beego.NSBefore(middleware.CheckJWTToken) | 40 | + nsV2 := beego.NewNamespace("v2", beego.NSBefore(middleware.CheckJWTToken)) // , |
41 | nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") | 41 | nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") |
42 | + nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2") | ||
42 | beego.AddNamespace(nsV2) | 43 | beego.AddNamespace(nsV2) |
43 | } | 44 | } |
@@ -13,6 +13,7 @@ type RequestHeader struct { | @@ -13,6 +13,7 @@ type RequestHeader struct { | ||
13 | CompanyId int64 //公司编号 | 13 | CompanyId int64 //公司编号 |
14 | UserId int64 //UserId 唯一标识,(类型是合伙人对应表partner_info.id,类型是高层对应表users.id) | 14 | UserId int64 //UserId 唯一标识,(类型是合伙人对应表partner_info.id,类型是高层对应表users.id) |
15 | AdminType int //合伙人:1 高管:2 | 15 | AdminType int //合伙人:1 高管:2 |
16 | + SimNum int | ||
16 | 17 | ||
17 | requestId string //请求编号 md5 | 18 | requestId string //请求编号 md5 |
18 | reqIndex int64 //请求链序号 | 19 | reqIndex int64 //请求链序号 |
-
请 注册 或 登录 后发表评论