Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongodb 支持 #152

Merged
merged 51 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fb33250
mongodb support init.
pengqian089 Dec 12, 2023
34929c6
适配mongodb
pengqian089 Dec 13, 2023
34f47ec
修复bug,
pengqian089 Dec 15, 2023
a93d2ad
mongodb存储的是UTC时间,目前改为取出时为 本地时间
pengqian089 Dec 15, 2023
4da4341
添加单元测试
pengqian089 Dec 15, 2023
143a9ce
修复当 主键 属性名不为Id时产生错误的问题
pengqian089 Dec 15, 2023
797c3df
优化过滤器,IRepository Find FindAsync 参数签名改为object,适配SysLog实体int类型的id
pengqian089 Dec 15, 2023
3c4b6fd
补完单元测试
pengqian089 Dec 15, 2023
a1349b8
重构数据访问模块,定义 Repository 层。
Dec 23, 2023
f24e20c
重新实现 Mongodb IRepository
pengqian089 Dec 23, 2023
238a80d
Mongodb Repository Implement
pengqian089 Dec 23, 2023
17bda7d
重构 ConfigService; 重构 FreesqlRepository;
Dec 23, 2023
01ab14a
修复 EnvAccessor 读取 env 的 bug;
Dec 23, 2023
cce74d0
Merge branch 'support-mongodb' into support-mongodb-repository
pengqian089 Dec 25, 2023
c6f6982
移除 Mongodb Service,使用 Mongodb Repository
pengqian089 Dec 25, 2023
5f193ce
修复错误依赖
pengqian089 Dec 25, 2023
8ca3baf
Merge pull request #1 from pengqian089/support-mongodb-repository
pengqian089 Dec 25, 2023
cacf8f4
EventRegister 注入抽象
pengqian089 Dec 25, 2023
b50d583
对 IFreeSqlFactory 接口添加 DeaultFreesqlFactory
Dec 25, 2023
3d67e5b
Merge branch 'support-mongodb' of https://github.com/pengqian089/Agil…
Dec 25, 2023
bcbbd25
Merge pull request #2 from pengqian089/support-mongodb-repository
pengqian089 Dec 26, 2023
a016c48
Service 实现层移除 FreeSql 的依赖,同时适配新的 Repository 层
pengqian089 Dec 26, 2023
e2f8137
Merge pull request #3 from pengqian089/support-mongodb-repository
pengqian089 Dec 26, 2023
85884cf
系统初始化优化
pengqian089 Dec 27, 2023
5428e92
Merge pull request #4 from pengqian089/support-mongodb-repository
pengqian089 Dec 27, 2023
e37858c
修复在 freesql 下的一些问题。配置的该删除基本能用。
Jan 2, 2024
4a6d8ee
Refactor ConfigService;
kklldog Jan 3, 2024
cb3529c
Refactor Freesql repositories;
kklldog Jan 3, 2024
ecc0064
adapt to different environment configurations of mongodb
pengqian089 Jan 5, 2024
625b7d4
修复相关bug,重构 EventRegister 相关内容。
Jan 6, 2024
7b453e5
重构 EventRegisterService
Jan 6, 2024
7057e50
实现 Unitofwork 模式来适配事务
Jan 6, 2024
304c906
Refactor FreesqlUow
Jan 6, 2024
abedae3
Refactor freesql respository;
Jan 6, 2024
5e77ba9
mongodb 事务适配;
pengqian089 Jan 6, 2024
462654d
Add more unit test cases;
Jan 7, 2024
7bbc27b
Update master ci file
Jan 7, 2024
0f9c6a1
重构 SystemInitializationService 把环境初始化跟Jwt secret初始化整合到一起;
Jan 7, 2024
eb9a34d
When standalone cluster run action without transaction.
Jan 13, 2024
51805e2
Update AppServiceTests for mysql
Jan 13, 2024
0643deb
Update AppServiceTests for pg
Jan 14, 2024
7932587
update AppServiceTests for oracle
Jan 14, 2024
f72f3ca
Update testcases;
Jan 14, 2024
be8b099
Fix ConfigServer test cases on sqlite
Jan 21, 2024
43b1a7d
Update ConfigService test cases for sqlserver
Jan 21, 2024
bf894db
update configservice test cases for mysql
Jan 21, 2024
c3f27df
Update ApiController test cases
Jan 21, 2024
42f546f
Update testcases;
Jan 21, 2024
d5a7dc8
Fix mongodb syslog sorted issue
Jan 21, 2024
a7b96fe
重构 test cases, 统一了 freesql 跟 mongodb 的测试用例;
Jan 21, 2024
6da6f61
测试用例适配 mongodb;
Jan 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/master-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
paths-ignore:
- '**/*.md'
- '**/*.yml'
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build-reactapp:
runs-on: ubuntu-latest
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/master-pr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: master pr ci workflow

on:
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build-reactapp:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/AgileConfig.Server.UI/react-ui-antd
strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- run: npm install
- run: npm run build
build-dotnet:
needs: build-reactapp
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.*
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
51 changes: 50 additions & 1 deletion AgileConfig.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.ServiceT
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.CommonTests", "test\AgileConfig.Server.CommonTests\AgileConfig.Server.CommonTests.csproj", "{70724B0E-7D81-412C-BDA7-747F4845E990}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgileConfig.Server.OIDC", "src\AgileConfig.Server.OIDC\AgileConfig.Server.OIDC.csproj", "{E49A2006-6D07-4434-AEC1-27E356A767AE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.OIDC", "src\AgileConfig.Server.OIDC\AgileConfig.Server.OIDC.csproj", "{E49A2006-6D07-4434-AEC1-27E356A767AE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.Mongodb", "src\AgileConfig.Server.Data.Mongodb\AgileConfig.Server.Data.Mongodb.csproj", "{4803646E-8327-4F69-8BA5-2244CB58BBA2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.Abstraction", "src\AgileConfig.Server.Data.Abstraction\AgileConfig.Server.Data.Abstraction.csproj", "{E8101403-72C9-40FB-BCEE-16ED5C23A495}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.Repository.Freesql", "src\AgileConfig.Server.Data.Repository.Freesql\AgileConfig.Server.Data.Repository.Freesql.csproj", "{955F64CC-9EAC-4563-804D-6E2CF9547357}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.Repository.Mongodb", "src\AgileConfig.Server.Data.Repository.Mongodb\AgileConfig.Server.Data.Repository.Mongodb.csproj", "{C6B7A5A6-7287-4A20-9336-EBE82A5256F1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.Repository.Selector", "src\AgileConfig.Server.Data.Repository.Selector\AgileConfig.Server.Data.Repository.Selector.csproj", "{15089E5A-12E4-4953-BA35-0CBB2B1189C0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.AbstractionTests", "test\AgileConfig.Server.Data.AbstractionTests\AgileConfig.Server.Data.AbstractionTests.csproj", "{964F5F7A-3BBD-47B3-8C28-EC16B1038A5A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgileConfig.Server.Data.FreesqlTests", "test\AgileConfig.Server.Data.FreesqlTests\AgileConfig.Server.Data.FreesqlTests.csproj", "{AC7E4D24-D5E8-4E30-BFB0-5DDC581CB0C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -88,6 +102,34 @@ Global
{E49A2006-6D07-4434-AEC1-27E356A767AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E49A2006-6D07-4434-AEC1-27E356A767AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E49A2006-6D07-4434-AEC1-27E356A767AE}.Release|Any CPU.Build.0 = Release|Any CPU
{4803646E-8327-4F69-8BA5-2244CB58BBA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4803646E-8327-4F69-8BA5-2244CB58BBA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4803646E-8327-4F69-8BA5-2244CB58BBA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4803646E-8327-4F69-8BA5-2244CB58BBA2}.Release|Any CPU.Build.0 = Release|Any CPU
{E8101403-72C9-40FB-BCEE-16ED5C23A495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8101403-72C9-40FB-BCEE-16ED5C23A495}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8101403-72C9-40FB-BCEE-16ED5C23A495}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8101403-72C9-40FB-BCEE-16ED5C23A495}.Release|Any CPU.Build.0 = Release|Any CPU
{955F64CC-9EAC-4563-804D-6E2CF9547357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{955F64CC-9EAC-4563-804D-6E2CF9547357}.Debug|Any CPU.Build.0 = Debug|Any CPU
{955F64CC-9EAC-4563-804D-6E2CF9547357}.Release|Any CPU.ActiveCfg = Release|Any CPU
{955F64CC-9EAC-4563-804D-6E2CF9547357}.Release|Any CPU.Build.0 = Release|Any CPU
{C6B7A5A6-7287-4A20-9336-EBE82A5256F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6B7A5A6-7287-4A20-9336-EBE82A5256F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6B7A5A6-7287-4A20-9336-EBE82A5256F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6B7A5A6-7287-4A20-9336-EBE82A5256F1}.Release|Any CPU.Build.0 = Release|Any CPU
{15089E5A-12E4-4953-BA35-0CBB2B1189C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15089E5A-12E4-4953-BA35-0CBB2B1189C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15089E5A-12E4-4953-BA35-0CBB2B1189C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15089E5A-12E4-4953-BA35-0CBB2B1189C0}.Release|Any CPU.Build.0 = Release|Any CPU
{964F5F7A-3BBD-47B3-8C28-EC16B1038A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{964F5F7A-3BBD-47B3-8C28-EC16B1038A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{964F5F7A-3BBD-47B3-8C28-EC16B1038A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{964F5F7A-3BBD-47B3-8C28-EC16B1038A5A}.Release|Any CPU.Build.0 = Release|Any CPU
{AC7E4D24-D5E8-4E30-BFB0-5DDC581CB0C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC7E4D24-D5E8-4E30-BFB0-5DDC581CB0C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC7E4D24-D5E8-4E30-BFB0-5DDC581CB0C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC7E4D24-D5E8-4E30-BFB0-5DDC581CB0C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -104,6 +146,13 @@ Global
{8CE2DB53-3A35-4991-A419-0EC12B001F59} = {F277EC27-8C0E-4490-9645-F5F3244F9246}
{70724B0E-7D81-412C-BDA7-747F4845E990} = {F277EC27-8C0E-4490-9645-F5F3244F9246}
{E49A2006-6D07-4434-AEC1-27E356A767AE} = {1D2FD643-CB85-40F9-BC8A-CE4A39E9F43E}
{4803646E-8327-4F69-8BA5-2244CB58BBA2} = {1D2FD643-CB85-40F9-BC8A-CE4A39E9F43E}
{E8101403-72C9-40FB-BCEE-16ED5C23A495} = {1D2FD643-CB85-40F9-BC8A-CE4A39E9F43E}
{955F64CC-9EAC-4563-804D-6E2CF9547357} = {1D2FD643-CB85-40F9-BC8A-CE4A39E9F43E}
{C6B7A5A6-7287-4A20-9336-EBE82A5256F1} = {1D2FD643-CB85-40F9-BC8A-CE4A39E9F43E}
{15089E5A-12E4-4953-BA35-0CBB2B1189C0} = {1D2FD643-CB85-40F9-BC8A-CE4A39E9F43E}
{964F5F7A-3BBD-47B3-8C28-EC16B1038A5A} = {F277EC27-8C0E-4490-9645-F5F3244F9246}
{AC7E4D24-D5E8-4E30-BFB0-5DDC581CB0C2} = {F277EC27-8C0E-4490-9645-F5F3244F9246}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7F10DB58-5B6F-4EAC-994F-14E8046B306F}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AgileConfig.Server.Data.Abstraction\AgileConfig.Server.Data.Abstraction.csproj" />
<ProjectReference Include="..\AgileConfig.Server.Data.Repository.Freesql\AgileConfig.Server.Data.Repository.Freesql.csproj" />
<ProjectReference Include="..\AgileConfig.Server.Data.Repository.Mongodb\AgileConfig.Server.Data.Repository.Mongodb.csproj" />
<ProjectReference Include="..\Agile.Config.Protocol\Agile.Config.Protocol.csproj" />
<ProjectReference Include="..\AgileConfig.Server.Data.Entity\AgileConfig.Server.Data.Entity.csproj" />
<ProjectReference Include="..\AgileConfig.Server.Data.Freesql\AgileConfig.Server.Data.Freesql.csproj" />
<ProjectReference Include="..\AgileConfig.Server.Data.Repository.Selector\AgileConfig.Server.Data.Repository.Selector.csproj" />
<ProjectReference Include="..\AgileConfig.Server.OIDC\AgileConfig.Server.OIDC.csproj" />
<ProjectReference Include="..\AgileConfig.Server.Service\AgileConfig.Server.Service.csproj" />
</ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions src/AgileConfig.Server.Apisite/ConfigureJwtBearerOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Text;
using AgileConfig.Server.IService;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;

namespace AgileConfig.Server.Apisite;

public class ConfigureJwtBearerOptions(
IJwtService jwtService) : IConfigureNamedOptions<JwtBearerOptions>
{
public void Configure(JwtBearerOptions options)
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = jwtService.Issuer,
ValidAudience = jwtService.Audience,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtService.GetSecurityKey())),
};
}

public void Configure(string name, JwtBearerOptions options)
{
Configure(options);
}
}
25 changes: 13 additions & 12 deletions src/AgileConfig.Server.Apisite/Controllers/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<IActionResult> Search(string name, string id, string group, st
{
query = query.Where(x => x.Group == group).ToList();
}

var appvms = new List<AppListVM>();
foreach (var app in query)
{
Expand All @@ -78,7 +78,7 @@ public async Task<IActionResult> Search(string name, string id, string group, st
}
}

if (children.Count>0)
if (children.Count > 0)
{
first.children = children;
}
Expand All @@ -87,10 +87,10 @@ public async Task<IActionResult> Search(string name, string id, string group, st

appvms = appGroupList;
}

if (tableGrouped)
{
if ( sortField == "group" && ascOrDesc.StartsWith("desc"))
if (sortField == "group" && ascOrDesc.StartsWith("desc"))
{
appvms = appvms.OrderByDescending(x => x.Group).ToList();
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public async Task<IActionResult> Search(string name, string id, string group, st
}
}
}

var count = appvms.Count;
var pageList = appvms.ToList().Skip((current - 1) * pageSize).Take(pageSize).ToList();
await AppendInheritancedInfo(pageList);
Expand All @@ -158,7 +158,7 @@ public async Task<IActionResult> Search(string name, string id, string group, st
total = count,
data = pageList
});
}
}

private async Task<AppListVM> AppToListVM(App item, bool appendInheritancedInfo)
{
Expand Down Expand Up @@ -203,13 +203,13 @@ private async Task AppendInheritancedInfo(List<AppListVM> list)
? new List<string>()
: (inheritancedApps).Select(ia => ia.Name).ToList();
appListVm.AppAdminName = (await _userService.GetUserAsync(appListVm.AppAdmin))?.UserName;
if (appListVm.children!=null)
if (appListVm.children != null)
{
await AppendInheritancedInfo(appListVm.children);
}
}
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "App.Add", Functions.App_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] AppVM model)
Expand Down Expand Up @@ -309,7 +309,7 @@ public async Task<IActionResult> Edit([FromBody] AppVM model)
app.Type = model.Inheritanced ? AppType.Inheritance : AppType.PRIVATE;
app.AppAdmin = model.AppAdmin;
app.Group = model.Group;

var inheritanceApps = new List<AppInheritanced>();
if (!model.Inheritanced && model.inheritancedApps != null)
{
Expand Down Expand Up @@ -546,7 +546,7 @@ public async Task<IActionResult> GetUserAppAuth(string appId)
{
AppId = appId
};
result.EditConfigPermissionUsers = (await _appService.GetUserAppAuth(appId, _premissionService.EditConfigPermissionKey)).Select(x=>x.Id).ToList();
result.EditConfigPermissionUsers = (await _appService.GetUserAppAuth(appId, _premissionService.EditConfigPermissionKey)).Select(x => x.Id).ToList();
result.PublishConfigPermissionUsers = (await _appService.GetUserAppAuth(appId, _premissionService.PublishConfigPermissionKey)).Select(x => x.Id).ToList();

return Json(new
Expand All @@ -557,12 +557,13 @@ public async Task<IActionResult> GetUserAppAuth(string appId)
}

[HttpGet]
public IActionResult GetAppGroups()
public async Task<IActionResult> GetAppGroups()
{
var groups = await _appService.GetAppGroups();
return Json(new
{
success = true,
data = _appService.GetAppGroups().OrderBy(x=>x)
data = groups.OrderBy(x => x)
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public async Task<IActionResult> Publish([FromBody] PublishLogVM model, string e

var appId = model.AppId;
var userId = await this.GetCurrentUserId(_userService);
var ret = _configService.Publish(appId, model.Ids, model.Log, userId, env);
var ret = await _configService.Publish(appId, model.Ids, model.Log, userId, env);

if (ret.result)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public async Task<IActionResult> SearchServerNodeClients(string address, int cur
var nodes = await _serverNodeService.GetAllNodesAsync();
if (string.IsNullOrEmpty(address))
{
addressess.AddRange(nodes.Where(x=>x.Status == NodeStatus.Online).Select(n => n.Address));
addressess.AddRange(nodes.Where(x=>x.Status == NodeStatus.Online).Select(n => n.Id.ToString()));
}
else
{
if (nodes.Any(x=>x.Status == NodeStatus.Online && x.Address.Equals(address, StringComparison.CurrentCultureIgnoreCase)))
if (nodes.Any(x=>x.Status == NodeStatus.Online && x.Id.ToString().Equals(address, StringComparison.CurrentCultureIgnoreCase)))
{
addressess.Add(address);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public async Task<IActionResult> RemoteNodesStatus()
result.Add(new
{
n = serverNode,
server_status = await _remoteServerNodeProxy.GetClientsReportAsync(serverNode.Address)
server_status = await _remoteServerNodeProxy.GetClientsReportAsync(serverNode.Id.ToString())
});
}

Expand Down
23 changes: 17 additions & 6 deletions src/AgileConfig.Server.Apisite/Controllers/ServerNodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ServerNodeController(IServerNodeService serverNodeService,

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "Node.Add", Functions.Node_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody]ServerNodeVM model)
public async Task<IActionResult> Add([FromBody] ServerNodeVM model)
{
if (model == null)
{
Expand All @@ -50,7 +50,7 @@ public async Task<IActionResult> Add([FromBody]ServerNodeVM model)
}

var node = new ServerNode();
node.Address = model.Address.TrimEnd('/');
node.Id = model.Address.TrimEnd('/');
node.Remark = model.Remark;
node.Status = NodeStatus.Offline;
node.CreateTime = DateTime.Now;
Expand All @@ -62,9 +62,9 @@ public async Task<IActionResult> Add([FromBody]ServerNodeVM model)
param.node = node;
param.userName = this.GetCurrentUserName();
TinyEventBus.Instance.Fire(EventKeys.ADD_NODE_SUCCESS, param);
await _remoteServerNodeProxy.TestEchoAsync(node.Address);
await _remoteServerNodeProxy.TestEchoAsync(node.Id);
}

return Json(new
{
data = node,
Expand All @@ -75,7 +75,7 @@ public async Task<IActionResult> Add([FromBody]ServerNodeVM model)

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "Node.Delete", Functions.Node_Delete })]
[HttpPost]
public async Task<IActionResult> Delete([FromBody]ServerNodeVM model)
public async Task<IActionResult> Delete([FromBody] ServerNodeVM model)
{
if (Appsettings.IsPreviewMode)
{
Expand Down Expand Up @@ -120,10 +120,21 @@ public async Task<IActionResult> All()
{
var nodes = await _serverNodeService.GetAllNodesAsync();

var vms = nodes.OrderBy(x => x.CreateTime).Select(x =>
{
return new ServerNodeVM
{
Address = x.Id,
Remark = x.Remark,
LastEchoTime = x.LastEchoTime,
Status = x.Status
};
});

return Json(new
{
success = true,
data = nodes.OrderBy(n => n.CreateTime)
data = vms
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AgileConfig.Server.Apisite/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<IActionResult> Search(string userName, string team, int curren
}

var users = await _userService.GetAll();
users = users.Where(x => x.Status == UserStatus.Normal && x.Id != SettingService.SuperAdminId).ToList();
users = users.Where(x => x.Status == UserStatus.Normal && x.Id != SystemSettings.SuperAdminId).ToList();
if (!string.IsNullOrEmpty(userName))
{
users = users.Where(x => x.UserName != null && x.UserName.Contains(userName)).ToList();
Expand Down Expand Up @@ -264,7 +264,7 @@ public async Task<IActionResult> adminUsers()
public async Task<IActionResult> AllUsers()
{
var users = await _userService.GetAll();
users = users.Where(x => x.Status == UserStatus.Normal && x.Id != SettingService.SuperAdminId).ToList();
users = users.Where(x => x.Status == UserStatus.Normal && x.Id != SystemSettings.SuperAdminId).ToList();

return Json(new
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public async Task<ActionResult<List<ApiConfigVM>>> GetAppConfig(string appId, [F
}

var cacheKey = $"ConfigController_APPCONFIG_{appId}_{env}";
_cacheMemory.TryGetValue(cacheKey, out List<ApiConfigVM> configs);
List<ApiConfigVM> configs = null;
_cacheMemory?.TryGetValue(cacheKey, out configs);
if (configs != null)
{
return configs;
Expand All @@ -83,7 +84,7 @@ public async Task<ActionResult<List<ApiConfigVM>>> GetAppConfig(string appId, [F
//增加5s的缓存,防止同一个app同时启动造成db的压力过大
var cacheOp = new MemoryCacheEntryOptions()
.SetAbsoluteExpiration(TimeSpan.FromSeconds(5));
_cacheMemory.Set(cacheKey, vms, cacheOp);
_cacheMemory?.Set(cacheKey, vms, cacheOp);

return vms;
}
Expand Down
Loading
Loading