DepartmentsApplicationService.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using System.Web.Mvc;
  4. using Abp.Application.Services.Dto;
  5. using Abp.Authorization;
  6. using Abp.Domain.Repositories;
  7. using IwbZero.AppServiceBase;
  8. using IwbZero.IdentityFramework;
  9. using ShwasherSys.Authorization.Permissions;
  10. using ShwasherSys.BasicInfo.Departments.Dto;
  11. namespace ShwasherSys.BasicInfo.Departments
  12. {
  13. [AbpAuthorize]
  14. public class DepartmentsAppService : ShwasherAsyncCrudAppService<Department, DepartmentDto, string, PagedRequestDto, DepartmentCreateDto, DepartmentUpdateDto >, IDepartmentsAppService
  15. {
  16. public DepartmentsAppService(IRepository<Department, string> repository) : base(repository)
  17. {
  18. KeyIsAuto = false;
  19. }
  20. protected override string GetPermissionName { get; set; } = PermissionNames.PagesBasicInfoDepartments;
  21. protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesBasicInfoDepartments;
  22. protected override string CreatePermissionName { get; set; } = PermissionNames.PagesBasicInfoDepartmentsCreate;
  23. protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesBasicInfoDepartmentsUpdate;
  24. protected override string DeletePermissionName { get; set; } = PermissionNames.PagesBasicInfoDepartmentsDelete;
  25. public override async Task Delete(EntityDto<string> input)
  26. {
  27. CheckDeletePermission();
  28. var entity = await Repository.FirstOrDefaultAsync(a => a.Id == input.Id);
  29. /*if ((await Repository.GetAllListAsync(a => a.FatherRegionID == entity.Id && a.IsLock == "N")).Any())
  30. {
  31. CheckErrors(IwbIdentityResult.Failed("此菜单下还有子区域,不能删除"));
  32. }*/
  33. entity.IsLock = "Y";
  34. // await Repository.UpdateAsync(entity);
  35. await CurrentUnitOfWork.SaveChangesAsync();
  36. }
  37. public List<SelectListItem> GetDepartmentsSelects()
  38. {
  39. var slist = new List<SelectListItem>();
  40. var list = Repository.GetAll();
  41. foreach (var l in list)
  42. {
  43. slist.Add(new SelectListItem { Text = l.DepartmentName, Value = l.Id });
  44. }
  45. return slist;
  46. }
  47. }
  48. }