10 changed files with 358 additions and 9 deletions
-
8src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs
-
4src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs
-
4src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs
-
27src/Shentun.Peis.Application.Contracts/CollectItemTypes/CollectItemTypeDto.cs
-
22src/Shentun.Peis.Application.Contracts/CollectItemTypes/CreateCollectItemTypeDto.cs
-
23src/Shentun.Peis.Application.Contracts/CollectItemTypes/UpdateCollectItemTypeDto.cs
-
1src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs
-
164src/Shentun.Peis.Application/CollectItemTypes/CollectItemTypeAppService.cs
-
7src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
-
107src/Shentun.Peis.Domain/CollectItemTypes/CollectItemTypeManager.cs
@ -0,0 +1,27 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CollectItemTypes |
||||
|
{ |
||||
|
public class CollectItemTypeDto : AuditedEntityDtoName |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
|
||||
|
public string SimpleCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 发票项目类别ID
|
||||
|
/// </summary>
|
||||
|
public Guid InvoiceItemTypeId { get; set; } |
||||
|
|
||||
|
|
||||
|
public int DisplayOrder { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CollectItemTypes |
||||
|
{ |
||||
|
public class CreateCollectItemTypeDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 发票项目类别ID
|
||||
|
/// </summary>
|
||||
|
public Guid InvoiceItemTypeId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CollectItemTypes |
||||
|
{ |
||||
|
public class UpdateCollectItemTypeDto |
||||
|
{ |
||||
|
|
||||
|
public Guid Id { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 发票项目类别ID
|
||||
|
/// </summary>
|
||||
|
public Guid InvoiceItemTypeId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,164 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Shentun.Peis.ColumnReferences; |
||||
|
using Shentun.Peis.HelperDto; |
||||
|
using Shentun.Peis.InvoiceItemTypes; |
||||
|
using Shentun.Peis.Models; |
||||
|
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.Abp.Identity; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace Shentun.Peis.CollectItemTypes |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 汇总项目类别
|
||||
|
/// </summary>
|
||||
|
[ApiExplorerSettings(GroupName = "Work")] |
||||
|
[Authorize] |
||||
|
public class CollectItemTypeAppService : ApplicationService |
||||
|
{ |
||||
|
private readonly IRepository<CollectItemType, Guid> _collectItemTypeRepository; |
||||
|
private readonly CollectItemTypeManager _manager; |
||||
|
private readonly CacheService _cacheService; |
||||
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
||||
|
|
||||
|
public CollectItemTypeAppService( |
||||
|
IRepository<CollectItemType, Guid> collectItemTypeRepository, |
||||
|
IRepository<IdentityUser, Guid> userRepository, |
||||
|
CollectItemTypeManager manager) |
||||
|
{ |
||||
|
_collectItemTypeRepository = collectItemTypeRepository; |
||||
|
_userRepository = userRepository; |
||||
|
_manager = manager; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据ID查实体内容
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/Get")] |
||||
|
public async Task<CollectItemTypeDto> GetAsync(Guid id) |
||||
|
{ |
||||
|
var entity = await _collectItemTypeRepository.GetAsync(id); |
||||
|
var entityDto = ObjectMapper.Map<CollectItemType, CollectItemTypeDto>(entity); |
||||
|
entityDto.CreatorName = _cacheService.GetSurnameAsync(entityDto.CreatorId).Result; |
||||
|
entityDto.LastModifierName = _cacheService.GetSurnameAsync(entityDto.LastModifierId).Result; |
||||
|
|
||||
|
return entityDto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询列表
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/GetList")] |
||||
|
public async Task<List<CollectItemTypeDto>> GetListAsync() |
||||
|
{ |
||||
|
var userQueryable = await _userRepository.GetQueryableAsync(); |
||||
|
|
||||
|
var entlist = (from a in await _collectItemTypeRepository.GetQueryableAsync() |
||||
|
join b in userQueryable on a.CreatorId equals b.Id into bb |
||||
|
from ab in bb.DefaultIfEmpty() |
||||
|
join c in userQueryable on a.LastModifierId equals c.Id into cc |
||||
|
from ac in cc.DefaultIfEmpty() |
||||
|
select new |
||||
|
{ |
||||
|
a, |
||||
|
CreatorName = ab != null ? ab.Surname : "", |
||||
|
LastModifierName = ac != null ? ac.Surname : "" |
||||
|
|
||||
|
}) |
||||
|
.Select(s => new CollectItemTypeDto |
||||
|
{ |
||||
|
CreationTime = s.a.CreationTime, |
||||
|
CreatorId = s.a.CreatorId, |
||||
|
LastModifierId = s.a.LastModifierId, |
||||
|
Id = s.a.Id, |
||||
|
DisplayOrder = s.a.DisplayOrder, |
||||
|
DisplayName = s.a.DisplayName, |
||||
|
InvoiceItemTypeId = s.a.InvoiceItemTypeId, |
||||
|
SimpleCode = s.a.SimpleCode, |
||||
|
LastModificationTime = s.a.LastModificationTime, |
||||
|
CreatorName = s.CreatorName, |
||||
|
LastModifierName = s.LastModifierName |
||||
|
}).OrderBy(o => o.DisplayOrder).ToList(); |
||||
|
|
||||
|
return entlist; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/Create")] |
||||
|
public async Task<CollectItemTypeDto> CreateAsync(CreateCollectItemTypeDto input) |
||||
|
{ |
||||
|
var createEntity = ObjectMapper.Map<CreateCollectItemTypeDto, CollectItemType>(input); |
||||
|
var entity = await _manager.CreateAsync(createEntity); |
||||
|
entity = await _collectItemTypeRepository.InsertAsync(entity); |
||||
|
var dto = ObjectMapper.Map<CollectItemType, CollectItemTypeDto>(entity); |
||||
|
return dto; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/Update")] |
||||
|
public async Task<CollectItemTypeDto> UpdateAsync(UpdateCollectItemTypeDto input) |
||||
|
{ |
||||
|
var entity = await _collectItemTypeRepository.GetAsync(input.Id); |
||||
|
var sourceEntity = ObjectMapper.Map<UpdateCollectItemTypeDto, CollectItemType>(input); |
||||
|
await _manager.UpdateAsync(sourceEntity, entity); |
||||
|
entity = await _collectItemTypeRepository.UpdateAsync(entity); |
||||
|
return ObjectMapper.Map<CollectItemType, CollectItemTypeDto>(entity); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/Delete")] |
||||
|
public async Task DeleteAsync(Guid id) |
||||
|
{ |
||||
|
var entity = await _collectItemTypeRepository.GetAsync(id); |
||||
|
await _manager.CheckAndDeleteAsync(entity); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 置顶,置底
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">需要修改的ID</param>
|
||||
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/UpdateManySort")] |
||||
|
public async Task UpdateManySortAsync(Guid id, int SortType) |
||||
|
{ |
||||
|
await _manager.UpdateManySortAsync(id, SortType); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 拖拽
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CollectItemType/UpdateSortMany")] |
||||
|
public async Task UpdateSortManyAsync(UpdateSortManyDto input) |
||||
|
{ |
||||
|
await _manager.UpdateSortManyAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,107 @@ |
|||||
|
using Shentun.Peis.Enums; |
||||
|
using Shentun.Peis.HelperDto; |
||||
|
using Shentun.Peis.Models; |
||||
|
using Shentun.Utilities; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Shentun.Peis.CollectItemTypes |
||||
|
{ |
||||
|
public class CollectItemTypeManager : DomainService |
||||
|
{ |
||||
|
|
||||
|
private readonly IRepository<CollectItemType, Guid> _repository; |
||||
|
|
||||
|
public CollectItemTypeManager( |
||||
|
IRepository<CollectItemType, Guid> repository |
||||
|
) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="entity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task<CollectItemType> CreateAsync( |
||||
|
CollectItemType entity |
||||
|
) |
||||
|
{ |
||||
|
|
||||
|
Verify(entity); |
||||
|
await EntityHelper.CheckSameName(_repository, entity.DisplayName); |
||||
|
return new CollectItemType( |
||||
|
GuidGenerator.Create() |
||||
|
) |
||||
|
{ |
||||
|
DisplayName = entity.DisplayName, |
||||
|
InvoiceItemTypeId = entity.InvoiceItemTypeId, |
||||
|
SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName), |
||||
|
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder(_repository) |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
public async Task UpdateAsync( |
||||
|
CollectItemType sourceEntity, |
||||
|
CollectItemType targetEntity |
||||
|
) |
||||
|
{ |
||||
|
DataHelper.CheckEntityIsNull(targetEntity); |
||||
|
Verify(sourceEntity); |
||||
|
if (sourceEntity.DisplayName != targetEntity.DisplayName) |
||||
|
{ |
||||
|
await EntityHelper.CheckSameName<CollectItemType, Guid>(_repository, sourceEntity.DisplayName, targetEntity); |
||||
|
targetEntity.DisplayName = sourceEntity.DisplayName; |
||||
|
targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(sourceEntity.DisplayName); |
||||
|
} |
||||
|
targetEntity.InvoiceItemTypeId = sourceEntity.InvoiceItemTypeId; |
||||
|
} |
||||
|
|
||||
|
public async Task CheckAndDeleteAsync(CollectItemType entity) |
||||
|
{ |
||||
|
await _repository.DeleteAsync(entity); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 置顶,置底
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">需要修改的ID</param>
|
||||
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateManySortAsync(Guid id, int SortType) |
||||
|
{ |
||||
|
await EntityHelper.UpdateManySortAsync(_repository, id, SortType); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 拖拽
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||
|
/// <param name="repository"></param>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateSortManyAsync(UpdateSortManyDto input) |
||||
|
{ |
||||
|
await EntityHelper.UpdateSortManyAsync(_repository, input); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
private void Verify(CollectItemType entity) |
||||
|
{ |
||||
|
DataHelper.CheckEntityIsNull(entity); |
||||
|
DataHelper.CheckStringIsNull(entity.DisplayName, "名称"); |
||||
|
DataHelper.CheckGuidIsDefaultValue(entity.InvoiceItemTypeId, "配置参数"); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue