mirror of https://github.com/abpframework/abp.git
10 changed files with 247 additions and 20 deletions
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public interface ITagAdminAppService : ICrudAppService<TagDto, Guid, TagGetListInput, TagCreateDto, TagUpdateDto> |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class TagCreateDto |
|||
{ |
|||
[Required] |
|||
public string EntityType { get; set; } |
|||
[Required] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class TagGetListInput : PagedAndSortedResultRequestDto |
|||
{ |
|||
public string Filter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class TagUpdateDto |
|||
{ |
|||
[Required] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Localization; |
|||
using Volo.CmsKit.Localization; |
|||
|
|||
namespace Volo.CmsKit.Permissions |
|||
{ |
|||
public class CmsKitAdminPermissionDefinitionProvider : PermissionDefinitionProvider |
|||
{ |
|||
public override void Define(IPermissionDefinitionContext context) |
|||
{ |
|||
var cmsGroup = context.GetGroupOrNull(CmsKitAdminPermissions.GroupName) ?? context.AddGroup(CmsKitAdminPermissions.GroupName, L("Permission:CmsKit")); |
|||
|
|||
cmsGroup |
|||
.AddPermission(CmsKitAdminPermissions.Tags.Default, L("Permission:TagManagement")) |
|||
.AddChild(CmsKitAdminPermissions.Tags.Create, L("Permission:TagManagement.Create")) |
|||
.AddChild(CmsKitAdminPermissions.Tags.Update, L("Permission:TagManagement.Update")) |
|||
.AddChild(CmsKitAdminPermissions.Tags.Delete, L("Permission:TagManagement.Delete")); |
|||
} |
|||
|
|||
private static LocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<CmsKitResource>(name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using Volo.Abp.Reflection; |
|||
|
|||
namespace Volo.CmsKit.Permissions |
|||
{ |
|||
public class CmsKitAdminPermissions |
|||
{ |
|||
public const string GroupName = "CmsKit"; |
|||
public static class Tags |
|||
{ |
|||
public const string Default = GroupName + ".Tags"; |
|||
public const string Create = Default + ".Create"; |
|||
public const string Update = Default + ".Update"; |
|||
public const string Delete = Default + ".Delete"; |
|||
} |
|||
|
|||
public static string[] GetAll() |
|||
{ |
|||
return ReflectionHelper.GetPublicConstantsRecursively(typeof(CmsKitAdminPermissions)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.CmsKit.Admin.Tags; |
|||
using Volo.CmsKit.Permissions; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class TagAdminAppService : |
|||
CrudAppService< |
|||
Tag, |
|||
TagDto, |
|||
Guid, |
|||
TagGetListInput, |
|||
TagCreateDto, |
|||
TagUpdateDto>, |
|||
ITagAdminAppService |
|||
{ |
|||
protected ITagManager TagManager { get; } |
|||
|
|||
public TagAdminAppService( |
|||
IRepository<Tag, Guid> repository, |
|||
ITagManager tagManager) : base(repository) |
|||
{ |
|||
TagManager = tagManager; |
|||
|
|||
GetListPolicyName = CmsKitAdminPermissions.Tags.Default; |
|||
GetPolicyName = CmsKitAdminPermissions.Tags.Default; |
|||
CreatePolicyName = CmsKitAdminPermissions.Tags.Create; |
|||
UpdatePolicyName = CmsKitAdminPermissions.Tags.Update; |
|||
DeletePolicyName = CmsKitAdminPermissions.Tags.Delete; |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Tags.Create)] |
|||
public override async Task<TagDto> CreateAsync(TagCreateDto input) |
|||
{ |
|||
var inserted = await TagManager.InsertAsync( |
|||
GuidGenerator.Create(), |
|||
input.EntityType, |
|||
input.Name, |
|||
CurrentTenant?.Id); |
|||
return MapToGetOutputDto(inserted); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Tags.Update)] |
|||
public override async Task<TagDto> UpdateAsync(Guid id, TagUpdateDto input) |
|||
{ |
|||
var updated = await TagManager.UpdateAsync( |
|||
id, |
|||
input.Name); |
|||
|
|||
return MapToGetOutputDto(updated); |
|||
} |
|||
protected override IQueryable<Tag> CreateFilteredQuery(TagGetListInput input) |
|||
{ |
|||
return base.CreateFilteredQuery(input) |
|||
.WhereIf( |
|||
!string.IsNullOrEmpty(input.Filter), |
|||
x => |
|||
x.Name.ToLower().Contains(input.Filter) || |
|||
x.EntityType.ToLower().Contains(input.Filter)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.CmsKit.Admin.Tags; |
|||
using Volo.CmsKit.Permissions; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class TagController : CmsKitAdminController, ITagAdminAppService |
|||
{ |
|||
protected ITagAdminAppService TagAdminAppService { get; } |
|||
|
|||
public TagController(ITagAdminAppService tagAdminAppService) |
|||
{ |
|||
TagAdminAppService = tagAdminAppService; |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Authorize(CmsKitAdminPermissions.Tags.Create)] |
|||
public Task<TagDto> CreateAsync(TagCreateDto input) |
|||
{ |
|||
return TagAdminAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpDelete("{id}")] |
|||
[Authorize(CmsKitAdminPermissions.Tags.Delete)] |
|||
public Task DeleteAsync(Guid id) |
|||
{ |
|||
return TagAdminAppService.DeleteAsync(id); |
|||
} |
|||
|
|||
[HttpGet("{id}")] |
|||
[Authorize(CmsKitAdminPermissions.Tags.Default)] |
|||
public Task<TagDto> GetAsync(Guid id) |
|||
{ |
|||
return TagAdminAppService.GetAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Authorize(CmsKitAdminPermissions.Tags.Default)] |
|||
public Task<PagedResultDto<TagDto>> GetListAsync(TagGetListInput input) |
|||
{ |
|||
return TagAdminAppService.GetListAsync(input); |
|||
} |
|||
|
|||
[HttpPut("{id}")] |
|||
[Authorize(CmsKitAdminPermissions.Tags.Update)] |
|||
public Task<TagDto> UpdateAsync(Guid id, [FromBody] TagUpdateDto input) |
|||
{ |
|||
return TagAdminAppService.UpdateAsync(id, input); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +1,29 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"PickYourReaction": "Pick your reaction", |
|||
"YourComment": "Your comment", |
|||
"YourReply": "Your reply", |
|||
"CommentAuthorizationExceptionMessage": "Those comments are not allowed for public display.", |
|||
"Comments": "Comments", |
|||
"Send": "Send", |
|||
"Delete": "Delete", |
|||
"Reply": "Reply", |
|||
"Update": "Update", |
|||
"Edit": "Edit", |
|||
"LoginToAddComment": "Login to add comment", |
|||
"LoginToRate": "Login to rate", |
|||
"LoginToReply": "Login to reply", |
|||
"MessageDeletionConfirmationMessage": "This comment will be deleted completely.", |
|||
"CommentAuthorizationExceptionMessage": "Those comments are not allowed for public display.", |
|||
"Undo": "Undo", |
|||
"Permission:CmsKit": "CmsKit", |
|||
"Permission:TagManagement": "Tag Management", |
|||
"Permission:TagManagement.Create": "Create Tag", |
|||
"Permission:TagManagement.Delete": "Delete Tag", |
|||
"Permission:TagManagement.Update": "Update Tag", |
|||
"PickYourReaction": "Pick your reaction", |
|||
"RatingUndoMessage": "Your rating will be undo.", |
|||
"LoginToRate": "Login to rate", |
|||
"Star": "Star" |
|||
"Reply": "Reply", |
|||
"Send": "Send", |
|||
"Star": "Star", |
|||
"TagDeletionConfirmationMessage": "Are you sure to delete '{0}' tag?", |
|||
"Tags": "Tags", |
|||
"Undo": "Undo", |
|||
"Update": "Update", |
|||
"YourComment": "Your comment", |
|||
"YourReply": "Your reply" |
|||
} |
|||
} |
|||
|
|||
@ -1,22 +1,29 @@ |
|||
{ |
|||
"culture": "tr", |
|||
"texts": { |
|||
"PickYourReaction": "Tepkinizi seçin", |
|||
"YourComment": "Yorumunuz", |
|||
"YourReply": "Cevabınız", |
|||
"CommentAuthorizationExceptionMessage": "Bu yorumları görebilmek için yetki gerekir.", |
|||
"Comments": "Yorumlar", |
|||
"Send": "Gönder", |
|||
"Delete": "Sil", |
|||
"Reply": "Cevapla", |
|||
"Update": "Güncelle", |
|||
"Edit": "Düzenle", |
|||
"LoginToAddComment": "Yorum yapmak için giriş yap", |
|||
"LoginToRate": "Oylamak için giriş yapın", |
|||
"LoginToReply": "Cevap vermek için giriş yap", |
|||
"MessageDeletionConfirmationMessage": "Bu yorum tamamen silinecektir", |
|||
"CommentAuthorizationExceptionMessage": "Bu yorumları görebilmek için yetki gerekir.", |
|||
"Undo": "Geri al", |
|||
"Permission:CmsKit": "CmsKit", |
|||
"Permission:TagManagement": "Etiket Yönetimi", |
|||
"Permission:TagManagement.Create": "Etiket Oluşturma", |
|||
"Permission:TagManagement.Delete": "Etiket Silme", |
|||
"Permission:TagManagement.Update": "Etiket Güncelleme", |
|||
"PickYourReaction": "Tepkinizi seçin", |
|||
"RatingUndoMessage": "Oylamanız geri alınacak.", |
|||
"LoginToRate": "Oylamak için giriş yapın", |
|||
"Star": "Yıldız" |
|||
"Reply": "Cevapla", |
|||
"Send": "Gönder", |
|||
"Star": "Yıldız", |
|||
"TagDeletionConfirmationMessage": "'{0}' etiketini silmek istediğinize emin misiniz?", |
|||
"Tags": "Etiketler", |
|||
"Undo": "Geri al", |
|||
"Update": "Güncelle", |
|||
"YourComment": "Yorumunuz", |
|||
"YourReply": "Cevabınız" |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue