package logic import ( "context" "strings" . "app.yhyue.com/moapp/jybase/common" "bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc" "bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types" "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb" pcpd "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb" "github.com/zeromicro/go-zero/core/logx" ) type ResEmpowerLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewResEmpowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResEmpowerLogic { return &ResEmpowerLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *ResEmpowerLogic) ResEmpower(req *types.ResEmpowerReq) (resp *types.BiResp, err error) { entUserIds := []int64{} for _, v := range strings.Split(req.EntUserId, ",") { entUserIds = append(entUserIds, Int64All(v)) } var r *pb.Resp pdReq := &pb.EmpowerReq{ Appid: "10000", FunctionCode: req.FunctionCode, EntId: req.EntId, EntUserId: entUserIds, } if req.ReqType == 1 { r, err = l.svcCtx.ResourceCenterRpc.Empower(context.Background(), pdReq) } else if req.ReqType == 2 { r, err = l.svcCtx.ResourceCenterRpc.ReEmpower(context.Background(), pdReq) } else if req.ReqType == -1 { r, err = l.svcCtx.ResourceCenterRpc.CancelAllEmpower(context.Background(), &pb.AllEmpowerReq{ Appid: "10000", FunctionModule: []string{"bi_电销菜单管理"}, EntId: req.EntId, EntUserId: entUserIds, }) } l.svcCtx.UserCenterRpc.WorkDesktopClearUserInfo(context.Background(), &pcpd.WorkDesktopClearUserInfoReq{ PositionId: req.PositionId, AppId: "10000", }) var status int64 if err != nil { l.Error(err) } else { status = r.Status } resp = &types.BiResp{ Error_code: 0, Data: map[string]interface{}{ "status": status, }, } return }