resempowerlogic.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package logic
  2. import (
  3. "context"
  4. "strings"
  5. . "app.yhyue.com/moapp/jybase/common"
  6. "bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
  7. "bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
  8. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
  9. pcpd "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type ResEmpowerLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewResEmpowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResEmpowerLogic {
  18. return &ResEmpowerLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *ResEmpowerLogic) ResEmpower(req *types.ResEmpowerReq) (resp *types.BiResp, err error) {
  25. entUserIds := []int64{}
  26. for _, v := range strings.Split(req.EntUserId, ",") {
  27. entUserIds = append(entUserIds, Int64All(v))
  28. }
  29. var r *pb.Resp
  30. pdReq := &pb.EmpowerReq{
  31. Appid: "10000",
  32. FunctionCode: req.FunctionCode,
  33. EntId: req.EntId,
  34. EntUserId: entUserIds,
  35. }
  36. if req.ReqType == 1 {
  37. r, err = l.svcCtx.ResourceCenterRpc.Empower(context.Background(), pdReq)
  38. } else if req.ReqType == 2 {
  39. r, err = l.svcCtx.ResourceCenterRpc.ReEmpower(context.Background(), pdReq)
  40. } else if req.ReqType == -1 {
  41. r, err = l.svcCtx.ResourceCenterRpc.CancelEmpower(context.Background(), pdReq)
  42. }
  43. l.svcCtx.UserCenterRpc.WorkDesktopClearUserInfo(context.Background(), &pcpd.WorkDesktopClearUserInfoReq{
  44. PositionId: req.PositionId,
  45. AppId: "10000",
  46. })
  47. var status int64
  48. if err != nil {
  49. l.Error(err)
  50. } else {
  51. status = r.Status
  52. }
  53. resp = &types.BiResp{
  54. Error_code: 0,
  55. Data: map[string]interface{}{
  56. "status": status,
  57. },
  58. }
  59. return
  60. }