| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using Abp.Authorization;
- using Abp.Domain.Repositories;
- using Abp.Linq.Extensions;
- using Abp.Runtime.Caching;
- using VberZero.AppService.Base;
- using VberZero.AppService.Base.Dto;
- using VberZero.AppService.States.Dto;
- using VberZero.Auditing;
- using VberZero.BaseSystem;
- using VberZero.BaseSystem.Users;
- using VberZero.Session;
- using VberZero.Tools.StringModel;
- namespace VberZero.AppService.States;
- [AbpAuthorize, AuditLog("字典管理", "字典")]
- public class StateAppServiceBase : VzCrudAppServiceBase<SysState, StateDto, int, VzPagedRequestDto, StateCreateDto, StateUpdateDto>, IStateAppServiceBase
- {
- public StateAppServiceBase(ICacheManager cacheManager, IRepository<SysState, int> repository) : base(repository, "StateNo")
- {
- CacheManager = cacheManager;
- }
- protected override string KeyExistMessage => string.Format(L("KeyExistMessageFormatter"), L("state"));
- protected override string KeyNotExistMessage => string.Format(L("KeyNotExistMessageFormatter"), L("state"));
- public override Task Create(StateCreateDto input)
- {
- return Task.CompletedTask;
- }
- public override async Task Update(StateUpdateDto input)
- {
- //if (AbpSession.GetUserName() != User.AdminUserName && AbpSession.GetUserName() != User.SystemUserName)
- //{
- // ThrowError("NoPermissionOperation");
- //}
- if (AbpSession.GetUserType() > VzDefinition.UserType.System)
- {
- ThrowError("NoPermissionOperation");
- }
- CheckUpdatePermission();
- var entity = await GetEntity(input);
- await UpdateEntity(input, entity);
- await CacheManager.GetCache(VzConsts.CacheSysState)
- .RemoveAsync(entity.CodeKey + "." + entity.CodeValue);
- }
- public override async Task Delete(VzEntityDto<int> input)
- {
- #if DEBUG
- if (AbpSession.GetUserName() != User.AdminUserName && AbpSession.GetUserName() != User.SystemUserName)
- {
- ThrowError("NoPermissionOperation");
- }
- await base.Delete(input);
- #else
- ThrowError("CanNotDelete");
- #endif
- }
- protected override IQueryable<T> SelfSorting<T>(IQueryable<T> query, VzPagedRequestDto input)
- {
- if (query is IQueryable<SysState> queryable)
- return (IQueryable<T>)queryable.OrderByDescending(r => r.Id);
- return query;
- }
- protected override IQueryable<T> KeyWordFilter<T>(IQueryable<T> query, string keyword)
- {
- if (query is IQueryable<SysState> queryable)
- return (IQueryable<T>)queryable.WhereIf(keyword.NotEmpty(), a =>
- a.CodeKey.Contains(keyword) ||
- a.CodeValue.Contains(keyword));
- return query;
- }
- }
|