From 57e98333cfadf027f68f977119cb2a7925f457c6 Mon Sep 17 00:00:00 2001 From: tiananlin Date: Tue, 26 Aug 2025 15:14:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Learn.Archives.API/Doc?= =?UTF-8?q?kerfiles/Dockerfile-production?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dockerfiles/Dockerfile-production | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Learn.Archives.API/Dockerfiles/Dockerfile-production diff --git a/Learn.Archives.API/Dockerfiles/Dockerfile-production b/Learn.Archives.API/Dockerfiles/Dockerfile-production new file mode 100644 index 0000000..d7599a1 --- /dev/null +++ b/Learn.Archives.API/Dockerfiles/Dockerfile-production @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish +WORKDIR /src +COPY . . +WORKDIR "/src/Learn.Archives.API" +ENV NUGET_XMLDOC_MODE none +RUN dotnet nuget add source --name marking https://gitea.23544.com/api/packages/marking/nuget/index.json +RUN dotnet publish "Learn.Archives.API.csproj" -c Release -o /app + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final +WORKDIR /app +COPY --from=publish /app . +ENV ASPNETCORE_ENVIRONMENT=Production +ENV TZ=Asia/Shanghai +EXPOSE 8080 +ENTRYPOINT ["dotnet", "Learn.Archives.API.dll"] \ No newline at end of file -- 2.40.1 From 87caff02993651dfe47b6231f89c8101cd2e32ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Tue, 11 Nov 2025 18:33:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=AF=B7=E6=B1=82=20?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83API=E7=9A=84=E6=8D=95?= =?UTF-8?q?=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Learn.Archives.Core/Common/OhException.cs | 10 ++++++++++ Learn.Archives.Core/Common/UserCenterService.cs | 15 +++++++++++++-- Learn.Archives.Core/Learn.Archives.Core.csproj | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Learn.Archives.Core/Common/OhException.cs b/Learn.Archives.Core/Common/OhException.cs index 72eca5c..fb36166 100644 --- a/Learn.Archives.Core/Common/OhException.cs +++ b/Learn.Archives.Core/Common/OhException.cs @@ -22,6 +22,16 @@ namespace Learn.Archives.Core.Common throw new OhException(message, code); } /// + /// 抛出 异常 + /// + /// + /// + /// + public static T Error(string message, int code = 500) + { + throw new OhException(message, code); + } + /// /// 抛出 模型校验异常 /// /// diff --git a/Learn.Archives.Core/Common/UserCenterService.cs b/Learn.Archives.Core/Common/UserCenterService.cs index b4f32b1..530c17b 100644 --- a/Learn.Archives.Core/Common/UserCenterService.cs +++ b/Learn.Archives.Core/Common/UserCenterService.cs @@ -71,8 +71,19 @@ namespace Learn.Archives.Core.Common requestMessage.Content = new StringContent(data.ToJson(), Encoding.UTF8, "application/json"); var responseMessage = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead); - var resStr = await responseMessage.Content?.ReadAsStringAsync(); - var res = JsonSerializer.Deserialize>(resStr); + var resStr = string.Empty; + try + { + resStr= await responseMessage?.Content?.ReadAsStringAsync(); + + } + catch (Exception ex) + { + return Oh.Error($"请求用户中心出现异常 {resStr} {ex.Message}"); + } + if(string.IsNullOrEmpty(resStr)) + return Oh.Error($"请求用户中心出现异常 返回了空数据"); + var res = JsonSerializer.Deserialize>(resStr); if (res == null || res.Code != 200) Oh.Error(res.Message, res.Code); return res.Data; diff --git a/Learn.Archives.Core/Learn.Archives.Core.csproj b/Learn.Archives.Core/Learn.Archives.Core.csproj index d41fa79..91ba3a1 100644 --- a/Learn.Archives.Core/Learn.Archives.Core.csproj +++ b/Learn.Archives.Core/Learn.Archives.Core.csproj @@ -28,6 +28,6 @@ - + -- 2.40.1