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

修改回调参数

parent 4db8b892
...@@ -101,6 +101,7 @@ type BackData struct { ...@@ -101,6 +101,7 @@ type BackData struct {
ID int `json:"id"` ID int `json:"id"`
Msg string `json:"msg"` Msg string `json:"msg"`
Status int8 `json:"status"` Status int8 `json:"status"`
Url string `json:"url"`
} }
type CallBackData struct { type CallBackData struct {
...@@ -154,6 +155,7 @@ func callBackUrl(c context.Context, projectId int32) (bool, string) { ...@@ -154,6 +155,7 @@ func callBackUrl(c context.Context, projectId int32) (bool, string) {
data.ID = id data.ID = id
data.Msg = projectInfo.CallbackRes data.Msg = projectInfo.CallbackRes
data.Status = 0 data.Status = 0
data.Url = *projectInfo.TargetURL
// 将结构体转换为 JSON 格式 // 将结构体转换为 JSON 格式
jsonData, _ := json.Marshal(data) jsonData, _ := json.Marshal(data)
headers := map[string]string{ headers := map[string]string{
......
...@@ -76,14 +76,6 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi ...@@ -76,14 +76,6 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi
resp.Msg = "SourceType 不能为空" resp.Msg = "SourceType 不能为空"
return resp, err return resp, err
} }
if req.TargetType == "" {
resp.Msg = "TargetType 不能为空"
return resp, err
}
if req.TargetUrl == "" {
resp.Msg = "TargetUrl 不能为空"
return resp, err
}
if req.CallbackUrl == "" { if req.CallbackUrl == "" {
resp.Msg = "CallbackUrl 不能为空" resp.Msg = "CallbackUrl 不能为空"
return resp, err return resp, err
...@@ -93,12 +85,27 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi ...@@ -93,12 +85,27 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi
return resp, err 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) jsonCallBackData, _ := json.Marshal(CallBackData)
request := &service.DoConversionRequest{ request := &service.DoConversionRequest{
ProjectName: req.ProjectName, ProjectName: req.ProjectName,
SourceType: req.SourceType, SourceType: req.SourceType,
TargetType: req.TargetType,
SourceURI: req.SourceUrl, SourceURI: req.SourceUrl,
TargetType: req.TargetType,
TargetURI: req.TargetUrl, TargetURI: req.TargetUrl,
IsPrivate: req.IsPrivate, IsPrivate: req.IsPrivate,
CallbackData: string(jsonCallBackData), 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