resempowerlogic.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type ResEmpowerLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewResEmpowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResEmpowerLogic {
  17. return &ResEmpowerLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *ResEmpowerLogic) ResEmpower(req *types.ResEmpowerReq) (resp *types.Resp, err error) {
  24. entUserIds := []int64{}
  25. for _, v := range strings.Split(req.EntUserId, ",") {
  26. entUserIds = append(entUserIds, Int64All(v))
  27. }
  28. r, err := l.svcCtx.ResourceCenterRpc.Empower(context.Background(), &pb.EmpowerReq{
  29. Appid: "10000",
  30. FunctionCode: req.FunctionCode,
  31. EntId: req.EntId,
  32. EntUserId: entUserIds,
  33. })
  34. var status int64
  35. if err != nil {
  36. l.Error(err)
  37. } else {
  38. status = r.Status
  39. }
  40. resp = &types.Resp{
  41. Error_code: 0,
  42. Data: map[string]interface{}{
  43. "status": status,
  44. },
  45. }
  46. return
  47. }