resempowerlogic.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.BiResp, err error) {
  24. entUserIds := []int64{}
  25. for _, v := range strings.Split(req.EntUserId, ",") {
  26. entUserIds = append(entUserIds, Int64All(v))
  27. }
  28. var r *pb.Resp
  29. if req.ReqType == 1 {
  30. r, err = l.svcCtx.ResourceCenterRpc.Empower(context.Background(), &pb.EmpowerReq{
  31. Appid: "10000",
  32. FunctionCode: req.FunctionCode,
  33. EntId: req.EntId,
  34. EntUserId: entUserIds,
  35. })
  36. } else {
  37. r, err = l.svcCtx.ResourceCenterRpc.CancelEmpower(context.Background(), &pb.EmpowerReq{
  38. Appid: "10000",
  39. FunctionCode: req.FunctionCode,
  40. EntId: req.EntId,
  41. EntUserId: entUserIds,
  42. })
  43. }
  44. var status int64
  45. if err != nil {
  46. l.Error(err)
  47. } else {
  48. status = r.Status
  49. }
  50. resp = &types.BiResp{
  51. Error_code: 0,
  52. Data: map[string]interface{}{
  53. "status": status,
  54. },
  55. }
  56. return
  57. }