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 739a6e0 commit 5e5f3bb
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/AgileConfig.Server.Apisite/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public class AdminController : Controller
{
private readonly ISettingService _settingService;
private readonly IUserService _userService;
private readonly IPremissionService _permissionService;
private readonly IPermissionService _permissionService;
private readonly IJwtService _jwtService;
private readonly IOidcClient _oidcClient;
private readonly ITinyEventBus _tinyEventBus;

public AdminController(
ISettingService settingService,
IUserService userService,
IPremissionService permissionService,
IPermissionService permissionService,
IJwtService jwtService,
IOidcClient oidcClient,
ITinyEventBus tinyEventBus)
Expand Down
4 changes: 2 additions & 2 deletions src/AgileConfig.Server.Apisite/Controllers/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ namespace AgileConfig.Server.Apisite.Controllers
public class AppController : Controller
{
private readonly IAppService _appService;
private readonly IPremissionService _permissionService;
private readonly IPermissionService _permissionService;
private readonly IUserService _userService;
private readonly ITinyEventBus _tinyEventBus;

public AppController(IAppService appService,
IPremissionService permissionService,
IPermissionService permissionService,
IUserService userService,
ITinyEventBus tinyEventBus)
{
Expand Down
4 changes: 2 additions & 2 deletions src/AgileConfig.Server.Apisite/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class HomeController : Controller
{
private readonly ISettingService _settingService;
private readonly IUserService _userService;
private readonly IPremissionService _permissionService;
private readonly IPermissionService _permissionService;

public HomeController(
ISettingService settingService,
IUserService userService,
IPremissionService permissionService
IPermissionService permissionService
)
{
_settingService = settingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ private static string GetEnvFromArgs(IDictionary<string, object> args, IConfigSe
/// 因为 attribute 不能传递 func 参数,所有从 action 的参数内获取 appId 的操作只能提前内置在一个静态字典内。
/// </summary>
protected static readonly
FrozenDictionary<string, Func<ActionExecutingContext, IPremissionService, IConfigService, string>>
FrozenDictionary<string, Func<ActionExecutingContext, IPermissionService, IConfigService, string>>
GetAppIdParamFuncs =
new Dictionary<string, Func<ActionExecutingContext, IPremissionService, IConfigService, string>>
new Dictionary<string, Func<ActionExecutingContext, IPermissionService, IConfigService, string>>
{
{
"Config.Add", (args, premission, config) =>
Expand Down Expand Up @@ -194,16 +194,16 @@ protected static readonly
protected const string GlobalMatchPatten = "GLOBAL_{0}";
protected const string AppMatchPatten = "APP_{0}_{1}";

private readonly IPremissionService _permissionService;
private readonly IPermissionService _permissionService;
private readonly IConfigService _configService;

private readonly string _actionName;
private readonly string _functionKey;

public PermissionCheckAttribute(IPremissionService premissionService, IConfigService configService,
public PermissionCheckAttribute(IPermissionService permissionService, IConfigService configService,
string actionName, string functionKey)
{
_permissionService = premissionService;
_permissionService = permissionService;
_configService = configService;

_actionName = actionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class PermissionCheckByBasicAttribute : PermissionCheckAttribute
protected IUserService _userService;

public PermissionCheckByBasicAttribute(
IPremissionService premissionService,
IPermissionService permissionService,
IConfigService configService,
IAdmBasicAuthService basicAuthService,
IUserService userService,
string actionName,
string functionKey) : base(premissionService, configService, actionName, functionKey)
string functionKey) : base(permissionService, configService, actionName, functionKey)
{
_userService = userService;
_basicAuthService = basicAuthService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using AgileConfig.Server.Data.Entity;
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace AgileConfig.Server.IService
{
public class Functions
public static class Functions
{
public const string App_Add = "APP_ADD";
public const string App_Edit = "APP_EDIT";
Expand All @@ -30,7 +27,7 @@ public class Functions
public const string User_Delete = "USER_DELETE";
}

public interface IPremissionService
public interface IPermissionService
{
string EditConfigPermissionKey { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace AgileConfig.Server.Service
{
public class PermissionService : IPremissionService
public class PermissionService : IPermissionService
{
private readonly IUserRoleRepository _userRoleRepository;
private readonly IUserAppAuthRepository _userAppAuthRepository;
Expand All @@ -23,8 +23,8 @@ public PermissionService(
_appRepository = appRepository;
}

private static readonly List<string> Template_SuperAdminPermissions = new List<string>
{
private static readonly List<string> Template_SuperAdminPermissions =
[
"GLOBAL_" + Functions.App_Add,
"GLOBAL_" + Functions.App_Delete,
"GLOBAL_" + Functions.App_Edit,
Expand All @@ -43,11 +43,11 @@ public PermissionService(

"GLOBAL_" + Functions.User_Add,
"GLOBAL_" + Functions.User_Edit,
"GLOBAL_" + Functions.User_Delete,
};
"GLOBAL_" + Functions.User_Delete
];

private static readonly List<string> Template_NormalAdminPermissions = new List<string>
{
private static readonly List<string> Template_NormalAdminPermissions =
[
"GLOBAL_" + Functions.App_Add,
"GLOBAL_" + Functions.Node_Add,
"GLOBAL_" + Functions.Node_Delete,
Expand All @@ -65,21 +65,21 @@ public PermissionService(
"APP_{0}_" + Functions.Config_Delete,
"APP_{0}_" + Functions.Config_Edit,
"APP_{0}_" + Functions.Config_Offline,
"APP_{0}_" + Functions.Config_Publish,
};
"APP_{0}_" + Functions.Config_Publish
];

private static readonly List<string> Template_NormalUserPermissions_Edit = new List<string>
{
private static readonly List<string> Template_NormalUserPermissions_Edit =
[
"APP_{0}_" + Functions.Config_Add,
"APP_{0}_" + Functions.Config_Delete,
"APP_{0}_" + Functions.Config_Edit,
};
"APP_{0}_" + Functions.Config_Edit
];

private static readonly List<string> Template_NormalUserPermissions_Publish = new List<string>
{
private static readonly List<string> Template_NormalUserPermissions_Publish =
[
"APP_{0}_" + Functions.Config_Offline,
"APP_{0}_" + Functions.Config_Publish
};
];

private async Task<List<string>> GetAdminUserFunctions(string userId)
{
Expand Down Expand Up @@ -181,7 +181,7 @@ private async Task<List<string>> GetNormalUserFunctions(string userId)
/// <summary>
/// 获取角色权限的模板
/// </summary>
/// <param name="role"></param>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<List<string>> GetUserPermission(string userId)
{
Expand Down Expand Up @@ -210,6 +210,7 @@ public async Task<List<string>> GetUserPermission(string userId)
/// 获取被授权给用户的app
/// </summary>
/// <param name="userId"></param>
/// <param name="authPermissionKey"></param>
/// <returns></returns>
private async Task<List<App>> GetUserAuthApp(string userId, string authPermissionKey)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AgileConfig.Server.Service/ServiceCollectionExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void AddBusinessServices(this IServiceCollection sc)
sc.AddScoped<IAppBasicAuthService, AppBasicAuthService>();
sc.AddScoped<IAdmBasicAuthService, AdmBasicAuthService>();
sc.AddScoped<IUserService, UserService>();
sc.AddScoped<IPremissionService, PermissionService>();
sc.AddScoped<IPermissionService, PermissionService>();
sc.AddScoped<IRegisterCenterService, RegisterCenterService>();

sc.AddScoped<ConfigStatusUpdateEventHandlersRegister>();
Expand Down
4 changes: 2 additions & 2 deletions test/ApiSiteTests/TestAppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task TestAdd()
var appService = new Mock<IAppService>();
var logService = new Mock<ISysLogService>();
var userService = new Mock<IUserService>();
var permissionService = new Mock<IPremissionService>();
var permissionService = new Mock<IPermissionService>();
var eventBus = new Mock<ITinyEventBus>();

var ctl = new AgileConfig.Server.Apisite.Controllers.AppController(appService.Object, permissionService.Object, userService.Object, eventBus.Object);
Expand All @@ -45,7 +45,7 @@ public async Task TestAdd()
var jr = result as JsonResult;
Assert.IsNotNull(jr.Value);
Console.WriteLine(jr.Value.ToString());
//Assert.IsTrue(jr.Value.ToString().Contains("应用Id已存在,请重新输入"));
//Assert.IsTrue(jr.Value.ToString().Contains("Ӧ��Id�Ѵ��ڣ�����������"));
App nullApp = null;

appService.Setup(s => s.GetAsync("02")).ReturnsAsync(nullApp);
Expand Down

0 comments on commit 5e5f3bb

Please sign in to comment.