作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !71
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
... ... @@ -274,6 +274,7 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
)
rsp = &protocol.RevokeResponse{}
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
}
... ... @@ -286,8 +287,10 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
err = nil
return
}
//注销凭证
userAuth.NewRedisUserCredential(user.Phone).RemoveAuth()
//注销token
id, _ := strconv.Atoi(user.Phone)
auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id)))
... ... @@ -298,6 +301,7 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
log.Error(err)
return
}
err = transactionContext.CommitTransaction()
return
}
... ...
... ... @@ -10,3 +10,5 @@ func CreateTransactionContext(options map[string]interface{}) (*transaction.Tran
PgDd: pg.DB,
}, nil
}
... ...
package user
import (
"encoding/json"
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/auth"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/query"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/service"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/userAuth"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
domain_service_i "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/service"
... ... @@ -132,20 +134,82 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe
transactionContext, _ = factory.CreateTransactionContext(nil)
UserAuthService = CreateUserAuthService(header.AdminType, transactionContext)
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err = UserAuthService.ChangeUserPhone(header.UserId, request.Phone, request.OldPhone); err != nil {
err = protocol.NewCustomMessage(1, err.Error())
return
}
err = transactionContext.CommitTransaction()
return
}
// ChangePhoneAllCompany 修改手机号,强制退出登录
func ChangePhoneAllCompany(header *protocol.RequestHeader, request *protocol.ChangePhoneAllCompanyRequest) (rsp *protocol.ChangePhoneAllCompanyResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
UserAuthService = CreateUserAuthService(header.AdminType, transactionContext)
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if request.Module == "employee" && request.Action == "changePhoneAllCompany" {
var oldPhone string
var newPhone string
var data map[string]interface{}
err := json.Unmarshal([]byte(request.Data), &data)
if err != nil {
return nil, err
}
if value, ok := data["old_phone"]; ok {
oldPhone = value.(string)
}
if value, ok := data["new_phone"]; ok {
newPhone = value.(string)
}
if err = UserAuthService.ChangeUserPhone(header.UserId, newPhone, oldPhone); err != nil {
err = protocol.NewCustomMessage(1, err.Error())
return nil, err
}
//注销凭证
errRemoveAuth := userAuth.NewRedisUserCredential(oldPhone).RemoveAuth()
if errRemoveAuth != nil {
log.Error(err)
return nil, err
}
//注销token
id, _ := strconv.Atoi(oldPhone)
uAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id)))
if !uAuth.Exist() {
return nil, nil
}
if err = uAuth.RemoveAuth(); err != nil {
log.Error(err)
return nil, err
}
}
err = transactionContext.CommitTransaction()
return nil, err
}
//重置密码
func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) {
var (
... ...
不能预览此文件类型
... ... @@ -2,6 +2,7 @@ package service
type UserAuthService interface {
ChangeUserPhone(userId int64, newPhone, oldPhone string) (err error)
ChangeUserPhoneAllCompany(userId int64, newPhone, oldPhone string) (err error)
ChangeUserPassword(userId int64, newPwd, oldPwd, phone string) (err error)
ResetUserPassword(userId int64, phone, password string) (err error)
}
... ...
不能预览此文件类型
... ... @@ -13,6 +13,8 @@ type PgAuthService struct {
partner *PgPartnerAuthService
}
func NewPgAuthService(ctx *transaction.TransactionContext) *PgAuthService {
return &PgAuthService{
manager: NewPgManagerAuthService(ctx),
... ... @@ -20,6 +22,10 @@ func NewPgAuthService(ctx *transaction.TransactionContext) *PgAuthService {
}
}
func (s *PgAuthService) ChangeUserPhoneAllCompany(userId int64, newPhone, oldPhone string) (err error) {
panic("implement me")
}
func (s *PgAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone string) (err error) {
errPartner := s.partner.ChangeUserPhone(userId, newPhone, oldPhone) // 合伙人修改手机号
errManager := s.manager.ChangeUserPhone(userId, newPhone, oldPhone) // 高管修改手机号
... ...
不能预览此文件类型
... ... @@ -53,6 +53,35 @@ func (this *UserController) CheckSmsCode() {
msg = protocol.NewReturnResponse(user.CheckSmsCode(header, request))
}
// ChangePhoneAllCompany TODO 企业平台调用修改手机号
func (this *UserController) ChangePhoneAllCompany() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChangePhoneAllCompanyRequest
header := this.GetRequestHeader(this.Ctx)
if err := this.JsonUnmarshal(&request); err != nil {
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
data, err := user.ChangePhoneAllCompany(header, request)
if err == nil {
msg = protocol.NewResponseMessage(0, "修改手机号成功")
return
}
msg = protocol.NewReturnResponse(data, err)
}
/**
* @Author SteveChan
* @Description //TODO 修改手机号
... ...
... ... @@ -7,4 +7,5 @@ import (
func init() {
beego.Router("ucenter/user/revoke", &controllers.AuthController{}, "Post:UCenterRevoke")
beego.Router("api/business/index", &controllers.UserController{}, "Post:ChangePhoneAllCompany")
}
... ...
... ... @@ -62,6 +62,17 @@ type ChangePhoneRequest struct {
type ChangePhoneResponse struct {
}
type ChangePhoneAllCompanyRequest struct {
// position:职位,department:部门,employee:员工,company:公司,profile员工档案
Module string `json:"module" valid:"Required"`
// add:添加,edit:编辑,delete删除,batchDelete:批量删除,setCompanyCharge:更改公司主管,batchForbid:批量禁用用户,batchRemove:批量更改用户部门,changeAdmin换管理员
Action string `json:"action" valid:"Required"`
// 具体的对象JSON数据
Data string `json:"data" valid:"Required"`
}
type ChangePhoneAllCompanyResponse struct {}
/*ResetPassword */
type ResetPasswordRequest struct {
//Captcha string `json:"captcha" valid:"Required"`
... ...