forked from JointCloud/pcm-ac
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/internal/common"
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/internal/pkg/utils/httputils"
|
|
"strconv"
|
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC"
|
|
"gitlink.org.cn/jcce-pcm/pcm-ac/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type QueryUserQuotasLimitLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewQueryUserQuotasLimitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryUserQuotasLimitLogic {
|
|
return &QueryUserQuotasLimitLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// QueryUserQuotasLimit 查询用户资源限制信息
|
|
func (l *QueryUserQuotasLimitLogic) QueryUserQuotasLimit(in *hpcAC.QueueReq) (*hpcAC.UserQuotasLimitResp, error) {
|
|
|
|
resp := &hpcAC.UserQuotasLimitResp{}
|
|
token := common.GetToken()
|
|
jobManagerId := common.GetJobManagerId()
|
|
|
|
quotaUrl := common.HpcCenterUrlPrefix() + l.svcCtx.Config.UserLimitUrl
|
|
|
|
quotaReq := httputils.GetHttpRequest()
|
|
_, err := quotaReq.SetHeader(httputils.ContentType, httputils.ApplicationJson).
|
|
SetHeader("token", token).
|
|
SetQueryString("strJobManagerID=" + strconv.Itoa(jobManagerId)).
|
|
SetResult(resp).
|
|
Get(quotaUrl)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|