diff --git a/Apimanager_backend/Controllers/SystemConfigController.cs b/Apimanager_backend/Controllers/SystemConfigController.cs index 74b915e..95cc50b 100644 --- a/Apimanager_backend/Controllers/SystemConfigController.cs +++ b/Apimanager_backend/Controllers/SystemConfigController.cs @@ -1,4 +1,4 @@ -using Apimanager_backend.Dtos; +using Apimanager_backend.Dtos; using Apimanager_backend.Exceptions; using Apimanager_backend.Models; using Apimanager_backend.Services; @@ -60,5 +60,27 @@ namespace Apimanager_backend.Controllers } } + + [HttpGet] + + public async Task?>>> GetAllSystemConfig() + { + try + { + var configInfo = await systemConfigService.GetAllSystemConfig(); + var res = new ResponseBase?>(configInfo); + return Ok(res); + } + catch (BaseException e) + { + var res = new ResponseBase?>( + code: e.code, + message: e.message, + data: null + ); + return NotFound(res); + } + + } } } diff --git a/Apimanager_backend/Dockerfile b/Apimanager_backend/Dockerfile new file mode 100644 index 0000000..500271a --- /dev/null +++ b/Apimanager_backend/Dockerfile @@ -0,0 +1,23 @@ +# 使用微软官方的 .NET 8.0 SDK 镜像作为构建阶段 +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /app + +# 复制项目文件并还原依赖 +COPY *.csproj ./ +RUN dotnet restore + +# 复制项目所有文件并发布(发布到 /app/publish) +COPY . ./ +RUN dotnet publish -c Release -o /app/publish + +# 使用更小的运行时镜像运行发布的应用 +FROM mcr.microsoft.com/dotnet/aspnet:8.0 +WORKDIR /app +COPY --from=build /app/publish ./ + +# 设置环境变量为 Development +ENV ASPNETCORE_ENVIRONMENT=Development +# 声明容器将监听端口 +EXPOSE 8080 +# 容器启动时执行应用 +ENTRYPOINT ["dotnet", "Apimanager_backend.dll"] diff --git a/Apimanager_backend/Program.cs b/Apimanager_backend/Program.cs index e0c8391..0b41235 100644 --- a/Apimanager_backend/Program.cs +++ b/Apimanager_backend/Program.cs @@ -60,7 +60,7 @@ if (app.Environment.IsDevelopment()) app.UseSwaggerUI(); } -app.UseHttpsRedirection(); +//app.UseHttpsRedirection(); app.UseCors("AllowAll"); app.UseAuthentication(); diff --git a/Apimanager_backend/Services/ISystemConfigService.cs b/Apimanager_backend/Services/ISystemConfigService.cs index 29e172c..e72900f 100644 --- a/Apimanager_backend/Services/ISystemConfigService.cs +++ b/Apimanager_backend/Services/ISystemConfigService.cs @@ -6,5 +6,6 @@ namespace Apimanager_backend.Services { public Task UpdateSystemConfig(string configName,string configBody); public Task GetSystemConfig(string configName); + public Task> GetAllSystemConfig(); } } diff --git a/Apimanager_backend/Services/SystemConfigService.cs b/Apimanager_backend/Services/SystemConfigService.cs index 6b5bd49..6be6ffb 100644 --- a/Apimanager_backend/Services/SystemConfigService.cs +++ b/Apimanager_backend/Services/SystemConfigService.cs @@ -36,5 +36,15 @@ namespace Apimanager_backend.Services } return config; } + + public async Task> GetAllSystemConfig() + { + var config = await apiContext.SystemConfigs.ToListAsync(); + if (config == null) + { + throw new BaseException(5006, "配置不存在"); + } + return config; + } } } diff --git a/Apimanager_backend/apimanager.tar b/Apimanager_backend/apimanager.tar new file mode 100644 index 0000000..134ed43 Binary files /dev/null and b/Apimanager_backend/apimanager.tar differ diff --git a/Apimanager_backend/appsettings.json b/Apimanager_backend/appsettings.json index 3f75902..1477a4c 100644 --- a/Apimanager_backend/appsettings.json +++ b/Apimanager_backend/appsettings.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "DefaultConnection": "server=192.168.5.100;username=root;password=768788dyw;port=3306;database=api_billing_system;SslMode=Preferred;" + "DefaultConnection": "server=192.168.5.100;username=root;password=768788Dyw;port=3306;database=api_billing_system;SslMode=Preferred;" }, "JwtSettings": { "Secret": "deXtdXode6hv0SI1o6xRw1ALkn0vYsWn", @@ -17,7 +17,7 @@ "RefreshTokenExpiryDays": 7 }, "redis": { - "ConnectionString": "192.168.5.100:6379" + "ConnectionString": "192.168.5.100:6379,abortConnect=false" }, "EmailSettings": { "Server": "smtp.exmail.qq.com",