Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev
正在显示
4 个修改的文件
包含
110 行增加
和
0 行删除
@@ -467,6 +467,47 @@ func (c *CompanyController) EditCompanyForUCenter() { | @@ -467,6 +467,47 @@ func (c *CompanyController) EditCompanyForUCenter() { | ||
467 | return | 467 | return |
468 | } | 468 | } |
469 | 469 | ||
470 | +//UserChangePhone | ||
471 | +//@router /ucenter/user/changePhone [post] | ||
472 | +func (c *CompanyController) UserChangePhone() { | ||
473 | + var msg *protocol.ResponseMessage | ||
474 | + defer func() { | ||
475 | + c.ResposeJson(msg) | ||
476 | + }() | ||
477 | + type Paremeter struct { | ||
478 | + Ucid int64 `json:"id"` //统一用户中心id | ||
479 | + Phone string `json:"phone"` //新手机号 | ||
480 | + } | ||
481 | + var param Paremeter | ||
482 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
483 | + log.Error("json 解析失败 err:%s", err) | ||
484 | + msg = protocol.BadRequestParam("1") | ||
485 | + return | ||
486 | + } | ||
487 | + data, err := servecompany.ChangePhoneForUCenter(param.Ucid, param.Phone) | ||
488 | + msg = protocol.NewReturnResponse(data, err) | ||
489 | +} | ||
490 | + | ||
491 | +//UserRevoke | ||
492 | +//@router /ucenter/user/uerRevoke [post] | ||
493 | +func (c *CompanyController) UserRevoke() { | ||
494 | + var msg *protocol.ResponseMessage | ||
495 | + defer func() { | ||
496 | + c.ResposeJson(msg) | ||
497 | + }() | ||
498 | + type Paremeter struct { | ||
499 | + Ucid int64 `json:"id"` //统一用户中心id | ||
500 | + } | ||
501 | + var param Paremeter | ||
502 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
503 | + log.Error("json 解析失败 err:%s", err) | ||
504 | + msg = protocol.BadRequestParam("1") | ||
505 | + return | ||
506 | + } | ||
507 | + data, err := servecompany.RevokeForUCenter(param.Ucid) | ||
508 | + msg = protocol.NewReturnResponse(data, err) | ||
509 | +} | ||
510 | + | ||
470 | //获取用户详情 | 511 | //获取用户详情 |
471 | //@router /user/info | 512 | //@router /user/info |
472 | func (c *CompanyController) UserDetail() { | 513 | func (c *CompanyController) UserDetail() { |
@@ -112,3 +112,16 @@ func GetUserAuthByUser(userId int64) (*UserAuth, error) { | @@ -112,3 +112,16 @@ func GetUserAuthByUser(userId int64) (*UserAuth, error) { | ||
112 | } | 112 | } |
113 | return nil, err | 113 | return nil, err |
114 | } | 114 | } |
115 | + | ||
116 | +func GetUserAuthByDeviceTye(userId int64, devType int8) (*UserAuth, error) { | ||
117 | + o := orm.NewOrm() | ||
118 | + uAuth := &UserAuth{ | ||
119 | + UserId: userId, | ||
120 | + DeviceType: devType, | ||
121 | + } | ||
122 | + err := o.Read(uAuth, "UserId", "DeviceType") | ||
123 | + if err == nil { | ||
124 | + return uAuth, nil | ||
125 | + } | ||
126 | + return nil, err | ||
127 | +} |
@@ -105,6 +105,8 @@ func init() { | @@ -105,6 +105,8 @@ func init() { | ||
105 | beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"), | 105 | beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"), |
106 | beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"), | 106 | beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"), |
107 | beego.NSRouter("/company/edit", &controllers.CompanyController{}, "post:EditCompanyForUCenter"), | 107 | beego.NSRouter("/company/edit", &controllers.CompanyController{}, "post:EditCompanyForUCenter"), |
108 | + beego.NSRouter("/user/revoke", &controllers.CompanyController{}, "post:UserRevoke"), | ||
109 | + beego.NSRouter("/user/changePhone", &controllers.CompanyController{}, "post:UserChangePhone"), | ||
108 | ) | 110 | ) |
109 | 111 | ||
110 | beego.AddNamespace(nsV1) | 112 | beego.AddNamespace(nsV1) |
@@ -5,6 +5,8 @@ import ( | @@ -5,6 +5,8 @@ import ( | ||
5 | "oppmg/models" | 5 | "oppmg/models" |
6 | "oppmg/protocol" | 6 | "oppmg/protocol" |
7 | "oppmg/services/ucenter" | 7 | "oppmg/services/ucenter" |
8 | + "oppmg/utils" | ||
9 | + "strings" | ||
8 | "time" | 10 | "time" |
9 | 11 | ||
10 | "github.com/astaxie/beego/orm" | 12 | "github.com/astaxie/beego/orm" |
@@ -488,3 +490,55 @@ func CompanyInfoForUCenter(uCenterid int64) (protocol.ResponseCenterCompany, err | @@ -488,3 +490,55 @@ func CompanyInfoForUCenter(uCenterid int64) (protocol.ResponseCenterCompany, err | ||
488 | } | 490 | } |
489 | return resp, nil | 491 | return resp, nil |
490 | } | 492 | } |
493 | + | ||
494 | +//统一用户中心 修改手机号 | ||
495 | +func ChangePhoneForUCenter(ucid int64, phone string) (rsp interface{}, err error) { | ||
496 | + var ( | ||
497 | + user *models.User | ||
498 | + ) | ||
499 | + if user, err = models.GetUserByUCenter(ucid); err != nil { | ||
500 | + if err == orm.ErrNoRows { | ||
501 | + return rsp, nil | ||
502 | + } | ||
503 | + return nil, protocol.NewErrWithMessage("1") | ||
504 | + } | ||
505 | + if user.Phone == strings.TrimSpace(phone) { | ||
506 | + return | ||
507 | + } | ||
508 | + if err = utils.UpdateTableByMap(user, map[string]interface{}{"Phone": strings.TrimSpace(phone)}); err != nil { | ||
509 | + log.Error(err.Error()) | ||
510 | + return | ||
511 | + } | ||
512 | + return | ||
513 | +} | ||
514 | + | ||
515 | +//统一用户中心 注销手机登录 | ||
516 | +func RevokeForUCenter(ucid int64) (rsp interface{}, err error) { | ||
517 | + var ( | ||
518 | + user *models.User | ||
519 | + userAuth *models.UserAuth | ||
520 | + updateMap = make(map[string]interface{}) | ||
521 | + ) | ||
522 | + if user, err = models.GetUserByUCenter(ucid); err != nil { | ||
523 | + if err == orm.ErrNoRows { | ||
524 | + return rsp, nil | ||
525 | + } | ||
526 | + return nil, protocol.NewErrWithMessage("1") | ||
527 | + } | ||
528 | + if userAuth, err = models.GetUserAuthByDeviceTye(user.Id, 1); err != nil { | ||
529 | + if err == orm.ErrNoRows { | ||
530 | + return rsp, nil | ||
531 | + } | ||
532 | + return nil, protocol.NewErrWithMessage("1") | ||
533 | + } | ||
534 | + { | ||
535 | + updateMap["AccessToken"] = "" | ||
536 | + updateMap["RefreshToken"] = "" | ||
537 | + updateMap["AuthCode"] = "" | ||
538 | + } | ||
539 | + if err = utils.UpdateTableByMap(userAuth, updateMap); err != nil { | ||
540 | + log.Error(err.Error()) | ||
541 | + return | ||
542 | + } | ||
543 | + return | ||
544 | +} |
-
请 注册 或 登录 后发表评论