Commit 9bfb58b7 authored by Bess严根旺's avatar Bess严根旺

修改回调参数

parent 4db8b892
......@@ -101,6 +101,7 @@ type BackData struct {
ID int `json:"id"`
Msg string `json:"msg"`
Status int8 `json:"status"`
Url string `json:"url"`
}
type CallBackData struct {
......@@ -154,6 +155,7 @@ func callBackUrl(c context.Context, projectId int32) (bool, string) {
data.ID = id
data.Msg = projectInfo.CallbackRes
data.Status = 0
data.Url = *projectInfo.TargetURL
// 将结构体转换为 JSON 格式
jsonData, _ := json.Marshal(data)
headers := map[string]string{
......
......@@ -76,14 +76,6 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi
resp.Msg = "SourceType 不能为空"
return resp, err
}
if req.TargetType == "" {
resp.Msg = "TargetType 不能为空"
return resp, err
}
if req.TargetUrl == "" {
resp.Msg = "TargetUrl 不能为空"
return resp, err
}
if req.CallbackUrl == "" {
resp.Msg = "CallbackUrl 不能为空"
return resp, err
......@@ -93,12 +85,27 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi
return resp, err
}
if req.TargetType == "" {
req.TargetType = "pdf"
}
if req.TargetUrl == "" {
dotIndex := strings.LastIndex(req.SourceUrl, ".")
if dotIndex != -1 {
// 从点的位置开始,替换后面的所有字符为指定字符串
req.TargetUrl = req.SourceUrl[:dotIndex+1] + "pdf"
} else {
resp.Msg = "SourceUrl 不合法"
return resp, err
}
}
jsonCallBackData, _ := json.Marshal(CallBackData)
request := &service.DoConversionRequest{
ProjectName: req.ProjectName,
SourceType: req.SourceType,
TargetType: req.TargetType,
SourceURI: req.SourceUrl,
TargetType: req.TargetType,
TargetURI: req.TargetUrl,
IsPrivate: req.IsPrivate,
CallbackData: string(jsonCallBackData),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment