60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/internal/common"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
|
|
"log"
|
|
)
|
|
|
|
type DeleteTaskAiLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
const (
|
|
ContentType = "Content-Type"
|
|
ApplicationFromUrlencoded = "application/x-www-from-urlencoded"
|
|
)
|
|
|
|
func NewDeleteTaskAiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTaskAiLogic {
|
|
return &DeleteTaskAiLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *DeleteTaskAiLogic) DeleteTaskAi(in *hpcAC.DeleteTaskAiReq) (*hpcAC.DeleteTaskAiResp, error) {
|
|
resp := &hpcAC.DeleteTaskAiResp{}
|
|
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.AiConf.DeleteTaskAi
|
|
|
|
token := common.GetToken()
|
|
if token == "" {
|
|
log.Println("获取token失败")
|
|
return nil, errors.New("获取token失败")
|
|
}
|
|
|
|
formData := map[string]string{
|
|
"ids": in.Ids,
|
|
}
|
|
|
|
req := common.GetRestyRequest(3)
|
|
_, err := req.
|
|
SetHeader("token", token).
|
|
SetHeader(ContentType, ApplicationFromUrlencoded).
|
|
SetFormData(formData).
|
|
SetResult(resp).
|
|
Delete(reqUrl)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|