Skip to content

Commit

Permalink
应用层版本注释
Browse files Browse the repository at this point in the history
  • Loading branch information
boydg123 committed Jul 17, 2017
1 parent 2f931b5 commit 6672b99
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Derrick.Authorization.Permissions.Dto
{
/// <summary>
/// 统一权限Dto
/// 平级权限Dto
/// </summary>
[AutoMapFrom(typeof(Abp.Authorization.Permission))]
public class FlatPermissionDto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Derrick.Authorization.Permissions.Dto
{
/// <summary>
/// ͳһȨÏÞ¼¶±ðDto
/// ƽ¼¶È¨ÏÞ¼¶±ðDto
/// </summary>
public class FlatPermissionWithLevelDto : FlatPermissionDto
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

namespace Derrick.Editions.Dto
{
/// <summary>
/// 创建或更新版本Dto
/// </summary>
public class CreateOrUpdateEditionDto
{
/// <summary>
/// 版本编辑Dto
/// </summary>
[Required]
public EditionEditDto Edition { get; set; }

/// <summary>
/// 功能值列表
/// </summary>
[Required]
public List<NameValueDto> FeatureValues { get; set; }
}
Expand Down
9 changes: 9 additions & 0 deletions zero/Derrick.Application/Editions/Dto/EditionEditDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

namespace Derrick.Editions.Dto
{
/// <summary>
/// °æ±¾±à¼­Dto
/// </summary>
[AutoMap(typeof(Edition))]
public class EditionEditDto
{
/// <summary>
/// ID
/// </summary>
public int? Id { get; set; }

/// <summary>
/// ÏÔʾÃû
/// </summary>
[Required]
public string DisplayName { get; set; }
}
Expand Down
12 changes: 12 additions & 0 deletions zero/Derrick.Application/Editions/Dto/EditionListDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@

namespace Derrick.Editions.Dto
{
/// <summary>
/// 版本列表Dto
/// </summary>
[AutoMapFrom(typeof(Edition))]
public class EditionListDto : EntityDto, IHasCreationTime
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }

/// <summary>
/// 显示名
/// </summary>
public string DisplayName { get; set; }

/// <summary>
/// 创建时间
/// </summary>
public DateTime CreationTime { get; set; }
}
}
26 changes: 21 additions & 5 deletions zero/Derrick.Application/Editions/Dto/FlatFeatureDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@

namespace Derrick.Editions.Dto
{
/// <summary>
/// 平级功能Dto
/// </summary>
[AutoMapFrom(typeof(Feature))]
public class FlatFeatureDto
{
/// <summary>
/// 父Name
/// </summary>
public string ParentName { get; set; }

/// <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 DefaultValue { get; set; }

/// <summary>
/// Input类型
/// </summary>
public IInputType InputType { get; set; }
}
}
14 changes: 12 additions & 2 deletions zero/Derrick.Application/Editions/Dto/GetEditionForEditOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@

namespace Derrick.Editions.Dto
{
/// <summary>
/// 版本编辑Output
/// </summary>
public class GetEditionForEditOutput
{
/// <summary>
/// 版本编辑Dto
/// </summary>
public EditionEditDto Edition { get; set; }

/// <summary>
/// 功能值Dto
/// </summary>
public List<NameValueDto> FeatureValues { get; set; }

/// <summary>
/// 平级功能列表
/// </summary>
public List<FlatFeatureDto> Features { get; set; }
}
}
59 changes: 50 additions & 9 deletions zero/Derrick.Application/Editions/EditionAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,40 @@

namespace Derrick.Editions
{
/// <summary>
/// 版本服务实现
/// </summary>
[AbpAuthorize(AppPermissions.Pages_Editions)]
public class EditionAppService : AbpZeroTemplateAppServiceBase, IEditionAppService
{
/// <summary>
/// 版本管理器
/// </summary>
private readonly EditionManager _editionManager;

/// <summary>
/// 构造函数
/// </summary>
/// <param name="editionManager">版本管理器</param>
public EditionAppService(EditionManager editionManager)
{
_editionManager = editionManager;
}

/// <summary>
/// 获取版本列表
/// </summary>
/// <returns></returns>
public async Task<ListResultDto<EditionListDto>> GetEditions()
{
var editions = await _editionManager.Editions.ToListAsync();
return new ListResultDto<EditionListDto>(
editions.MapTo<List<EditionListDto>>()
);
}

/// <summary>
/// 为编辑获取版本
/// </summary>
/// <param name="input">空ID Dto</param>
/// <returns></returns>
[AbpAuthorize(AppPermissions.Pages_Editions_Create, AppPermissions.Pages_Editions_Edit)]
public async Task<GetEditionForEditOutput> GetEditionForEdit(NullableIdDto input)
{
Expand Down Expand Up @@ -58,7 +74,11 @@ public async Task<GetEditionForEditOutput> GetEditionForEdit(NullableIdDto input
FeatureValues = featureValues.Select(fv => new NameValueDto(fv)).ToList()
};
}

/// <summary>
/// 创建或更新版本
/// </summary>
/// <param name="input">创建或更新版本Dto</param>
/// <returns></returns>
[AbpAuthorize(AppPermissions.Pages_Editions_Create, AppPermissions.Pages_Editions_Edit)]
public async Task CreateOrUpdateEdition(CreateOrUpdateEditionDto input)
{
Expand All @@ -71,14 +91,22 @@ public async Task CreateOrUpdateEdition(CreateOrUpdateEditionDto input)
await UpdateEditionAsync(input);
}
}

/// <summary>
/// 删除版本
/// </summary>
/// <param name="input">实体Dto</param>
/// <returns></returns>
[AbpAuthorize(AppPermissions.Pages_Editions_Delete)]
public async Task DeleteEdition(EntityDto input)
{
var edition = await _editionManager.GetByIdAsync(input.Id);
await _editionManager.DeleteAsync(edition);
}

/// <summary>
/// 获取Combobox版本集合
/// </summary>
/// <param name="selectedEditionId">选中版本的ID</param>
/// <returns></returns>
public async Task<List<ComboboxItemDto>> GetEditionComboboxItems(int? selectedEditionId = null)
{
var editions = await _editionManager.Editions.ToListAsync();
Expand All @@ -102,7 +130,11 @@ public async Task<List<ComboboxItemDto>> GetEditionComboboxItems(int? selectedEd

return editionItems;
}

/// <summary>
/// 创建版本
/// </summary>
/// <param name="input">创建或更新版本Dto</param>
/// <returns></returns>
[AbpAuthorize(AppPermissions.Pages_Editions_Create)]
protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input)
{
Expand All @@ -113,7 +145,11 @@ protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input)

await SetFeatureValues(edition, input.FeatureValues);
}

/// <summary>
/// 更新版本
/// </summary>
/// <param name="input">创建或更新版本Dto</param>
/// <returns></returns>
[AbpAuthorize(AppPermissions.Pages_Editions_Edit)]
protected virtual async Task UpdateEditionAsync(CreateOrUpdateEditionDto input)
{
Expand All @@ -124,7 +160,12 @@ protected virtual async Task UpdateEditionAsync(CreateOrUpdateEditionDto input)

await SetFeatureValues(edition, input.FeatureValues);
}

/// <summary>
/// 设置功能值
/// </summary>
/// <param name="edition">版本</param>
/// <param name="featureValues">功能值</param>
/// <returns></returns>
private Task SetFeatureValues(Edition edition, List<NameValueDto> featureValues)
{
return _editionManager.SetFeatureValuesAsync(edition.Id, featureValues.Select(fv => new NameValue(fv.Name, fv.Value)).ToArray());
Expand Down
29 changes: 28 additions & 1 deletion zero/Derrick.Application/Editions/IEditionAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,43 @@

namespace Derrick.Editions
{
/// <summary>
/// 版本服务
/// </summary>
public interface IEditionAppService : IApplicationService
{
/// <summary>
/// 获取版本列表
/// </summary>
/// <returns></returns>
Task<ListResultDto<EditionListDto>> GetEditions();

/// <summary>
/// 为编辑获取版本
/// </summary>
/// <param name="input">空ID Dto</param>
/// <returns></returns>
Task<GetEditionForEditOutput> GetEditionForEdit(NullableIdDto input);

/// <summary>
/// 创建或更新版本
/// </summary>
/// <param name="input">创建或更新版本Dto</param>
/// <returns></returns>
Task CreateOrUpdateEdition(CreateOrUpdateEditionDto input);

/// <summary>
/// 删除版本
/// </summary>
/// <param name="input">实体Dto</param>
/// <returns></returns>
Task DeleteEdition(EntityDto input);


/// <summary>
/// 获取Combobox版本集合
/// </summary>
/// <param name="selectedEditionId">选中版本的ID</param>
/// <returns></returns>
Task<List<ComboboxItemDto>> GetEditionComboboxItems(int? selectedEditionId = null);
}
}

0 comments on commit 6672b99

Please sign in to comment.