作者 yangfu

修改: 1.用户注销

... ... @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/tiptok/gocomm/xa/eda"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
"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"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event"
... ... @@ -262,6 +263,39 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs
return
}
//注销登录
func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.RevokeResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
user *domain.Users
)
rsp = &protocol.RevokeResponse{}
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil {
log.Error(err)
err = nil
return
}
id, _ := strconv.Atoi(user.Phone)
auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id)))
if !auth.Exist() {
return
}
if err = auth.RemoveAuth(); err != nil {
log.Error(err)
return
}
return
}
func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ...
... ... @@ -244,3 +244,26 @@ func (this *AuthController) LoginV2() {
}
msg = protocol.NewReturnResponse(data, err)
}
//Revoke
//@router /ucenter/user/revoke [post]
func (this *AuthController) UCenterRevoke() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
type reqParam struct {
UserId int64 `json:"id"`
}
var request *reqParam
if err := this.JsonUnmarshal(&request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
msg = protocol.NewReturnResponse(auth.UCenterRevoke(nil, request.UserId))
}
... ...
package routers
import (
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/controllers"
)
func init() {
beego.Router("ucenter/user/revoke", &controllers.AuthController{}, "Post:UCenterRevoke")
}
... ...