正在显示
3 个修改的文件
包含
67 行增加
和
0 行删除
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | "github.com/tiptok/gocomm/xa/eda" | 5 | "github.com/tiptok/gocomm/xa/eda" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" |
7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/userAuth" | ||
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event" |
@@ -262,6 +263,39 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs | @@ -262,6 +263,39 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs | ||
262 | return | 263 | return |
263 | } | 264 | } |
264 | 265 | ||
266 | +//注销登录 | ||
267 | +func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.RevokeResponse, err error) { | ||
268 | + var ( | ||
269 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
270 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
271 | + user *domain.Users | ||
272 | + ) | ||
273 | + | ||
274 | + rsp = &protocol.RevokeResponse{} | ||
275 | + if err = transactionContext.StartTransaction(); err != nil { | ||
276 | + return nil, err | ||
277 | + } | ||
278 | + defer func() { | ||
279 | + transactionContext.RollbackTransaction() | ||
280 | + }() | ||
281 | + | ||
282 | + if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil { | ||
283 | + log.Error(err) | ||
284 | + err = nil | ||
285 | + return | ||
286 | + } | ||
287 | + id, _ := strconv.Atoi(user.Phone) | ||
288 | + auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id))) | ||
289 | + if !auth.Exist() { | ||
290 | + return | ||
291 | + } | ||
292 | + if err = auth.RemoveAuth(); err != nil { | ||
293 | + log.Error(err) | ||
294 | + return | ||
295 | + } | ||
296 | + return | ||
297 | +} | ||
298 | + | ||
265 | func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) { | 299 | func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) { |
266 | var ( | 300 | var ( |
267 | transactionContext, _ = factory.CreateTransactionContext(nil) | 301 | transactionContext, _ = factory.CreateTransactionContext(nil) |
@@ -244,3 +244,26 @@ func (this *AuthController) LoginV2() { | @@ -244,3 +244,26 @@ func (this *AuthController) LoginV2() { | ||
244 | } | 244 | } |
245 | msg = protocol.NewReturnResponse(data, err) | 245 | msg = protocol.NewReturnResponse(data, err) |
246 | } | 246 | } |
247 | + | ||
248 | +//Revoke | ||
249 | +//@router /ucenter/user/revoke [post] | ||
250 | +func (this *AuthController) UCenterRevoke() { | ||
251 | + var msg *protocol.ResponseMessage | ||
252 | + defer func() { | ||
253 | + this.Resp(msg) | ||
254 | + }() | ||
255 | + type reqParam struct { | ||
256 | + UserId int64 `json:"id"` | ||
257 | + } | ||
258 | + var request *reqParam | ||
259 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
260 | + log.Error(err) | ||
261 | + msg = protocol.BadRequestParam(1) | ||
262 | + return | ||
263 | + } | ||
264 | + if b, m := this.Valid(request); !b { | ||
265 | + msg = m | ||
266 | + return | ||
267 | + } | ||
268 | + msg = protocol.NewReturnResponse(auth.UCenterRevoke(nil, request.UserId)) | ||
269 | +} |
pkg/port/appsvr/routers/api_router.go
0 → 100644
-
请 注册 或 登录 后发表评论