12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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
- if req.ReqType == 1 {
- r, err = l.svcCtx.ResourceCenterRpc.Empower(context.Background(), &pb.EmpowerReq{
- Appid: "10000",
- FunctionCode: req.FunctionCode,
- EntId: req.EntId,
- EntUserId: entUserIds,
- })
- } else if req.ReqType == 2 {
- r, err = l.svcCtx.ResourceCenterRpc.CrReEmpower(context.Background(), &pb.CrReEmpowerReq{
- Appid: "10000",
- FunctionModule: []string{"bi_电销菜单管理"},
- FunctionCode: strings.Split(req.FunctionCode, ","),
- EntId: req.EntId,
- EntUserId: entUserIds,
- })
- } 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
- }
|