checkpowerlogic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/entity"
  6. . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service"
  7. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/svc"
  8. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type CheckPowerLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewCheckPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckPowerLogic {
  17. return &CheckPowerLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. // 检查用户权益
  24. func (l *CheckPowerLogic) CheckPower(in *pb.CheckPowerReq) (*pb.Resp, error) {
  25. resp := &pb.Resp{}
  26. if in.Appid == "" {
  27. l.Error(fmt.Sprintf("%+v", in), "无效的参数appid")
  28. return resp, nil
  29. } else if in.FunctionCode == "" {
  30. l.Error(fmt.Sprintf("%+v", in), "无效的参数function_code")
  31. return resp, nil
  32. } else if in.UserId == 0 && in.EntId == 0 && in.EntUserId == 0 {
  33. l.Error(fmt.Sprintf("%+v", in), "无效的参数user_id、ent_id、ent_user_id")
  34. return resp, nil
  35. }
  36. function := Base_function.FindByCode(in.Appid, in.FunctionCode)
  37. if function == nil {
  38. l.Error(fmt.Sprintf("%+v", in), "功能原始表中没有找到该功能")
  39. return resp, nil
  40. }
  41. status, _, _, err := Surplus(in.Appid, in.FunctionCode, in.UserId, in.EntId, in.EntUserId)
  42. resp.Status = status
  43. if err != nil {
  44. l.Error(fmt.Sprintf("%+v", in), err.Error())
  45. }
  46. return resp, nil
  47. }