| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using System.Threading.Tasks;
- using Abp.Application.Services.Dto;
- using Abp.Authorization;
- using Abp.Domain.Entities;
- using Abp.Domain.Repositories;
- using WePlatform.Authorization.Users;
- using WePlatform.CommonManager.AppGuids;
- using WePlatform.CommonManager.AttachFiles;
- using WePlatform.CommonManager.Notifications;
- using WePlatform.CommonManager.States;
- using WePlatform.Configuration;
- using IwbZero.AppServiceBase;
- using IwbZero.Authorization.Base.Permissions;
- using IwbZero.Authorization.Base.Users;
- namespace WePlatform
- {
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput, TGetInput, TDeleteInput>
- : IwbZeroAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput, TGetInput, TDeleteInput>
- where TEntity : class, IEntity<TPrimaryKey>
- where TEntityDto : IEntityDto<TPrimaryKey>
- where TUpdateInput : IEntityDto<TPrimaryKey>
- where TGetInput : IEntityDto<TPrimaryKey>
- where TDeleteInput : IEntityDto<TPrimaryKey>
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, TPrimaryKey> repository, string keyFiledName = null) : base(repository, keyFiledName)
- {
- AppGuidManager = NullAppGuidManager.Instance;
- AttachFileManager = NullAttachFileManager.Instance;
- StatesManager = NullStatesManager.Instance;
- NoticeManager = NullNotificationManager.Instance;
- }
- /// <summary>
- /// 系统字典管理
- /// </summary>
- public IStatesManager StatesManager { get; set; }
- /// <summary>
- /// 系统附件管理
- /// </summary>
- public IAttachFileManager AttachFileManager { get; set; }
- /// <summary>
- /// 系统GUID管理
- /// </summary>
- public IAppGuidManager AppGuidManager { get; set; }
- /// <summary>
- /// 用户信息管理
- /// </summary>
- public UserManager UserManager { get; set; }
- public INotificationManager NoticeManager { get; set; }
- #region DataPermission
- protected virtual async Task CheckDataPermission(string permissionName, string key, int operType)
- {
- if (string.IsNullOrEmpty(permissionName))
- {
- ThrowError("DataPermissionNameIsNull");
- return;
- }
- var useId = AbpSession.UserId ?? 0;
- if (useId == 0)
- {
- ThrowError("UserSessionTimeout");
- return;
- }
- if (AbpSession.UserName != UserBase.AdminUserName && AbpSession.UserName != UserBase.SystemUserName)
- {
- if (!await UserManager.IsGrantedAsync(useId, key, operType, permissionName))
- {
- throw new AbpAuthorizationException(L(IwbLanguageMessage.NoPermissionOperation));
- }
- }
- }
- protected virtual async Task CheckDataQueryPermission(string permissionName, string key)
- {
- await CheckDataPermission(permissionName, key, (int)OperType.Query);
- }
- protected virtual async Task CheckDataUpdatePermission(string permissionName, string key)
- {
- await CheckDataPermission(permissionName, key, (int)OperType.Update);
- }
- protected virtual async Task CheckDataDeletePermission(string permissionName, string key)
- {
- await CheckDataPermission(permissionName, key, (int)OperType.Delete);
- }
- #endregion
- }
- #region AppService
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto>
- : IwbAsyncCrudAppService<TEntity, TEntityDto, int>
- where TEntity : class, IEntity<int>
- where TEntityDto : IEntityDto<int>
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, int> repository, string keyFiledName = null)
- : base(repository)
- {
- KeyFiledName = keyFiledName;
- }
- }
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey>
- : IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, IIwbPagedRequest>
- where TEntity : class, IEntity<TPrimaryKey>
- where TEntityDto : IEntityDto<TPrimaryKey>
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, TPrimaryKey> repository, string keyFiledName = null)
- : base(repository)
- {
- KeyFiledName = keyFiledName;
- }
- }
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput>
- : IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TEntityDto, TEntityDto>
- where TEntity : class, IEntity<TPrimaryKey>
- where TEntityDto : IEntityDto<TPrimaryKey>
- where TGetAllInput : IIwbPagedRequest
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, TPrimaryKey> repository, string keyFiledName = null)
- : base(repository)
- {
- KeyFiledName = keyFiledName;
- }
- }
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput>
- : IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TCreateInput>
- where TGetAllInput : IIwbPagedRequest
- where TEntity : class, IEntity<TPrimaryKey>
- where TEntityDto : IEntityDto<TPrimaryKey>
- where TCreateInput : IEntityDto<TPrimaryKey>
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, TPrimaryKey> repository, string keyFiledName = null)
- : base(repository)
- {
- KeyFiledName = keyFiledName;
- }
- }
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput>
- : IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput, EntityDto<TPrimaryKey>>
- where TEntity : class, IEntity<TPrimaryKey>
- where TEntityDto : IEntityDto<TPrimaryKey>
- where TUpdateInput : IEntityDto<TPrimaryKey>
- where TGetAllInput : IIwbPagedRequest
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, TPrimaryKey> repository, string keyFiledName = null)
- : base(repository)
- {
- KeyFiledName = keyFiledName;
- }
- }
- public abstract class IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput, TGetInput>
- : IwbAsyncCrudAppService<TEntity, TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput, TGetInput, EntityDto<TPrimaryKey>>
- where TEntity : class, IEntity<TPrimaryKey>
- where TEntityDto : IEntityDto<TPrimaryKey>
- where TUpdateInput : IEntityDto<TPrimaryKey>
- where TGetInput : IEntityDto<TPrimaryKey>
- where TGetAllInput : IIwbPagedRequest
- {
- protected IwbAsyncCrudAppService(IRepository<TEntity, TPrimaryKey> repository, string keyFiledName = null)
- : base(repository)
- {
- KeyFiledName = keyFiledName;
- }
- }
- #endregion
- }
|