You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using Shentun.Peis.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Volo.Abp.Domain.Repositories;
  8. using Volo.Abp;
  9. using Volo.Abp.Domain.Services;
  10. using Shentun.Peis.HelperDto;
  11. namespace Shentun.Peis.ColumnReferences
  12. {
  13. public class ColumnReferenceManager: DomainService
  14. {
  15. private readonly IRepository<ColumnReference, Guid> _repository;
  16. public ColumnReferenceManager(
  17. IRepository<ColumnReference, Guid> repository
  18. )
  19. {
  20. _repository = repository;
  21. }
  22. /// <summary>
  23. /// 创建
  24. /// </summary>
  25. /// <param name="entity"></param>
  26. /// <returns></returns>
  27. public async Task<ColumnReference> CreateAsync(
  28. ColumnReference entity
  29. )
  30. {
  31. DataHelper.CheckEntityIsNull(entity);
  32. //Verify(entity);
  33. await EntityHelper.CheckSameName(_repository, entity.DisplayName);
  34. return new ColumnReference(
  35. GuidGenerator.Create()
  36. )
  37. {
  38. DisplayName = entity.DisplayName,
  39. ParmValue = entity.ParmValue,
  40. DisplayOrder = await EntityHelper.CreateMaxDisplayOrder(_repository),
  41. };
  42. }
  43. public async Task UpdateAsync(
  44. ColumnReference sourceEntity,
  45. ColumnReference targetEntity
  46. )
  47. {
  48. DataHelper.CheckEntityIsNull(sourceEntity);
  49. DataHelper.CheckEntityIsNull(targetEntity);
  50. if (sourceEntity.DisplayName != targetEntity.DisplayName)
  51. {
  52. await EntityHelper.CheckSameName<ColumnReference, Guid>(_repository, sourceEntity.DisplayName, targetEntity);
  53. targetEntity.DisplayName = sourceEntity.DisplayName;
  54. }
  55. targetEntity.ParmValue = sourceEntity.ParmValue;
  56. }
  57. public async Task CheckAndDeleteAsync(ColumnReference entity)
  58. {
  59. await _repository.DeleteAsync(entity);
  60. }
  61. /// <summary>
  62. /// 修改排序 置顶,置底
  63. /// </summary>
  64. /// <param name="id">需要修改的ID</param>
  65. /// <param name="SortType">修改方式:1 置顶 2 置底</param>
  66. /// <returns></returns>
  67. public async Task UpdateManySortAsync(Guid id, int SortType)
  68. {
  69. await EntityHelper.UpdateManySortAsync(_repository, id, SortType);
  70. }
  71. /// <summary>
  72. /// 修改排序 拖拽
  73. /// </summary>
  74. /// <typeparam name="TEntity"></typeparam>
  75. /// <param name="repository"></param>
  76. /// <param name="input"></param>
  77. /// <returns></returns>
  78. public async Task UpdateSortManyAsync(UpdateSortManyDto input)
  79. {
  80. await EntityHelper.UpdateSortManyAsync(_repository, input);
  81. }
  82. }
  83. }