pcm-ac/internal/logic/filecontentlogic.go

42 lines
1.2 KiB
Go

package logic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
"gitlink.org.cn/JointCloud/pcm-ac/internal/pkg/utils"
"gitlink.org.cn/JointCloud/pcm-ac/internal/pkg/utils/httputils"
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
)
type FileContentLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewFileContentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FileContentLogic {
return &FileContentLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// FileContent 查看文件内容
func (l *FileContentLogic) FileContent(in *hpcAC.FileDataReq) (*hpcAC.FileContentResp, error) {
var resp hpcAC.FileContentResp
url := "/hpc/openapi/v2/file/content"
triggerNum := strconv.FormatInt(int64(in.TriggerNum), 10)
queryParams := map[string]string{
"hostName": in.HostName,
"dirPath": in.DirPath,
"triggerNum": triggerNum,
"rollDirection": in.RollDirection,
}
_, _ = utils.Post("", l.svcCtx.Config.ClusterUrl, url, httputils.ApplicationFromUrlencoded, nil, nil, nil, nil, &queryParams, &resp)
return &resp, nil
}