正在显示
7 个修改的文件
包含
53 行增加
和
5 行删除
@@ -8,8 +8,6 @@ import ( | @@ -8,8 +8,6 @@ import ( | ||
8 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg" | 8 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg" |
9 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/redis" | 9 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/redis" |
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/port/sarama" | ||
12 | - | ||
13 | //"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/ginsvr" | 11 | //"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/ginsvr" |
14 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr" | 12 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr" |
15 | ) | 13 | ) |
@@ -26,7 +24,7 @@ func main() { | @@ -26,7 +24,7 @@ func main() { | ||
26 | event.InitEventCenter() | 24 | event.InitEventCenter() |
27 | 25 | ||
28 | //启动kafaka消息订阅 | 26 | //启动kafaka消息订阅 |
29 | - go sarama.Run() | 27 | + //go sarama.Run() |
30 | 28 | ||
31 | beego.Run() | 29 | beego.Run() |
32 | } | 30 | } |
@@ -350,20 +350,24 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -350,20 +350,24 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
350 | imInfo *domain.ImInfo | 350 | imInfo *domain.ImInfo |
351 | loginSvr = domain_service.NewPgLoginService(transactionContext) | 351 | loginSvr = domain_service.NewPgLoginService(transactionContext) |
352 | ) | 352 | ) |
353 | + | ||
353 | phoneId, e := strconv.Atoi(request.Phone) | 354 | phoneId, e := strconv.Atoi(request.Phone) |
354 | if e != nil { | 355 | if e != nil { |
355 | log.Error(e) | 356 | log.Error(e) |
356 | e = protocol.NewErrWithMessage(2) | 357 | e = protocol.NewErrWithMessage(2) |
357 | return | 358 | return |
358 | } | 359 | } |
360 | + | ||
359 | rsp := &protocolx.CenterCompanysResponse{} | 361 | rsp := &protocolx.CenterCompanysResponse{} |
360 | if err = transactionContext.StartTransaction(); err != nil { | 362 | if err = transactionContext.StartTransaction(); err != nil { |
361 | log.Error(err) | 363 | log.Error(err) |
362 | return nil, err | 364 | return nil, err |
363 | } | 365 | } |
366 | + | ||
364 | defer func() { | 367 | defer func() { |
365 | transactionContext.RollbackTransaction() | 368 | transactionContext.RollbackTransaction() |
366 | }() | 369 | }() |
370 | + | ||
367 | // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用) | 371 | // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用) |
368 | if request.GrantType == protocol.LoginBySmsCode { | 372 | if request.GrantType == protocol.LoginBySmsCode { |
369 | e := loginSvr.RegistryGuest(request.Phone) | 373 | e := loginSvr.RegistryGuest(request.Phone) |
@@ -371,22 +375,38 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -371,22 +375,38 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
371 | log.Error(e) | 375 | log.Error(e) |
372 | } | 376 | } |
373 | } | 377 | } |
378 | + | ||
374 | // loginSvr 初始化 | 379 | // loginSvr 初始化 |
375 | loginSvr.Init(request.Phone) | 380 | loginSvr.Init(request.Phone) |
376 | if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { | 381 | if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { |
377 | err = protocol.NewErrWithMessage(10001) | 382 | err = protocol.NewErrWithMessage(10001) |
378 | return | 383 | return |
379 | } | 384 | } |
385 | + | ||
380 | switch request.GrantType { | 386 | switch request.GrantType { |
381 | case protocol.LoginByPassword: | 387 | case protocol.LoginByPassword: |
382 | if len(request.Password) == 0 { | 388 | if len(request.Password) == 0 { |
383 | err = protocol.NewCustomMessage(1, "密码不能为空!") | 389 | err = protocol.NewCustomMessage(1, "密码不能为空!") |
384 | return | 390 | return |
385 | } | 391 | } |
392 | + // 判断是否高管 | ||
393 | + ok, loginErr := loginSvr.CheckIsSenior(request.Phone, 0) | ||
394 | + if loginErr != nil { | ||
395 | + err = protocol.NewErrWithMessage(10001) | ||
396 | + return | ||
397 | + } | ||
398 | + if ok { // 高管 | ||
386 | if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil { | 399 | if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil { |
387 | err = protocol.NewCustomMessage(1, "密码输入有误!") | 400 | err = protocol.NewCustomMessage(1, "密码输入有误!") |
388 | return | 401 | return |
389 | } | 402 | } |
403 | + } else { // 普通用户登录,进入游客页面 | ||
404 | + guestErr := loginSvr.RegistryGuest(request.Phone) | ||
405 | + if guestErr != nil { | ||
406 | + err = protocol.NewCustomMessage(1, "普通用户登录错误") | ||
407 | + return | ||
408 | + } | ||
409 | + } | ||
390 | break | 410 | break |
391 | case protocol.LoginBySmsCode: | 411 | case protocol.LoginBySmsCode: |
392 | if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil { | 412 | if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil { |
@@ -46,6 +46,8 @@ type Users struct { | @@ -46,6 +46,8 @@ type Users struct { | ||
46 | AccessPartners []*PartnerInfo | 46 | AccessPartners []*PartnerInfo |
47 | // 1普通用户 2主管理员 | 47 | // 1普通用户 2主管理员 |
48 | AdminType int8 `json:"adminType"` | 48 | AdminType int8 `json:"adminType"` |
49 | + // 是否高管 | ||
50 | + IsSenior int8 `json:"isSenior"` | ||
49 | } | 51 | } |
50 | 52 | ||
51 | func (Users *Users) AccessPartnerIds() []int64 { | 53 | func (Users *Users) AccessPartnerIds() []int64 { |
@@ -38,6 +38,31 @@ func (svr *PgLoginService) Init(phone string) (err error) { | @@ -38,6 +38,31 @@ func (svr *PgLoginService) Init(phone string) (err error) { | ||
38 | return nil | 38 | return nil |
39 | } | 39 | } |
40 | 40 | ||
41 | +/** | ||
42 | + * @Author SteveChan | ||
43 | + * @Description // 判断是否是高管 | ||
44 | + * @Date 10:44 2021/1/12 | ||
45 | + * @Param | ||
46 | + * @return | ||
47 | + **/ | ||
48 | +func (svr *PgLoginService) CheckIsSenior(phone string, companyId int64) (ok bool, err error) { | ||
49 | + var ( | ||
50 | + UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext) | ||
51 | + ) | ||
52 | + svr.Phone = phone | ||
53 | + user, err := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "status": 1}) | ||
54 | + if err != nil { | ||
55 | + return false, err | ||
56 | + } else { | ||
57 | + if user.IsSenior == 1 { | ||
58 | + ok = true | ||
59 | + } else if user.IsSenior == 2 { | ||
60 | + ok = false | ||
61 | + } | ||
62 | + } | ||
63 | + return ok, nil | ||
64 | +} | ||
65 | + | ||
41 | //合伙人登录 | 66 | //合伙人登录 |
42 | func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) { | 67 | func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) { |
43 | if len(svr.PartnerInfo) == 0 { | 68 | if len(svr.PartnerInfo) == 0 { |
@@ -173,6 +198,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { | @@ -173,6 +198,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { | ||
173 | response["companys"] = companys | 198 | response["companys"] = companys |
174 | return response, nil | 199 | return response, nil |
175 | } | 200 | } |
201 | + | ||
176 | func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { | 202 | func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { |
177 | response := make(map[string]interface{}) | 203 | response := make(map[string]interface{}) |
178 | response["id"] = protocolx.AdminTypeManager | 204 | response["id"] = protocolx.AdminTypeManager |
-
请 注册 或 登录 后发表评论