perf: 优化返回处理

main
SongWJ 6 months ago
parent bd909b0f94
commit 242df37f27

@ -69,12 +69,15 @@ public class LocalMode
} }
var deeplResp = JsonConvert.DeserializeObject<DeepLResponse>(responseBody); var deeplResp = JsonConvert.DeserializeObject<DeepLResponse>(responseBody);
var response = new Response var response = new Response
{ {
Code = resp.StatusCode.GetHashCode(), Code = resp.StatusCode.GetHashCode()
Data = deeplResp?.Result?.Texts?.FirstOrDefault()?.Text ?? deeplResp?.Error?.Message ?? "Empty Response"
}; };
string defaultMessage = resp.StatusCode == System.Net.HttpStatusCode.OK ? "Empty Result" : "Empty Error Message";
response.Data = deeplResp?.Result?.Texts?.FirstOrDefault()?.Text ?? deeplResp?.Error?.Message ?? defaultMessage;
return JsonConvert.SerializeObject(response); return JsonConvert.SerializeObject(response);
} }

Loading…
Cancel
Save