Compare commits
No commits in common. "df5a77ab6fb360168680323fb93f84ea99163da9" and "f728bf4491ed8ea0efc3425c4d1f7716577ab722" have entirely different histories.
df5a77ab6f
...
f728bf4491
@ -1,6 +1,5 @@
|
|||||||
using Apimanager_backend.Dtos;
|
using Apimanager_backend.Dtos;
|
||||||
using Apimanager_backend.Exceptions;
|
using Apimanager_backend.Exceptions;
|
||||||
using Apimanager_backend.Models;
|
|
||||||
using Apimanager_backend.Services;
|
using Apimanager_backend.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@ -146,19 +145,5 @@ namespace Apimanager_backend.Controllers
|
|||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region 获取角色列表
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Roles = "Admin")]
|
|
||||||
public async Task<ActionResult<ResponseBase<List<Models.Role>>>> GetRoles()
|
|
||||||
{
|
|
||||||
//var userRoles = await adminService.GetRolesAsync();
|
|
||||||
var userRoles = new List<Models.Role>() {
|
|
||||||
new Models.Role("管理员","Admin"),
|
|
||||||
new Models.Role("普通用户","User")
|
|
||||||
};
|
|
||||||
var res = new ResponseBase<List<Models.Role>>(userRoles);
|
|
||||||
return Ok(res);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using Apimanager_backend.Dtos;
|
using Apimanager_backend.Dtos;
|
||||||
using Apimanager_backend.Exceptions;
|
using Apimanager_backend.Exceptions;
|
||||||
using Apimanager_backend.Models;
|
using Apimanager_backend.Models;
|
||||||
using Apimanager_backend.Services;
|
using Apimanager_backend.Services;
|
||||||
@ -40,7 +40,7 @@ namespace Apimanager_backend.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
[Authorize(Roles = "User")]
|
||||||
public async Task<ActionResult<ResponseBase<SystemConfig?>>> GetSystemConfig(string configName)
|
public async Task<ActionResult<ResponseBase<SystemConfig?>>> GetSystemConfig(string configName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -60,27 +60,5 @@ namespace Apimanager_backend.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
|
|
||||||
public async Task<ActionResult<ResponseBase<List<SystemConfig>?>>> GetAllSystemConfig()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var configInfo = await systemConfigService.GetAllSystemConfig();
|
|
||||||
var res = new ResponseBase<List<SystemConfig>?>(configInfo);
|
|
||||||
return Ok(res);
|
|
||||||
}
|
|
||||||
catch (BaseException e)
|
|
||||||
{
|
|
||||||
var res = new ResponseBase<List<SystemConfig>?>(
|
|
||||||
code: e.code,
|
|
||||||
message: e.message,
|
|
||||||
data: null
|
|
||||||
);
|
|
||||||
return NotFound(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
# 使用微软官方的 .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"]
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
namespace Apimanager_backend.Models
|
|
||||||
{
|
|
||||||
public class Role
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Value { get; set; }
|
|
||||||
public Role(string name, string value)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
Value = value;
|
|
||||||
}
|
|
||||||
public Role() { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -60,7 +60,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
//app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseCors("AllowAll");
|
app.UseCors("AllowAll");
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|||||||
@ -114,11 +114,5 @@ namespace Apimanager_backend.Services
|
|||||||
return await context.Users.CountAsync();
|
return await context.Users.CountAsync();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region 获取角色列表
|
|
||||||
public async Task<List<UserRole>> GetRolesAsync()
|
|
||||||
{
|
|
||||||
return await context.UserRoles.Where(x => true).Take(10).ToListAsync();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using Apimanager_backend.Dtos;
|
using Apimanager_backend.Dtos;
|
||||||
using Apimanager_backend.Models;
|
|
||||||
|
|
||||||
namespace Apimanager_backend.Services
|
namespace Apimanager_backend.Services
|
||||||
{
|
{
|
||||||
@ -47,10 +46,5 @@ namespace Apimanager_backend.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UserCountAsync();
|
Task<int> UserCountAsync();
|
||||||
/// <summary>
|
|
||||||
/// 获取角色列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<List<UserRole>> GetRolesAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,5 @@ namespace Apimanager_backend.Services
|
|||||||
{
|
{
|
||||||
public Task<SystemConfig> UpdateSystemConfig(string configName,string configBody);
|
public Task<SystemConfig> UpdateSystemConfig(string configName,string configBody);
|
||||||
public Task<SystemConfig> GetSystemConfig(string configName);
|
public Task<SystemConfig> GetSystemConfig(string configName);
|
||||||
public Task<List<SystemConfig>> GetAllSystemConfig();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,15 +36,5 @@ namespace Apimanager_backend.Services
|
|||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<SystemConfig>> GetAllSystemConfig()
|
|
||||||
{
|
|
||||||
var config = await apiContext.SystemConfigs.ToListAsync();
|
|
||||||
if (config == null)
|
|
||||||
{
|
|
||||||
throw new BaseException(5006, "配置不存在");
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"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": {
|
"JwtSettings": {
|
||||||
"Secret": "deXtdXode6hv0SI1o6xRw1ALkn0vYsWn",
|
"Secret": "deXtdXode6hv0SI1o6xRw1ALkn0vYsWn",
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"RefreshTokenExpiryDays": 7
|
"RefreshTokenExpiryDays": 7
|
||||||
},
|
},
|
||||||
"redis": {
|
"redis": {
|
||||||
"ConnectionString": "192.168.5.100:6379,abortConnect=false"
|
"ConnectionString": "192.168.5.100:6379"
|
||||||
},
|
},
|
||||||
"EmailSettings": {
|
"EmailSettings": {
|
||||||
"Server": "smtp.exmail.qq.com",
|
"Server": "smtp.exmail.qq.com",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user