27 changed files with 1472 additions and 1000 deletions
@ -0,0 +1,62 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace CompanyName.ProjectName.Settings |
|||
{ |
|||
public class SettingOutput |
|||
{ |
|||
/// <summary>
|
|||
/// 分组
|
|||
/// </summary>
|
|||
public string Group { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 分组显示名称
|
|||
/// </summary>
|
|||
public string GroupDisplayName { get; set; } |
|||
|
|||
public List<SettingItemOutput> SettingItemOutput { get; set; } |
|||
|
|||
public SettingOutput() |
|||
{ |
|||
SettingItemOutput = new List<SettingItemOutput>(); |
|||
} |
|||
} |
|||
|
|||
public class SettingItemOutput |
|||
{ |
|||
public SettingItemOutput(string name, string displayName, string value, string type,string description) |
|||
{ |
|||
Name = name; |
|||
DisplayName = displayName; |
|||
Value = value; |
|||
Type = type ?? "Text"; |
|||
Description = description; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 名称
|
|||
/// </summary>
|
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 显示名称
|
|||
/// </summary>
|
|||
public string DisplayName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 描述
|
|||
/// </summary>
|
|||
public string Description { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 值
|
|||
/// </summary>
|
|||
public string Value { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 前端控件类型
|
|||
/// </summary>
|
|||
public string Type { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.Extension.Customs.Dtos; |
|||
using CompanyName.ProjectName.Tenants.Dtos; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
using Volo.Abp.TenantManagement; |
|||
|
|||
namespace CompanyName.ProjectName.Tenants |
|||
{ |
|||
public interface IVoloTenantAppService : IApplicationService |
|||
{ |
|||
Task<FindTenantResultDto> FindTenantByNameAsync(FindTenantByNameInput input); |
|||
|
|||
Task<PagedResultDto<TenantDto>> ListAsync(PagingTenantInput input); |
|||
|
|||
Task<TenantDto> CreateAsync(TenantCreateDto input); |
|||
|
|||
Task<TenantDto> UpdateAsync(UpdateTenantInput input); |
|||
|
|||
Task DeleteAsync(IdInput input); |
|||
|
|||
Task<string> GetDefaultConnectionStringAsync(IdInput input); |
|||
|
|||
Task UpdateDefaultConnectionStringAsync(UpdateConnectionStringInput input); |
|||
|
|||
Task DeleteDefaultConnectionStringAsync(IdInput input); |
|||
} |
|||
} |
|||
@ -1,31 +1,113 @@ |
|||
using System.Collections.Generic; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using EasyAbp.Abp.SettingUi; |
|||
using EasyAbp.Abp.SettingUi.Authorization; |
|||
using EasyAbp.Abp.SettingUi.Dto; |
|||
using CompanyName.ProjectName.Localization; |
|||
using CompanyName.ProjectName.Permissions; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.SettingManagement; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace CompanyName.ProjectName.Settings |
|||
{ |
|||
[Authorize(Policy = SettingUiPermissions.ShowSettingPage)] |
|||
[Authorize(policy: ProjectNamePermissions.SystemManagement.Setting)] |
|||
public class SettingAppService : ProjectNameAppService, ISettingAppService |
|||
{ |
|||
private readonly ISettingUiAppService _settingUiAppService; |
|||
private readonly ISettingDefinitionManager _settingDefinitionManager; |
|||
private readonly ISettingManager _settingManager; |
|||
private readonly IStringLocalizer<ProjectNameResource> _localizer; |
|||
private readonly IStringLocalizerFactory _factory; |
|||
|
|||
public SettingAppService(ISettingUiAppService settingUiAppService) |
|||
public SettingAppService( |
|||
ISettingDefinitionManager settingDefinitionManager, |
|||
ISettingManager settingManager, |
|||
IStringLocalizer<ProjectNameResource> localizer, |
|||
IStringLocalizerFactory factory) |
|||
{ |
|||
_settingUiAppService = settingUiAppService; |
|||
_settingDefinitionManager = settingDefinitionManager; |
|||
_settingManager = settingManager; |
|||
_localizer = localizer; |
|||
_factory = factory; |
|||
} |
|||
|
|||
public async Task<List<SettingOutput>> GetAsync() |
|||
{ |
|||
var ss = _localizer.GetAllStrings(); |
|||
var s = _localizer["Setting:Group:System"]; |
|||
var s2 = _localizer["Volo.Abp.Identity:PasswordRequiresDigit"]; |
|||
var allSettings = _settingDefinitionManager.GetAll().ToList(); |
|||
var settings = allSettings |
|||
.Where(e => e.Properties.ContainsKey(ProjectNameSettings.Group.Defalut)).ToList(); |
|||
|
|||
var settingOutput = settings |
|||
.GroupBy(e => e.Properties[ProjectNameSettings.Group.Defalut].ToString()).Select(s => |
|||
new SettingOutput |
|||
{ |
|||
Group = s.Key, |
|||
GroupDisplayName = _localizer[s.Key] |
|||
}).ToList(); |
|||
|
|||
public async Task<List<SettingGroup>> GetAsync() |
|||
foreach (var item in settingOutput) |
|||
{ |
|||
var currentSettings = settings.Where(e => e.Properties.ContainsValue(item.Group)); |
|||
foreach (var itemDefinition in currentSettings) |
|||
{ |
|||
return await _settingUiAppService.GroupSettingDefinitions(); |
|||
|
|||
var value = await SettingProvider.GetOrNullAsync(itemDefinition.Name); |
|||
var type = itemDefinition.Properties |
|||
.FirstOrDefault(f => f.Key == ProjectNameSettings.ControlType.Defalut).Value |
|||
.ToString(); |
|||
|
|||
item.SettingItemOutput.Add(new SettingItemOutput( |
|||
itemDefinition.Name, |
|||
L["DisplayName:" + itemDefinition.Name], |
|||
value, |
|||
type, |
|||
itemDefinition.Description.Localize(_factory))); |
|||
} |
|||
} |
|||
|
|||
return await Task.FromResult(settingOutput); |
|||
} |
|||
|
|||
public async Task UpdateAsync(UpdateSettingInput input) |
|||
{ |
|||
await _settingUiAppService.SetSettingValues(input.Values); |
|||
foreach (var kv in input.Values) |
|||
{ |
|||
// The key of the settingValues is in camel_Case, like "setting_Abp_Localization_DefaultLanguage",
|
|||
// change it to "Abp.Localization.DefaultLanguage" form
|
|||
if (!kv.Key.StartsWith(ProjectNameSettings.Prefix)) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
string name = kv.Key.RemovePreFix(ProjectNameSettings.Prefix); |
|||
var setting = _settingDefinitionManager.GetOrNull(name); |
|||
if (setting == null) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
await SetSetting(setting, kv.Value); |
|||
} |
|||
} |
|||
|
|||
private Task SetSetting(SettingDefinition setting, string value) |
|||
{ |
|||
if (setting.Providers.Any(p => p == UserSettingValueProvider.ProviderName)) |
|||
{ |
|||
return _settingManager.SetForCurrentUserAsync(setting.Name, value); |
|||
} |
|||
|
|||
if (setting.Providers.Any(p => p == GlobalSettingValueProvider.ProviderName)) |
|||
{ |
|||
return _settingManager.SetGlobalAsync(setting.Name, value); |
|||
} |
|||
|
|||
//Default
|
|||
return _settingManager.SetForCurrentTenantAsync(setting.Name, value); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.Extension.Customs.Dtos; |
|||
using CompanyName.ProjectName.Tenants.Dtos; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
using Volo.Abp.TenantManagement; |
|||
|
|||
namespace CompanyName.ProjectName.Tenants |
|||
{ |
|||
public class VoloTenantAppService : ProjectNameAppService, IVoloTenantAppService |
|||
{ |
|||
private readonly IAbpTenantAppService _abpTenantAppService; |
|||
private readonly ITenantAppService _tenantAppService; |
|||
|
|||
public VoloTenantAppService( |
|||
IAbpTenantAppService abpTenantAppService, |
|||
ITenantAppService tenantAppService) |
|||
{ |
|||
_abpTenantAppService = abpTenantAppService; |
|||
_tenantAppService = tenantAppService; |
|||
} |
|||
|
|||
public async Task<FindTenantResultDto> FindTenantByNameAsync(FindTenantByNameInput input) |
|||
{ |
|||
return await _abpTenantAppService.FindTenantByNameAsync(input.Name); |
|||
} |
|||
|
|||
|
|||
[Authorize(policy:TenantManagementPermissions.Tenants.Default)] |
|||
public Task<PagedResultDto<TenantDto>> ListAsync(PagingTenantInput input) |
|||
{ |
|||
var request = new GetTenantsInput |
|||
{ |
|||
Filter = input.Filter, SkipCount = input.SkipCount, MaxResultCount = input.PageSize |
|||
}; |
|||
return _tenantAppService.GetListAsync(request); |
|||
} |
|||
|
|||
[Authorize(policy:TenantManagementPermissions.Tenants.Create)] |
|||
public Task<TenantDto> CreateAsync(TenantCreateDto input) |
|||
{ |
|||
return _tenantAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[Authorize(policy:TenantManagementPermissions.Tenants.Update)] |
|||
public Task<TenantDto> UpdateAsync(UpdateTenantInput input) |
|||
{ |
|||
var request = new TenantUpdateDto() |
|||
{ |
|||
Name = input.Name.Trim() |
|||
}; |
|||
return _tenantAppService.UpdateAsync(input.Id, request); |
|||
} |
|||
|
|||
[Authorize(policy:TenantManagementPermissions.Tenants.Delete)] |
|||
public Task DeleteAsync(IdInput input) |
|||
{ |
|||
return _tenantAppService.DeleteAsync(input.Id); |
|||
} |
|||
|
|||
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)] |
|||
public Task<string> GetDefaultConnectionStringAsync(IdInput input) |
|||
{ |
|||
return _tenantAppService.GetDefaultConnectionStringAsync(input.Id); |
|||
} |
|||
|
|||
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)] |
|||
public Task UpdateDefaultConnectionStringAsync(UpdateConnectionStringInput input) |
|||
{ |
|||
return _tenantAppService.UpdateDefaultConnectionStringAsync(input.Id, |
|||
input.ConnectionString); |
|||
} |
|||
|
|||
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)] |
|||
public Task DeleteDefaultConnectionStringAsync(IdInput input) |
|||
{ |
|||
return _tenantAppService.DeleteDefaultConnectionStringAsync(input.Id); |
|||
} |
|||
} |
|||
} |
|||
@ -1,26 +1,28 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.Tenants.Dtos; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Swashbuckle.AspNetCore.Annotations; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
|
|||
namespace CompanyName.ProjectName.Controllers.Tenants |
|||
{ |
|||
[Route("Tenants")] |
|||
public class AbpTenantController : ProjectNameController |
|||
{ |
|||
private readonly IAbpTenantAppService _abpTenantAppService; |
|||
|
|||
public AbpTenantController(IAbpTenantAppService abpTenantAppService) |
|||
{ |
|||
_abpTenantAppService = abpTenantAppService; |
|||
} |
|||
|
|||
[HttpPost("find")] |
|||
[SwaggerOperation(summary: "通过名称获取租户信息", Tags = new[] {"Tenants"})] |
|||
public async Task<FindTenantResultDto> FindTenantByNameAsync(FindTenantByNameInput input) |
|||
{ |
|||
return await _abpTenantAppService.FindTenantByNameAsync(input.Name); |
|||
} |
|||
} |
|||
} |
|||
// using System;
|
|||
// using System.Threading.Tasks;
|
|||
// using CompanyName.ProjectName.Tenants.Dtos;
|
|||
// using Microsoft.AspNetCore.Mvc;
|
|||
// using Swashbuckle.AspNetCore.Annotations;
|
|||
// using Volo.Abp.Application.Services;
|
|||
// using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
|
|||
//
|
|||
// namespace CompanyName.ProjectName.Controllers.Tenants
|
|||
// {
|
|||
// [Route("Tenants")]
|
|||
// public class AbpTenantController : ProjectNameController,IApplicationService
|
|||
// {
|
|||
// private readonly IAbpTenantAppService _abpTenantAppService;
|
|||
//
|
|||
// public AbpTenantController(IAbpTenantAppService abpTenantAppService)
|
|||
// {
|
|||
// _abpTenantAppService = abpTenantAppService;
|
|||
// }
|
|||
//
|
|||
// [HttpPost("find")]
|
|||
// [SwaggerOperation(summary: "通过名称获取租户信息", Tags = new[] {"Tenants"})]
|
|||
// public async Task<FindTenantResultDto> FindTenantByNameAsync(FindTenantByNameInput input)
|
|||
// {
|
|||
// return await _abpTenantAppService.FindTenantByNameAsync(input.Name);
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
@ -1,77 +1,83 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.Tenants.Dtos; |
|||
using CompanyName.ProjectName.Extension.Customs.Dtos; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using CompanyName.ProjectName.Tenants; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Swashbuckle.AspNetCore.Annotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
using Volo.Abp.TenantManagement; |
|||
|
|||
namespace CompanyName.ProjectName.Controllers.Tenants |
|||
{ |
|||
[Route("Tenants")] |
|||
public class TenantController : ProjectNameController |
|||
public class TenantController : ProjectNameController, IVoloTenantAppService |
|||
{ |
|||
private readonly ITenantAppService _tenantAppService; |
|||
private readonly IVoloTenantAppService _voloTenantAppService; |
|||
|
|||
public TenantController(ITenantAppService tenantAppService) |
|||
public TenantController(IVoloTenantAppService voloTenantAppService) |
|||
{ |
|||
_tenantAppService = tenantAppService; |
|||
_voloTenantAppService = voloTenantAppService; |
|||
} |
|||
|
|||
[HttpPost("find")] |
|||
[SwaggerOperation(summary: "通过名称获取租户信息", Tags = new[] {"Tenants"})] |
|||
public Task<FindTenantResultDto> FindTenantByNameAsync(FindTenantByNameInput input) |
|||
{ |
|||
return _voloTenantAppService.FindTenantByNameAsync(input); |
|||
} |
|||
|
|||
[HttpPost("page")] |
|||
[SwaggerOperation(summary: "分页获取租户信息", Tags = new[] {"Tenants"})] |
|||
[SwaggerOperation(summary: "分页获取租户信息", Tags = new[] { "Tenants" })] |
|||
public Task<PagedResultDto<TenantDto>> ListAsync(PagingTenantInput input) |
|||
{ |
|||
var request = new GetTenantsInput {Filter = input.Filter, SkipCount = input.SkipCount, MaxResultCount = input.PageSize}; |
|||
return _tenantAppService.GetListAsync(request); |
|||
return _voloTenantAppService.ListAsync(input); |
|||
} |
|||
|
|||
[HttpPost("create")] |
|||
[SwaggerOperation(summary: "创建租户", Tags = new[] {"Tenants"})] |
|||
[SwaggerOperation(summary: "创建租户", Tags = new[] { "Tenants" })] |
|||
public Task<TenantDto> CreateAsync(TenantCreateDto input) |
|||
{ |
|||
return _tenantAppService.CreateAsync(input); |
|||
return _voloTenantAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpPost("update")] |
|||
[SwaggerOperation(summary: "更新租户", Tags = new[] {"Tenants"})] |
|||
[SwaggerOperation(summary: "更新租户", Tags = new[] { "Tenants" })] |
|||
public Task<TenantDto> UpdateAsync(UpdateTenantInput input) |
|||
{ |
|||
var request = new TenantUpdateDto() |
|||
{ |
|||
Name = input.Name.Trim() |
|||
}; |
|||
return _tenantAppService.UpdateAsync(input.Id, request); |
|||
return _voloTenantAppService.UpdateAsync(input); |
|||
} |
|||
|
|||
[HttpPost("delete")] |
|||
[SwaggerOperation(summary: "删除租户", Tags = new[] {"Tenants"})] |
|||
[SwaggerOperation(summary: "删除租户", Tags = new[] { "Tenants" })] |
|||
public Task DeleteAsync(IdInput input) |
|||
{ |
|||
return _tenantAppService.DeleteAsync(input.Id); |
|||
return _voloTenantAppService.DeleteAsync(input); |
|||
} |
|||
|
|||
[HttpPost("getConnectionString")] |
|||
[SwaggerOperation(summary: "获取租户连接字符串", Tags = new[] {"Tenants"})] |
|||
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)] |
|||
[SwaggerOperation(summary: "获取租户连接字符串", Tags = new[] { "Tenants" })] |
|||
public Task<string> GetDefaultConnectionStringAsync(IdInput input) |
|||
{ |
|||
return _tenantAppService.GetDefaultConnectionStringAsync(input.Id); |
|||
return _voloTenantAppService.GetDefaultConnectionStringAsync(input); |
|||
} |
|||
|
|||
[HttpPost("updateConnectionString")] |
|||
[SwaggerOperation(summary: "更新租户连接字符串", Tags = new[] {"Tenants"})] |
|||
[SwaggerOperation(summary: "更新租户连接字符串", Tags = new[] { "Tenants" })] |
|||
public Task UpdateDefaultConnectionStringAsync(UpdateConnectionStringInput input) |
|||
{ |
|||
return _tenantAppService.UpdateDefaultConnectionStringAsync(input.Id, input.ConnectionString); |
|||
return _voloTenantAppService.UpdateDefaultConnectionStringAsync(input); |
|||
} |
|||
|
|||
[HttpPost("deleteConnectionString")] |
|||
[SwaggerOperation(summary: "删除租户连接字符串", Tags = new[] {"Tenants"})] |
|||
[SwaggerOperation(summary: "删除租户连接字符串", Tags = new[] { "Tenants" })] |
|||
public Task DeleteDefaultConnectionStringAsync(IdInput input) |
|||
{ |
|||
return _tenantAppService.DeleteDefaultConnectionStringAsync(input.Id); |
|||
return _voloTenantAppService.DeleteDefaultConnectionStringAsync(input); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
Loading…
Reference in new issue