Skip to content

Commit

Permalink
fix: 调整多语言权限
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed Jul 15, 2023
1 parent e9bd75c commit df20638
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public override void Define(IPermissionDefinitionContext context)
{
var abpIdentityGroup = context.GetGroup(AbpProCapPermissions.CapManagement.Default);

abpIdentityGroup.AddPermission(AbpProCapPermissions.CapManagement.Cap, L("Permission:Cap"));
abpIdentityGroup.AddPermission(AbpProCapPermissions.CapManagement.Cap, L("Permission:Cap"), multiTenancySide: MultiTenancySides.Both);
}

private static LocalizableString L(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
global using Volo.Abp.Application.Services;
global using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
global using Volo.Abp.Data;
global using Volo.Abp.MultiTenancy;
global using Volo.Abp.PermissionManagement;
global using Volo.Abp.TenantManagement;
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,32 @@ public override void Define(IPermissionDefinitionContext context)
{
var abpIdentityGroup = context.GetGroup(IdentityPermissions.GroupName);
var userManagement = abpIdentityGroup.GetPermissionOrNull(IdentityPermissions.Users.Default);
userManagement.AddChild(BasicManagementPermissions.SystemManagement.UserEnable, L("Permission:Enable"));
userManagement.AddChild(BasicManagementPermissions.SystemManagement.UserExport, L("Permission:Export"));
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"));
var settingManagement = abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.Setting, L("Permission:SettingManagement"));
var organizationUnitManagement = abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.OrganizationUnit, L("Permission:OrganizationUnitManagement"));
abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.AuditLog, L("Permission:AuditLogManagement"), multiTenancySide: MultiTenancySides.Both);
var settingManagement = abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.Setting, L("Permission:SettingManagement"), multiTenancySide: MultiTenancySides.Both);
var organizationUnitManagement = abpIdentityGroup.AddPermission(BasicManagementPermissions.SystemManagement.OrganizationUnit, L("Permission:OrganizationUnitManagement"), multiTenancySide: MultiTenancySides.Both);
organizationUnitManagement.AddChild
(
BasicManagementPermissions.SystemManagement.OrganizationUnitManagement.Create,
L("Permission:Create")
L("Permission:Create"), multiTenancySide: MultiTenancySides.Both
);
organizationUnitManagement.AddChild
(
BasicManagementPermissions.SystemManagement.OrganizationUnitManagement.Update,
L("Permission:Update")
L("Permission:Update"), multiTenancySide: MultiTenancySides.Both
);
organizationUnitManagement.AddChild
(
BasicManagementPermissions.SystemManagement.OrganizationUnitManagement.Delete,
L("Permission:Delete")
L("Permission:Delete"), multiTenancySide: MultiTenancySides.Both
);

}

private static LocalizableString L(string name)
{
return LocalizableString.Create<BasicManagementResource>(name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
{
options.Resources
.Add<BasicManagementResource>(BasicManagementConsts.DefaultCultureName)
.AddVirtualJson("/Localization/BasicManagement")
.AddBaseTypes(typeof(IdentityResource))
.AddBaseTypes(typeof(AbpValidationResource))
.AddBaseTypes(typeof(AbpLocalizationResource))
.AddBaseTypes(typeof(AbpSettingManagementResource));
.AddVirtualJson("/Localization/BasicManagement");

options.DefaultResourceType = typeof(BasicManagementResource);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
global using Volo.Abp.Authorization.Permissions;
global using Volo.Abp.Localization;
global using Volo.Abp.Modularity;
global using Volo.Abp.MultiTenancy;
global using Volo.Abp.Reflection;
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public override void Define(IPermissionDefinitionContext context)
var abpIdentityGroup = context.GetGroup("AbpIdentity");

var dataDictionaryManagement = abpIdentityGroup.AddPermission(DataDictionaryManagementPermissions.DataDictionaryManagement.Default,
L("Permission:DataDictionaryManagement"));
dataDictionaryManagement.AddChild(DataDictionaryManagementPermissions.DataDictionaryManagement.Create, L("Permission:Create"));
dataDictionaryManagement.AddChild(DataDictionaryManagementPermissions.DataDictionaryManagement.Update, L("Permission:Update"));
dataDictionaryManagement.AddChild(DataDictionaryManagementPermissions.DataDictionaryManagement.Delete, L("Permission:Delete"));
L("Permission:DataDictionaryManagement"), multiTenancySide: MultiTenancySides.Both);
dataDictionaryManagement.AddChild(DataDictionaryManagementPermissions.DataDictionaryManagement.Create, L("Permission:Create"), multiTenancySide: MultiTenancySides.Both);
dataDictionaryManagement.AddChild(DataDictionaryManagementPermissions.DataDictionaryManagement.Update, L("Permission:Update"), multiTenancySide: MultiTenancySides.Both);
dataDictionaryManagement.AddChild(DataDictionaryManagementPermissions.DataDictionaryManagement.Delete, L("Permission:Delete"), multiTenancySide: MultiTenancySides.Both);
}

private static LocalizableString L(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
global using Volo.Abp.Authorization.Permissions;
global using Volo.Abp.Localization;
global using Volo.Abp.Modularity;
global using Volo.Abp.MultiTenancy;
global using Volo.Abp.Reflection;
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ public override void Define(IPermissionDefinitionContext context)
// var languageManagement = context.AddGroup(LanguageManagementPermissions.GroupName, L("Permission:LanguageManagement"));


var languages = abpIdentityGroup.AddPermission(LanguageManagementPermissions.Languages.Default, L("Permission:Languages"));
languages.AddChild(LanguageManagementPermissions.Languages.Create, L("Permission:Create"));
languages.AddChild(LanguageManagementPermissions.Languages.Edit, L("Permission:Edit"));
languages.AddChild(LanguageManagementPermissions.Languages.Delete, L("Permission:Delete"));
languages.AddChild(LanguageManagementPermissions.Languages.ChangeDefault, L("Permission:LanguagesChangeDefault"));
var languages = abpIdentityGroup.AddPermission(LanguageManagementPermissions.Languages.Default, L("Permission:Languages"), multiTenancySide: MultiTenancySides.Both);
languages.AddChild(LanguageManagementPermissions.Languages.Create, L("Permission:Create"), multiTenancySide: MultiTenancySides.Both);
languages.AddChild(LanguageManagementPermissions.Languages.Update, L("Permission:Update"), multiTenancySide: MultiTenancySides.Both);
languages.AddChild(LanguageManagementPermissions.Languages.Delete, L("Permission:Delete"), multiTenancySide: MultiTenancySides.Both);
languages.AddChild(LanguageManagementPermissions.Languages.ChangeDefault, L("Permission:LanguagesChangeDefault"), multiTenancySide: MultiTenancySides.Both);


var languageTexts = abpIdentityGroup.AddPermission(LanguageManagementPermissions.LanguageTexts.Default, L("Permission:LanguageTexts"));
languageTexts.AddChild(LanguageManagementPermissions.LanguageTexts.Edit, L("Permission:Edit"));
languageTexts.AddChild(LanguageManagementPermissions.LanguageTexts.Create, L("Permission:Create"));
var languageTexts = abpIdentityGroup.AddPermission(LanguageManagementPermissions.LanguageTexts.Default, L("Permission:LanguageTexts"), multiTenancySide: MultiTenancySides.Both);
languageTexts.AddChild(LanguageManagementPermissions.LanguageTexts.Update, L("Permission:Update"), multiTenancySide: MultiTenancySides.Both);
languageTexts.AddChild(LanguageManagementPermissions.LanguageTexts.Create, L("Permission:Create"), multiTenancySide: MultiTenancySides.Both);
}

private static LocalizableString L(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class LanguageTexts

public const string Create = "AbpIdentity.LanguageTexts.Create";

public const string Edit = "AbpIdentity.LanguageTexts.Edit";
public const string Update = "AbpIdentity.LanguageTexts.Update";
}

public class Languages
{
public const string Default = "AbpIdentity.Languages";

public const string Edit = "AbpIdentity.Languages.Edit";
public const string Update = "AbpIdentity.Languages.Update";

public const string Create = "AbpIdentity.Languages.Create";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ await _languageTextManager.CreateAsync(
/// <summary>
/// 编辑语言文本
/// </summary>
[Authorize(LanguageManagementPermissions.LanguageTexts.Edit)]
[Authorize(LanguageManagementPermissions.LanguageTexts.Update)]
public async Task UpdateAsync(UpdateLanguageTextInput input)
{
var localizedString = await GetLocalizedStringAsync(input.ResourceName, input.CultureName, input.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Task CreateAsync(CreateLanguageInput input)
/// <summary>
/// 编辑语言
/// </summary>
[Authorize(LanguageManagementPermissions.Languages.Edit)]
[Authorize(LanguageManagementPermissions.Languages.Update)]
public Task UpdateAsync(UpdateLanguageInput input)
{
return _languageManager.UpdateAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
preIcon="ant-design:plus-circle-outlined"
type="primary"
@click="openCreateLanguageModal"
v-auth="'AbpIdentity.Languages.Create'"
>
{{ t('common.createText') }}
</a-button>
Expand All @@ -28,12 +29,14 @@
{
icon: 'clarity:note-edit-line',
label: t('common.editText'),
auth: 'AbpIdentity.Languages.Update',
onClick: handleEdit.bind(null, record),
},
{
icon: 'ant-design:delete-outlined',
color: 'error',
label: t('common.delText'),
auth: 'AbpIdentity.Languages.Update',
popConfirm: {
title: t('common.askDelete'),
placement: 'left',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
preIcon="ant-design:plus-circle-outlined"
type="primary"
@click="openCreateLanguageTextModal"
v-auth="'AbpIdentity.LanguageTexts.Create'"
>
{{ t('common.createText') }}
</a-button>
Expand All @@ -17,6 +18,7 @@
{
icon: 'clarity:note-edit-line',
label: t('common.editText'),
auth: 'AbpIdentity.LanguageTexts.Update',
onClick: handleEdit.bind(null, record),
},
]"
Expand Down
Loading

0 comments on commit df20638

Please sign in to comment.