disconnectlogic.go 927 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package logic
  2. import (
  3. "context"
  4. "ylink/comm/result"
  5. "ylink/core/auth/rpc/auth"
  6. "ylink/flowsrv/rpc/internal/svc"
  7. "ylink/flowsrv/rpc/pb"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type DisconnectLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewDisconnectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisconnectLogic {
  16. return &DisconnectLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *DisconnectLogic) Disconnect(in *pb.CommandReq) (*pb.CommandResp, error) {
  23. _, err := l.svcCtx.AuthRpc.CheckAuth(l.ctx, &auth.CheckAuthReq{
  24. Type: in.Type,
  25. AccessToken: in.AccessToken,
  26. })
  27. if err != nil {
  28. return &pb.CommandResp{
  29. Code: result.TokenParseError,
  30. Msg: err.Error(),
  31. Data: nil,
  32. }, err
  33. }
  34. // TODO: notify inner service
  35. return &pb.CommandResp{
  36. Code: result.Ok,
  37. Msg: "success",
  38. Data: nil,
  39. }, nil
  40. }