Skip to content

Commit

Permalink
feat: 添加Feature功能
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed Apr 10, 2024
1 parent a11af34 commit b2879e8
Show file tree
Hide file tree
Showing 29 changed files with 1,421 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Lion.AbpPro.BasicManagement.Features.Dtos;

public class DeleteFeatureInput : IValidatableObject
{
public string ProviderName { get; set; }

public string ProviderKey { get; set; }

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var localization = validationContext.GetRequiredService<IStringLocalizer<AbpProLocalizationResource>>();
if (ProviderName.IsNullOrWhiteSpace())
{
yield return new ValidationResult(
localization[AbpProLocalizationErrorCodes.ErrorCode100003, nameof(ProviderName)],
new[] { nameof(ProviderName) }
);
}

if (ProviderKey.IsNullOrWhiteSpace())
{
yield return new ValidationResult(
localization[AbpProLocalizationErrorCodes.ErrorCode100003, nameof(ProviderKey)],
new[] { nameof(ProviderKey) }
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Lion.AbpPro.BasicManagement.Features.Dtos;

public class GetFeatureListResultInput : IValidatableObject
{
public string ProviderName { get; set; }

public string ProviderKey { get; set; }

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var localization = validationContext.GetRequiredService<IStringLocalizer<AbpProLocalizationResource>>();
if (ProviderName.IsNullOrWhiteSpace())
{
yield return new ValidationResult(
localization[AbpProLocalizationErrorCodes.ErrorCode100003, nameof(ProviderName)],
new[] { nameof(ProviderName) }
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Volo.Abp.FeatureManagement;

namespace Lion.AbpPro.BasicManagement.Features.Dtos;

public class UpdateFeatureInput : IValidatableObject
{
public string ProviderName { get; set; }

public string ProviderKey { get; set; }

public UpdateFeaturesDto UpdateFeaturesDto { get; set; }


public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var localization = validationContext.GetRequiredService<IStringLocalizer<AbpProLocalizationResource>>();
if (ProviderName.IsNullOrWhiteSpace())
{
yield return new ValidationResult(
localization[AbpProLocalizationErrorCodes.ErrorCode100003, nameof(ProviderName)],
new[] { nameof(ProviderName) }
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Lion.AbpPro.BasicManagement.Features.Dtos;
using Volo.Abp.FeatureManagement;

namespace Lion.AbpPro.BasicManagement.Features;

public interface IVoloFeatureAppService : IApplicationService
{
/// <summary>
/// 获取Features
/// </summary>
Task<GetFeatureListResultDto> GetAsync(GetFeatureListResultInput input);

/// <summary>
/// 更新Features
/// </summary>
Task UpdateAsync(UpdateFeatureInput input);

/// <summary>
/// 删除Features
/// </summary>
Task DeleteAsync(DeleteFeatureInput input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ public override void Define(IPermissionDefinitionContext context)
userManagement.AddChild(BasicManagementPermissions.SystemManagement.UserEnable, L("Permission:Enable"), multiTenancySide: MultiTenancySides.Both);
userManagement.AddChild(BasicManagementPermissions.SystemManagement.UserExport, L("Permission:Export"), multiTenancySide: MultiTenancySides.Both);

var auditManagement =
abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.AuditLog, L("Permission:AuditLogManagement"), multiTenancySide: MultiTenancySides.Both);
abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.AuditLog, L("Permission:AuditLogManagement"), multiTenancySide: MultiTenancySides.Both);
abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.Setting, L("Permission:SettingManagement"), multiTenancySide: MultiTenancySides.Both);
abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.IdentitySecurityLog, L("Permission:IdentitySecurityLog"), multiTenancySide: MultiTenancySides.Both);
var organizationUnitManagement = abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.OrganizationUnit, L("Permission:OrganizationUnitManagement"), multiTenancySide: MultiTenancySides.Both);
abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.FeatureManagement, L("Permission:FeatureManagement"), multiTenancySide: MultiTenancySides.Both);

var organizationUnitManagement = abpIdentityGroup
.AddPermission(BasicManagementPermissions.SystemManagement.OrganizationUnit, L("Permission:OrganizationUnitManagement"), multiTenancySide: MultiTenancySides.Both);

organizationUnitManagement.AddChild
(
BasicManagementPermissions.SystemManagement.OrganizationUnitManagement.Create,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class SystemManagement
public const string Setting = Default + ".Setting";
public const string IdentitySecurityLog = Default + ".IdentitySecurityLogs";
public const string OrganizationUnit = Default + ".OrganizationUnitManagement";
public const string FeatureManagement = Default + ".FeatureManagement";
public static class OrganizationUnitManagement
{
public const string Default = SystemManagement.Default + ".OrganizationUnitManagement";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ protected virtual async Task<ApplicationFeatureConfigurationDto> GetFeaturesConf
continue;
}

if (featureDefinition.Name == "SettingManagement.Enable")
{
continue;
}

if (featureDefinition.Name == "SettingManagement.AllowChangingEmailSettings")
{
continue;
}
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Lion.AbpPro.BasicManagement.Features.Dtos;
using Volo.Abp.FeatureManagement;

namespace Lion.AbpPro.BasicManagement.Features;

[Authorize]
public class VoloFeatureAppService : BasicManagementAppService, IVoloFeatureAppService
{
private readonly IFeatureAppService _featureAppService;

public VoloFeatureAppService(IFeatureAppService featureAppService)
{
_featureAppService = featureAppService;
}

public virtual async Task<GetFeatureListResultDto> GetAsync(GetFeatureListResultInput input)
{
var result = await _featureAppService.GetAsync(input.ProviderName, input.ProviderKey);
// 过滤自带的SettingManagement设置
result.Groups = result.Groups.Where(e => e.Name != "SettingManagement").ToList();
return result;
}

public virtual async Task UpdateAsync(UpdateFeatureInput input)
{
await _featureAppService.UpdateAsync(input.ProviderName, input.ProviderKey, input.UpdateFeaturesDto);
}

public virtual async Task DeleteAsync(DeleteFeatureInput input)
{
await _featureAppService.DeleteAsync(input.ProviderName, input.ProviderKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Permission:SettingManagement": "SettingManagement",
"Permission:IdentitySecurityLog": "IdentitySecurityLog",
"Permission:OrganizationUnitManagement": "OrganizationUnitManagement",
"Permission:FeatureManagement": "FeatureManagement",
"Setting.Group.System": "System",
"Lion.AbpPro.BasicManagement:100001": "OrganizationUnit Not Exist",
"Lion.AbpPro.BasicManagement:100002": "UserLockedOut",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Permission:SettingManagement": "设置管理",
"Permission:IdentitySecurityLog": "登录日志",
"Permission:OrganizationUnitManagement": "组织结构管理",

"Permission:FeatureManagement": "功能管理",
"Setting.Group.System": "系统",
"Lion.AbpPro.BasicManagement:100001": "组织机构不存在",
"Lion.AbpPro.BasicManagement:100002": "用户被锁定",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Lion.AbpPro.BasicManagement.Features;
using Lion.AbpPro.BasicManagement.Features.Dtos;
using Volo.Abp.FeatureManagement;

namespace Lion.AbpPro.BasicManagement.Systems;

[Route("Features")]
public class FeatureController : BasicManagementController, IVoloFeatureAppService
{
private readonly IVoloFeatureAppService _featureAppService;

public FeatureController(IVoloFeatureAppService featureAppService)
{
_featureAppService = featureAppService;
}

[HttpPost("list")]
[SwaggerOperation(summary: "获取Features", Tags = new[] {"Features"})]
public Task<GetFeatureListResultDto> GetAsync(GetFeatureListResultInput input)
{
return _featureAppService.GetAsync(input);
}

[HttpPost("update")]
[SwaggerOperation(summary: "更新Features", Tags = new[] {"Features"})]
public Task UpdateAsync(UpdateFeatureInput input)
{
return _featureAppService.UpdateAsync(input);
}

[HttpPost("delete")]
[SwaggerOperation(summary: "删除Features", Tags = new[] {"Features"})]
public Task DeleteAsync(DeleteFeatureInput input)
{
return _featureAppService.DeleteAsync(input);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<None Remove="Logs\**" />
</ItemGroup>


<ItemGroup>
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*.json" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:3100"
},
"ConnectionStrings": {
"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
"Default": "Data Source=43.139.143.143;Port=3306;Database=tenantdb;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"Hangfire": {
"Redis": {
"Host": "localhost:6379,password=1q2w3E*",
"Host": "43.139.143.143:6379,password=1q2w3E*",
"DB": "2"
}
},
"Redis": {
"Configuration": "localhost:6379,password=1q2w3E*,defaultdatabase=1"
"Configuration": "43.139.143.143:6379,password=1q2w3E*,defaultdatabase=5"
},
"Jwt": {
"Audience": "Lion.AbpPro",
Expand All @@ -52,11 +52,12 @@
"ExpirationTime": 2
},
"Cap": {
"Enabled": false,
"Enabled": true,
"RabbitMq": {
"HostName": "localhost",
"HostName": "43.139.143.143",
"UserName": "admin",
"Password": "admin"
"Password": "1q2w3E*",
"Port": 5672
}
},
"ElasticSearch": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Volo.Abp.Features;
using Volo.Abp.Validation.StringValues;

namespace Lion.AbpPro.Features;

public class AbpProFeatureDefinitionProvider : FeatureDefinitionProvider
{
public override void Define(IFeatureDefinitionContext context)
{

var group = context.AddGroup(AbpProFeatures.GroupName,L("Feature:TestGroup"));

// ToggleStringValueType bool类型 前端渲染为checkbox
group.AddFeature(AbpProFeatures.TestEnable,
"true",
L("Feature:TestEnable"),
L("Feature:TestEnable"),
new ToggleStringValueType());

// ToggleStringValueType string类型 前端渲染为input
group.AddFeature(AbpProFeatures.TestString,
"输入需要设定的值",
L("Feature:TestString"),
L("Feature:TestString"),
new FreeTextStringValueType());

// todo SelectionStringValueType select标签待定
}

private static LocalizableString L(string name)
{
return LocalizableString.Create<AbpProResource>(name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Lion.AbpPro.Features;

public class AbpProFeatures
{
public const string GroupName = "AbpPro";

public const string TestEnable = GroupName + ".TestEnable";

public const string TestString = GroupName + ".TestString";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"Description:Setting.Group.Other.Github": "Github",
"Enum:TestType:Created:1":"Created",
"Enum:TestType:Cancel:1":"Cancel",
"Enum:TestType:Delete:1":"Delete"
"Enum:TestType:Delete:1":"Delete",
"Feature:TestEnable": "TestEnable",
"Feature:TestString": "TestString",
"Feature:TestGroup": "TestGroup"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"Description:Setting.Group.Other.Github": "Github",
"Enum:TestType:Created:1":"创建",
"Enum:TestType:Cancel:1":"取消",
"Enum:TestType:Delete:1":"删除"
"Enum:TestType:Delete:1":"删除",
"Feature:TestGroup": "测试功能分组",
"Feature:TestEnable": "测试Checkbox-bool类型",
"Feature:TestString": "测试Input-string类型"
}
}
2 changes: 1 addition & 1 deletion vben28/src/api/sys/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function login(input: LoginInput): Promise<LoginOutput> {
*/
export function getAbpApplicationConfiguration() {
const _abpApplicationConfigurationServiceProxy = new AbpApplicationConfigurationServiceProxy();
return _abpApplicationConfigurationServiceProxy.applicationConfiguration();
return _abpApplicationConfigurationServiceProxy.applicationConfiguration(false);
}


Expand Down
1 change: 1 addition & 0 deletions vben28/src/locales/lang/en/routes/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
logLevel: 'Level',
logContent: 'Content',
settingManagement: 'SettingManagement',
featureManagement: 'FeatureManagement',
dictionaryManagement: 'DataDictionary',
dictionaryTypeName: 'Type',
dictionaryCode: 'Code',
Expand Down
1 change: 1 addition & 0 deletions vben28/src/locales/lang/en/routes/tenant.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
name: 'Name',
connectionString: 'ConnectionString',
manageFeatures : 'Manage Features',
tenantManagement: 'TenantManagement',
tenantList: 'TenantList',
adminPassword: 'AdminPassword',
Expand Down
1 change: 1 addition & 0 deletions vben28/src/locales/lang/zh-CN/routes/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default {
logContent: '内容',
detail: '详情',
settingManagement: '设置管理',
featureManagement: '功能管理',
dictionaryManagement: '数据字典',
dictionaryTypeName: '字典类型',
dictionaryCode: '编码',
Expand Down
1 change: 1 addition & 0 deletions vben28/src/locales/lang/zh-CN/routes/tenant.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
name: '名称',
connectionString: '连接字符串',
manageFeatures : '功能管理',
tenantManagement: '租户管理',
tenantList: '租户列表',
adminPassword: '管理员密码',
Expand Down
Loading

0 comments on commit b2879e8

Please sign in to comment.