resempowerlogic.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.CancelAllEmpower(context.Background(), &pb.AllEmpowerReq{
  42. Appid: "10000",
  43. FunctionModule: []string{"bi_电销菜单管理"},
  44. EntId: req.EntId,
  45. EntUserId: entUserIds,
  46. })
  47. }
  48. l.svcCtx.UserCenterRpc.WorkDesktopClearUserInfo(context.Background(), &pcpd.WorkDesktopClearUserInfoReq{
  49. PositionId: req.PositionId,
  50. AppId: "10000",
  51. })
  52. var status int64
  53. if err != nil {
  54. l.Error(err)
  55. } else {
  56. status = r.Status
  57. }
  58. resp = &types.BiResp{
  59. Error_code: 0,
  60. Data: map[string]interface{}{
  61. "status": status,
  62. },
  63. }
  64. return
  65. }