123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package logic
- import (
- "context"
- "fmt"
- "bp.jydev.jianyu360.cn/BaseService/resourceCenter/api/internal/svc"
- "bp.jydev.jianyu360.cn/BaseService/resourceCenter/api/internal/types"
- . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type SurplusDetailLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewSurplusDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SurplusDetailLogic {
- return &SurplusDetailLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- //资源剩余详情
- func (l *SurplusDetailLogic) SurplusDetail(req *types.SurplusReq) (resp *types.Reply, err error) {
- resp = &types.Reply{}
- if req.AppId == "" {
- resp.Error_msg = "无效的参数appid"
- l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
- return resp, nil
- } else if req.Function_code == "" {
- resp.Error_msg = "无效的参数function_code"
- l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
- return resp, nil
- } else if req.User_id == 0 && req.Ent_id == 0 && req.Ent_user_id == 0 {
- resp.Error_msg = "无效的参数user_id、ent_id、ent_user_id"
- l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
- return resp, nil
- }
- status, total, surplus, err := Surplus(req.AppId, req.Function_code, req.User_id, req.Ent_id, req.Ent_user_id)
- if err != nil {
- resp.Error_msg = err.Error()
- l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
- }
- resp.Error_code = status
- resp.Data = &types.SurplusData{
- Total: total,
- Surplus: surplus,
- }
- return
- }
|