Skip to content

Commit

Permalink
Correct naming;
Browse files Browse the repository at this point in the history
  • Loading branch information
agile.zhou committed Nov 2, 2024
1 parent 7b9e57a commit 739a6e0
Show file tree
Hide file tree
Showing 18 changed files with 1,687 additions and 739 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Dynamic;
using AgileConfig.Server.Apisite.Utilites;
using AgileConfig.Server.OIDC;
using System.Collections.Generic;
Expand Down
28 changes: 14 additions & 14 deletions src/AgileConfig.Server.Apisite/Controllers/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ namespace AgileConfig.Server.Apisite.Controllers
public class AppController : Controller
{
private readonly IAppService _appService;
private readonly IPremissionService _premissionService;
private readonly IPremissionService _permissionService;
private readonly IUserService _userService;
private readonly ITinyEventBus _tinyEventBus;

public AppController(IAppService appService,
IPremissionService premissionService,
IPremissionService permissionService,
IUserService userService,
ITinyEventBus tinyEventBus)
{
_userService = userService;
_tinyEventBus = tinyEventBus;
_appService = appService;
_premissionService = premissionService;
_permissionService = permissionService;
}

public async Task<IActionResult> Search(string name, string id, string group, string sortField,
Expand Down Expand Up @@ -112,7 +112,7 @@ private async Task AppendInheritancedInfo(List<AppListVM> list)
}
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "App.Add", Functions.App_Add })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "App.Add", Functions.App_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] AppVM model)
{
Expand Down Expand Up @@ -161,7 +161,7 @@ public async Task<IActionResult> Add([FromBody] AppVM model)
});
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "App.Edit", Functions.App_Edit })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "App.Edit", Functions.App_Edit })]
[HttpPost]
public async Task<IActionResult> Edit([FromBody] AppVM model)
{
Expand Down Expand Up @@ -272,10 +272,10 @@ public async Task<IActionResult> Get(string id)
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[TypeFilter(typeof(PremissionCheckAttribute),
Arguments = new object[] { "App.DisableOrEanble", Functions.App_Edit })]
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "App.DisableOrEnable", Functions.App_Edit })]
[HttpPost]
public async Task<IActionResult> DisableOrEanble(string id)
public async Task<IActionResult> DisableOrEnable(string id)
{
ArgumentException.ThrowIfNullOrEmpty(id);

Expand Down Expand Up @@ -305,7 +305,7 @@ public async Task<IActionResult> DisableOrEanble(string id)
});
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "App.Delete", Functions.App_Delete })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "App.Delete", Functions.App_Delete })]
[HttpPost]
public async Task<IActionResult> Delete(string id)
{
Expand Down Expand Up @@ -372,16 +372,16 @@ public async Task<IActionResult> InheritancedApps(string currentAppId)
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "App.Auth", Functions.App_Auth })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "App.Auth", Functions.App_Auth })]
[HttpPost]
public async Task<IActionResult> SaveAppAuth([FromBody] AppAuthVM model)
{
ArgumentNullException.ThrowIfNull(model);

var result = await _appService.SaveUserAppAuth(model.AppId, model.EditConfigPermissionUsers,
_premissionService.EditConfigPermissionKey);
_permissionService.EditConfigPermissionKey);
var result1 = await _appService.SaveUserAppAuth(model.AppId, model.PublishConfigPermissionUsers,
_premissionService.PublishConfigPermissionKey);
_permissionService.PublishConfigPermissionKey);

return Json(new
{
Expand All @@ -399,10 +399,10 @@ public async Task<IActionResult> GetUserAppAuth(string appId)
AppId = appId
};
result.EditConfigPermissionUsers =
(await _appService.GetUserAppAuth(appId, _premissionService.EditConfigPermissionKey)).Select(x => x.Id)
(await _appService.GetUserAppAuth(appId, _permissionService.EditConfigPermissionKey)).Select(x => x.Id)
.ToList();
result.PublishConfigPermissionUsers =
(await _appService.GetUserAppAuth(appId, _premissionService.PublishConfigPermissionKey))
(await _appService.GetUserAppAuth(appId, _permissionService.PublishConfigPermissionKey))
.Select(x => x.Id).ToList();

return Json(new
Expand Down
16 changes: 8 additions & 8 deletions src/AgileConfig.Server.Apisite/Controllers/ConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ITinyEventBus tinyEventBus
_tinyEventBus = tinyEventBus;
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "Config.Add", Functions.Config_Add })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "Config.Add", Functions.Config_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] ConfigVM model, EnvString env)
{
Expand Down Expand Up @@ -94,7 +94,7 @@ public async Task<IActionResult> Add([FromBody] ConfigVM model, EnvString env)
});
}

[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.AddRange", Functions.Config_Add })]
[HttpPost]
public async Task<IActionResult> AddRange([FromBody] List<ConfigVM> model, EnvString env)
Expand Down Expand Up @@ -163,7 +163,7 @@ public async Task<IActionResult> AddRange([FromBody] List<ConfigVM> model, EnvSt
});
}

[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.Edit", Functions.Config_Edit })]
[HttpPost]
public async Task<IActionResult> Edit([FromBody] ConfigVM model, [FromQuery] EnvString env)
Expand Down Expand Up @@ -363,7 +363,7 @@ public async Task<IActionResult> Get(string id, EnvString env)
});
}

[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.Delete", Functions.Config_Delete })]
[HttpPost]
public async Task<IActionResult> Delete(string id, EnvString env)
Expand Down Expand Up @@ -406,7 +406,7 @@ public async Task<IActionResult> Delete(string id, EnvString env)
});
}

[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.DeleteSome", Functions.Config_Delete })]
[HttpPost]
public async Task<IActionResult> DeleteSome([FromBody] List<string> ids, EnvString env)
Expand Down Expand Up @@ -457,7 +457,7 @@ public async Task<IActionResult> DeleteSome([FromBody] List<string> ids, EnvStri
}


[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.Rollback", Functions.Config_Publish })]
[HttpPost]
public async Task<IActionResult> Rollback(string publishTimelineId, EnvString env)
Expand Down Expand Up @@ -516,7 +516,7 @@ public async Task<IActionResult> ConfigPublishedHistory(string configId, EnvStri
/// 发布所有待发布的配置项
/// </summary>
/// <returns></returns>
[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.Publish", Functions.Config_Publish })]
[HttpPost]
public async Task<IActionResult> Publish([FromBody] PublishLogVM model, EnvString env)
Expand Down Expand Up @@ -733,7 +733,7 @@ public async Task<IActionResult> CancelSomeEdit([FromBody] List<string> ids, Env
});
}

[TypeFilter(typeof(PremissionCheckAttribute),
[TypeFilter(typeof(PermissionCheckAttribute),
Arguments = new object[] { "Config.EvnSync", Functions.Config_Add })]
[HttpPost]
public async Task<IActionResult> SyncEnv([FromBody] List<string> toEnvs, [FromQuery] string appId,
Expand Down
6 changes: 3 additions & 3 deletions src/AgileConfig.Server.Apisite/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using System.Linq;
using System.Reflection;
using AgileConfig.Server.Apisite.Utilites;
using AgileConfig.Server.OIDC;

Expand All @@ -19,8 +20,7 @@ public class HomeController : Controller
public HomeController(
ISettingService settingService,
IUserService userService,
IPremissionService permissionService,
IOidcClient oidcClient
IPremissionService permissionService
)
{
_settingService = settingService;
Expand Down Expand Up @@ -76,7 +76,7 @@ public async Task<IActionResult> Current()
[AllowAnonymous]
public async Task<IActionResult> Sys()
{
string appVer = System.Reflection.Assembly.GetAssembly(typeof(AgileConfig.Server.Apisite.Program)).GetName().Version.ToString();
string appVer = Assembly.GetAssembly(typeof(Program))?.GetName()?.Version?.ToString();
string userName = this.GetCurrentUserName();
if (string.IsNullOrEmpty(userName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace AgileConfig.Server.Apisite.Controllers
/// <summary>
/// 这个Controller用来接受其它节点发送过来的命令
/// </summary>
public class RemoteOPController : Controller
public class RemoteOpController : Controller
{
private readonly IConfigService _configService;
private readonly IServiceInfoService _serviceInfoService;
private readonly ILogger _logger;
public RemoteOPController(IConfigService configService,
public RemoteOpController(IConfigService configService,
IServiceInfoService serviceInfoService,
ILoggerFactory loggerFactory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AgileConfig.Server.Apisite.Models;
using AgileConfig.Server.Apisite.Websocket;
using AgileConfig.Server.Common;
using AgileConfig.Server.Data.Entity;
using AgileConfig.Server.IService;
using Microsoft.AspNetCore.Mvc;
Expand Down
4 changes: 2 additions & 2 deletions src/AgileConfig.Server.Apisite/Controllers/SSOController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace AgileConfig.Server.Apisite.Controllers
{
public class SSOController : Controller
public class SsoController : Controller
{
private readonly IOidcClient _oidcClient;

public SSOController(IOidcClient oidcClient)
public SsoController(IOidcClient oidcClient)
{
_oidcClient = oidcClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ITinyEventBus tinyEventBus
_tinyEventBus = tinyEventBus;
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "Node.Add", Functions.Node_Add })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "Node.Add", Functions.Node_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] ServerNodeVM model)
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public async Task<IActionResult> Add([FromBody] ServerNodeVM model)
});
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "Node.Delete", Functions.Node_Delete })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "Node.Delete", Functions.Node_Delete })]
[HttpPost]
public async Task<IActionResult> Delete([FromBody] ServerNodeVM model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<IActionResult> Add([FromBody] ServiceInfoVM model)
{
if (model == null)
{
throw new ArgumentNullException("model");
throw new ArgumentNullException(nameof(model));
}

if ((await _serviceInfoService.GetByServiceIdAsync(model.ServiceId)) != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using AgileConfig.Server.Apisite.Filters;
using AgileConfig.Server.Data.Entity;
using AgileConfig.Server.IService;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -32,10 +31,8 @@ public async Task<IActionResult> Search(string appId, SysLogType? logType, DateT

var pageList = await _sysLogService.SearchPage(appId, logType, startTime, endTime?.Date.AddDays(1), pageSize, current);
var total = await _sysLogService.Count(appId, logType, startTime, endTime?.Date.AddDays(1));
var totalPages = total / pageSize;
if ((total % pageSize) > 0)
{
totalPages++;
}

return Json(new
Expand Down
8 changes: 4 additions & 4 deletions src/AgileConfig.Server.Apisite/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task<IActionResult> Search(string userName, string team, int curren
});
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "User.Add", Functions.User_Add })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "User.Add", Functions.User_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] UserVM model)
{
Expand Down Expand Up @@ -130,7 +130,7 @@ public async Task<IActionResult> Add([FromBody] UserVM model)
});
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "User.Edit", Functions.User_Edit })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "User.Edit", Functions.User_Edit })]
[HttpPost]
public async Task<IActionResult> Edit([FromBody] UserVM model)
{
Expand Down Expand Up @@ -169,7 +169,7 @@ public async Task<IActionResult> Edit([FromBody] UserVM model)

const string DefaultPassword = "123456";

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "User.ResetPassword", Functions.User_Edit })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "User.ResetPassword", Functions.User_Edit })]
[HttpPost]
public async Task<IActionResult> ResetPassword(string userId)
{
Expand Down Expand Up @@ -203,7 +203,7 @@ public async Task<IActionResult> ResetPassword(string userId)
});
}

[TypeFilter(typeof(PremissionCheckAttribute), Arguments = new object[] { "User.Delete", Functions.User_Delete })]
[TypeFilter(typeof(PermissionCheckAttribute), Arguments = new object[] { "User.Delete", Functions.User_Delete })]
[HttpPost]
public async Task<IActionResult> Delete(string userId)
{
Expand Down
10 changes: 5 additions & 5 deletions src/AgileConfig.Server.Apisite/Controllers/api/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task<ActionResult<ApiAppVM>> GetById(string id)
/// <param name="model">应用模型</param>
/// <returns></returns>
[ProducesResponseType(201)]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "App.Add", Functions.App_Add })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "App.Add", Functions.App_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] ApiAppVM model)
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public async Task<IActionResult> Add([FromBody] ApiAppVM model)
/// <param name="model">编辑后的应用模型</param>
/// <returns></returns>
[ProducesResponseType(200)]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "App.Edit", Functions.App_Edit })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "App.Edit", Functions.App_Edit })]
[HttpPut("{id}")]
public async Task<IActionResult> Edit(string id, [FromBody] ApiAppVM model)
{
Expand Down Expand Up @@ -164,7 +164,7 @@ public async Task<IActionResult> Edit(string id, [FromBody] ApiAppVM model)
/// <param name="id">应用id</param>
/// <returns></returns>
[ProducesResponseType(204)]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "App.Delete", Functions.App_Delete })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "App.Delete", Functions.App_Delete })]
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(string id)
{
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task<IActionResult> Delete(string id)
/// <param name="env">环境</param>
/// <returns></returns>
[TypeFilter(typeof(AdmBasicAuthenticationAttribute))]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "Config.Publish_API", Functions.Config_Publish })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "Config.Publish_API", Functions.Config_Publish })]
[HttpPost("publish")]
public async Task<IActionResult> Publish(string appId, EnvString env)
{
Expand Down Expand Up @@ -248,7 +248,7 @@ public async Task<ActionResult<IEnumerable<ApiPublishTimelineVM>>> PublishHistor
/// <param name="env">环境</param>
/// <returns></returns>
[TypeFilter(typeof(AdmBasicAuthenticationAttribute))]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "Config.Rollback_API", Functions.Config_Publish })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "Config.Rollback_API", Functions.Config_Publish })]
[HttpPost("rollback")]
public async Task<IActionResult> Rollback(string historyId, EnvString env)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public async Task<ActionResult<ApiConfigVM>> GetConfig(string id, [FromQuery] En
/// <returns></returns>
[ProducesResponseType(201)]
[TypeFilter(typeof(AdmBasicAuthenticationAttribute))]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "Config.Add", Functions.Config_Add })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "Config.Add", Functions.Config_Add })]
[HttpPost]
public async Task<IActionResult> Add([FromBody] ApiConfigVM model, EnvString env)
{
Expand Down Expand Up @@ -167,7 +167,7 @@ public async Task<IActionResult> Add([FromBody] ApiConfigVM model, EnvString env
/// <param name="env">环境</param>
/// <returns></returns>
[TypeFilter(typeof(AdmBasicAuthenticationAttribute))]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "Config.Edit", Functions.Config_Edit })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "Config.Edit", Functions.Config_Edit })]
[HttpPut("{id}")]
public async Task<IActionResult> Edit(string id, [FromBody] ApiConfigVM model, EnvString env)
{
Expand Down Expand Up @@ -207,7 +207,7 @@ public async Task<IActionResult> Edit(string id, [FromBody] ApiConfigVM model, E
/// <returns></returns>
[ProducesResponseType(204)]
[TypeFilter(typeof(AdmBasicAuthenticationAttribute))]
[TypeFilter(typeof(PremissionCheckByBasicAttribute), Arguments = new object[] { "Config.Delete", Functions.Config_Delete })]
[TypeFilter(typeof(PermissionCheckByBasicAttribute), Arguments = new object[] { "Config.Delete", Functions.Config_Delete })]
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(string id, EnvString env)
{
Expand Down
Loading

0 comments on commit 739a6e0

Please sign in to comment.