21 changed files with 914 additions and 8 deletions
-
15src/Shentun.Peis.Application.Contracts/AuditedEntityDtoName.cs
-
26src/Shentun.Peis.Application.Contracts/CommonTableTypes/CommonTableTypeDto.cs
-
12src/Shentun.Peis.Application.Contracts/CommonTableTypes/CommonTableTypeIdInputDto.cs
-
20src/Shentun.Peis.Application.Contracts/CommonTableTypes/CreateCommonTableTypeDto.cs
-
19src/Shentun.Peis.Application.Contracts/CommonTableTypes/UpdateCommonTableTypeDto.cs
-
20src/Shentun.Peis.Application.Contracts/CommonTableTypes/UpdateManySortCommonTableTypeInputDto.cs
-
31src/Shentun.Peis.Application.Contracts/CommonTables/CommonTableDto.cs
-
11src/Shentun.Peis.Application.Contracts/CommonTables/CommonTableIdInputDto.cs
-
27src/Shentun.Peis.Application.Contracts/CommonTables/CreateCommonTableDto.cs
-
26src/Shentun.Peis.Application.Contracts/CommonTables/UpdateCommonTableDto.cs
-
20src/Shentun.Peis.Application.Contracts/CommonTables/UpdateManySortCommonTableInputDto.cs
-
157src/Shentun.Peis.Application/CommonTableTypes/CommonTableTypeAppService.cs
-
159src/Shentun.Peis.Application/CommonTables/CommonTableAppService.cs
-
11src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
-
7src/Shentun.Peis.Domain/CommonTableTypes/CommonTableType.cs
-
120src/Shentun.Peis.Domain/CommonTableTypes/CommonTableTypeManager.cs
-
2src/Shentun.Peis.Domain/CommonTables/CommonTable.cs
-
122src/Shentun.Peis.Domain/CommonTables/CommonTableManager.cs
-
96src/Shentun.Peis.Domain/EntityHelper.cs
-
14src/Shentun.Peis.Domain/HelperDto/UpdateSortManyDto.cs
-
1src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/PeisDbContext.cs
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
public class CommonTableTypeDto: AuditedEntityDtoNameString |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 简拼
|
||||
|
/// </summary>
|
||||
|
public string SimpleCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public int DisplayOrder { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
public class CommonTableTypeIdInputDto |
||||
|
{ |
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
public class CreateCommonTableTypeDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 主键
|
||||
|
/// </summary>
|
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
public class UpdateCommonTableTypeDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 主键
|
||||
|
/// </summary>
|
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
public class UpdateManySortCommonTableTypeInputDto |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 需要修改的ID
|
||||
|
/// </summary>
|
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改方式:1 置顶 2 置底
|
||||
|
/// </summary>
|
||||
|
public int SortType { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
public class CommonTableDto : AuditedEntityDtoName |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 对照值
|
||||
|
/// </summary>
|
||||
|
public string DataCode { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 通用字段对照类别
|
||||
|
/// </summary>
|
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
|
||||
|
|
||||
|
public string SimpleCode { get; set; } = null!; |
||||
|
|
||||
|
public int DisplayOrder { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
public class CommonTableIdInputDto |
||||
|
{ |
||||
|
public Guid CommonTableId { get; set;} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
public class CreateCommonTableDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 对照值
|
||||
|
/// </summary>
|
||||
|
public string DataCode { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 通用字段对照类别
|
||||
|
/// </summary>
|
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
public class UpdateCommonTableDto |
||||
|
{ |
||||
|
public Guid CommonTableId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 对照值
|
||||
|
/// </summary>
|
||||
|
public string DataCode { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
public string DisplayName { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 通用字段对照类别
|
||||
|
/// </summary>
|
||||
|
public string CommonTableTypeId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
public class UpdateManySortCommonTableInputDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 需要修改的ID
|
||||
|
/// </summary>
|
||||
|
public Guid CommonTableId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改方式:1 置顶 2 置底
|
||||
|
/// </summary>
|
||||
|
public int SortType { get; set; } |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,157 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Shentun.Peis.CommonCharTypes; |
||||
|
using Shentun.Peis.HelperDto; |
||||
|
using Shentun.Peis.Models; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Shentun.Peis.CommonTableTypes; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 通用字段对照类别
|
||||
|
/// </summary>
|
||||
|
[ApiExplorerSettings(GroupName = "Work")] |
||||
|
[Authorize] |
||||
|
public class CommonTableTypeAppService : ApplicationService |
||||
|
{ |
||||
|
private readonly IRepository<CommonTableType, string> _commonTableTypeRepository; |
||||
|
private readonly CommonTableTypeManager _commonTableTypeManager; |
||||
|
private readonly CacheService _cacheService; |
||||
|
|
||||
|
public CommonTableTypeAppService( |
||||
|
IRepository<CommonTableType, string> commonTableTypeRepository, |
||||
|
CommonTableTypeManager commonTableTypeManager, |
||||
|
CacheService cacheService) |
||||
|
{ |
||||
|
_commonTableTypeRepository = commonTableTypeRepository; |
||||
|
_commonTableTypeManager = commonTableTypeManager; |
||||
|
_cacheService = cacheService; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取通过主键
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/Get")] |
||||
|
public async Task<CommonTableTypeDto> GetAsync(CommonTableTypeIdInputDto input) |
||||
|
{ |
||||
|
var commonTableTypeEnt = await _commonTableTypeRepository.GetAsync(input.CommonTableTypeId); |
||||
|
var entityDto = ObjectMapper.Map<CommonTableType, CommonTableTypeDto>(commonTableTypeEnt); |
||||
|
entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); |
||||
|
entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); |
||||
|
return entityDto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取列表
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/GetList")] |
||||
|
public async Task<List<CommonTableTypeDto>> GetListAsync() |
||||
|
{ |
||||
|
var entlist = await _commonTableTypeRepository.GetQueryableAsync(); |
||||
|
|
||||
|
var entdto = entlist.Select(s => new CommonTableTypeDto |
||||
|
{ |
||||
|
CreationTime = s.CreationTime, |
||||
|
CreatorId = s.CreatorId, |
||||
|
DisplayName = s.DisplayName, |
||||
|
DisplayOrder = s.DisplayOrder, |
||||
|
Id = s.Id, |
||||
|
LastModificationTime = s.LastModificationTime, |
||||
|
LastModifierId = s.LastModifierId, |
||||
|
SimpleCode = s.SimpleCode, |
||||
|
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, |
||||
|
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result |
||||
|
}).OrderBy(o => o.DisplayOrder).ToList(); |
||||
|
|
||||
|
return entdto; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/Create")] |
||||
|
public async Task<CommonTableTypeDto> CreateAsync(CreateCommonTableTypeDto input) |
||||
|
{ |
||||
|
var createEntity = ObjectMapper.Map<CreateCommonTableTypeDto, CommonTableType>(input); |
||||
|
var entity = await _commonTableTypeManager.CreateAsync(createEntity, input.CommonTableTypeId); |
||||
|
entity = await _commonTableTypeRepository.InsertAsync(entity); |
||||
|
var dto = ObjectMapper.Map<CommonTableType, CommonTableTypeDto>(entity); |
||||
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); |
||||
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); |
||||
|
return dto; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/Update")] |
||||
|
public async Task<CommonTableTypeDto> UpdateAsync(UpdateCommonTableTypeDto input) |
||||
|
{ |
||||
|
var entity = await _commonTableTypeRepository.GetAsync(input.CommonTableTypeId); |
||||
|
var sourceEntity = ObjectMapper.Map<UpdateCommonTableTypeDto, CommonTableType>(input); |
||||
|
await _commonTableTypeManager.UpdateAsync(sourceEntity, entity); |
||||
|
entity = await _commonTableTypeRepository.UpdateAsync(entity); |
||||
|
var dto = ObjectMapper.Map<CommonTableType, CommonTableTypeDto>(entity); |
||||
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); |
||||
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); |
||||
|
return dto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/Delete")] |
||||
|
public async Task DeleteAsync(CommonTableTypeIdInputDto input) |
||||
|
{ |
||||
|
await _commonTableTypeManager.CheckAndDeleteAsync(input.CommonTableTypeId); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 置顶,置底
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/UpdateManySort")] |
||||
|
public async Task UpdateManySortAsync(UpdateManySortCommonTableTypeInputDto input) |
||||
|
{ |
||||
|
await _commonTableTypeManager.UpdateManySortAsync(input.CommonTableTypeId, input.SortType); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 拖拽
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTableType/UpdateSortMany")] |
||||
|
public async Task UpdateSortManyAsync(UpdateSortManyCommonDto input) |
||||
|
{ |
||||
|
await _commonTableTypeManager.UpdateSortManyAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,159 @@ |
|||||
|
using AutoMapper.Internal.Mappers; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Shentun.Peis.CommonTables; |
||||
|
using Shentun.Peis.HelperDto; |
||||
|
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; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 通用字段对照
|
||||
|
/// </summary>
|
||||
|
[ApiExplorerSettings(GroupName = "Work")] |
||||
|
[Authorize] |
||||
|
public class CommonTableAppService : ApplicationService |
||||
|
{ |
||||
|
private readonly IRepository<CommonTableType, string> _commonTableTypeRepository; |
||||
|
private readonly IRepository<CommonTable, Guid> _commonTableRepository; |
||||
|
private readonly CommonTableManager _commonTableManager; |
||||
|
private readonly CacheService _cacheService; |
||||
|
|
||||
|
public CommonTableAppService( |
||||
|
IRepository<CommonTableType, string> commonTableTypeRepository, |
||||
|
CommonTableManager commonTableManager, |
||||
|
CacheService cacheService, |
||||
|
IRepository<CommonTable, Guid> commonTableRepository) |
||||
|
{ |
||||
|
_commonTableTypeRepository = commonTableTypeRepository; |
||||
|
_commonTableManager = commonTableManager; |
||||
|
_cacheService = cacheService; |
||||
|
_commonTableRepository = commonTableRepository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取通过主键
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/Get")] |
||||
|
public async Task<CommonTableDto> GetAsync(CommonTableIdInputDto input) |
||||
|
{ |
||||
|
var commonTableEnt = await _commonTableRepository.GetAsync(input.CommonTableId); |
||||
|
var entityDto = ObjectMapper.Map<CommonTable, CommonTableDto>(commonTableEnt); |
||||
|
entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); |
||||
|
entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); |
||||
|
return entityDto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取列表
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/GetList")] |
||||
|
public async Task<List<CommonTableDto>> GetListAsync() |
||||
|
{ |
||||
|
var entlist = await _commonTableRepository.GetQueryableAsync(); |
||||
|
|
||||
|
var entdto = entlist.Select(s => new CommonTableDto |
||||
|
{ |
||||
|
CreationTime = s.CreationTime, |
||||
|
CreatorId = s.CreatorId, |
||||
|
DisplayName = s.DisplayName, |
||||
|
DisplayOrder = s.DisplayOrder, |
||||
|
Id = s.Id, |
||||
|
CommonTableTypeId = s.CommonTableTypeId, |
||||
|
DataCode = s.DataCode, |
||||
|
LastModificationTime = s.LastModificationTime, |
||||
|
LastModifierId = s.LastModifierId, |
||||
|
SimpleCode = s.SimpleCode, |
||||
|
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, |
||||
|
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result |
||||
|
}).OrderBy(o => o.DisplayOrder).ToList(); |
||||
|
|
||||
|
return entdto; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/Create")] |
||||
|
public async Task<CommonTableDto> CreateAsync(CreateCommonTableDto input) |
||||
|
{ |
||||
|
var createEntity = ObjectMapper.Map<CreateCommonTableDto, CommonTable>(input); |
||||
|
var entity = await _commonTableManager.CreateAsync(createEntity); |
||||
|
entity = await _commonTableRepository.InsertAsync(entity); |
||||
|
var dto = ObjectMapper.Map<CommonTable, CommonTableDto>(entity); |
||||
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); |
||||
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); |
||||
|
return dto; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/Update")] |
||||
|
public async Task<CommonTableDto> UpdateAsync(UpdateCommonTableDto input) |
||||
|
{ |
||||
|
var entity = await _commonTableRepository.GetAsync(input.CommonTableId); |
||||
|
var sourceEntity = ObjectMapper.Map<UpdateCommonTableDto, CommonTable>(input); |
||||
|
await _commonTableManager.UpdateAsync(sourceEntity, entity); |
||||
|
entity = await _commonTableRepository.UpdateAsync(entity); |
||||
|
var dto = ObjectMapper.Map<CommonTable, CommonTableDto>(entity); |
||||
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); |
||||
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); |
||||
|
return dto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/Delete")] |
||||
|
public async Task DeleteAsync(CommonTableIdInputDto input) |
||||
|
{ |
||||
|
await _commonTableManager.CheckAndDeleteAsync(input.CommonTableId); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 置顶,置底
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/UpdateManySort")] |
||||
|
public async Task UpdateManySortAsync(UpdateManySortCommonTableInputDto input) |
||||
|
{ |
||||
|
await _commonTableManager.UpdateManySortAsync(input.CommonTableId, input.SortType); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 拖拽
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/CommonTable/UpdateSortMany")] |
||||
|
public async Task UpdateSortManyAsync(UpdateSortManyCommonDto input) |
||||
|
{ |
||||
|
await _commonTableManager.UpdateSortManyAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,120 @@ |
|||||
|
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.Repositories; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTableTypes |
||||
|
{ |
||||
|
public class CommonTableTypeManager : DomainService |
||||
|
{ |
||||
|
private readonly IRepository<CommonTableType, string> _commonTableTypeRepository; |
||||
|
private readonly IRepository<CommonTable, Guid> _commonTableRepository; |
||||
|
|
||||
|
public CommonTableTypeManager( |
||||
|
IRepository<CommonTableType, string> commonTableTypeRepository, |
||||
|
IRepository<CommonTable, Guid> commonTableRepository) |
||||
|
{ |
||||
|
_commonTableTypeRepository = commonTableTypeRepository; |
||||
|
_commonTableRepository = commonTableRepository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="entity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task<CommonTableType> CreateAsync( |
||||
|
CommonTableType entity, string CommonTableTypeId |
||||
|
) |
||||
|
{ |
||||
|
DataHelper.CheckEntityIsNull(entity); |
||||
|
DataHelper.CheckStringIsNull(entity.DisplayName, "名称"); |
||||
|
await EntityHelper.CheckSameName<CommonTableType, string>(_commonTableTypeRepository, entity.DisplayName); |
||||
|
return new CommonTableType(CommonTableTypeId) |
||||
|
{ |
||||
|
DisplayName = entity.DisplayName, |
||||
|
SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName), |
||||
|
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<CommonTableType>(_commonTableTypeRepository) |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新
|
||||
|
/// </summary>
|
||||
|
/// <param name="sourceEntity"></param>
|
||||
|
/// <param name="targetEntity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateAsync( |
||||
|
CommonTableType sourceEntity, |
||||
|
CommonTableType targetEntity |
||||
|
) |
||||
|
{ |
||||
|
DataHelper.CheckEntityIsNull(sourceEntity); |
||||
|
DataHelper.CheckEntityIsNull(targetEntity); |
||||
|
DataHelper.CheckStringIsNull(sourceEntity.DisplayName, "名称"); |
||||
|
if (sourceEntity.DisplayName != targetEntity.DisplayName) |
||||
|
{ |
||||
|
|
||||
|
await EntityHelper.CheckSameName<CommonTableType, string>(_commonTableTypeRepository, sourceEntity.DisplayName, targetEntity); |
||||
|
targetEntity.DisplayName = sourceEntity.DisplayName; |
||||
|
targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(targetEntity.DisplayName); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// <exception cref="UserFriendlyException"></exception>
|
||||
|
public async Task CheckAndDeleteAsync(string id) |
||||
|
{ |
||||
|
|
||||
|
var commonTableEnt = await _commonTableRepository.FirstOrDefaultAsync(m => m.CommonTableTypeId == id); |
||||
|
if (commonTableEnt != null) |
||||
|
{ |
||||
|
throw new UserFriendlyException($"类型已被使用,不能删除"); |
||||
|
} |
||||
|
|
||||
|
await _commonTableTypeRepository.DeleteAsync(id); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 置顶,置底
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">需要修改的ID</param>
|
||||
|
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateManySortAsync(string id, int SortType) |
||||
|
{ |
||||
|
await EntityHelper.UpdateManySortCommonAsync(_commonTableTypeRepository, id, SortType); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 拖拽
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||
|
/// <param name="repository"></param>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateSortManyAsync(UpdateSortManyCommonDto input) |
||||
|
{ |
||||
|
await EntityHelper.UpdateSortManyCommonAsync(_commonTableTypeRepository, input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,122 @@ |
|||||
|
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.Repositories; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Shentun.Peis.CommonTables |
||||
|
{ |
||||
|
|
||||
|
public class CommonTableManager : DomainService |
||||
|
{ |
||||
|
private readonly IRepository<CommonTableType, string> _commonTableTypeRepository; |
||||
|
private readonly IRepository<CommonTable, Guid> _commonTableRepository; |
||||
|
|
||||
|
public CommonTableManager( |
||||
|
IRepository<CommonTableType, string> commonTableTypeRepository, |
||||
|
IRepository<CommonTable, Guid> commonTableRepository) |
||||
|
{ |
||||
|
_commonTableTypeRepository = commonTableTypeRepository; |
||||
|
_commonTableRepository = commonTableRepository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="entity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task<CommonTable> CreateAsync( |
||||
|
CommonTable entity |
||||
|
) |
||||
|
{ |
||||
|
DataHelper.CheckEntityIsNull(entity); |
||||
|
DataHelper.CheckStringIsNull(entity.DisplayName, "名称"); |
||||
|
DataHelper.CheckStringIsNull(entity.DataCode, "对照值"); |
||||
|
DataHelper.CheckStringIsNull(entity.CommonTableTypeId, "通用字段对照类别"); |
||||
|
await EntityHelper.CheckSameName(_commonTableRepository, entity.DisplayName); |
||||
|
return new CommonTable |
||||
|
{ |
||||
|
DisplayName = entity.DisplayName, |
||||
|
CommonTableTypeId = entity.CommonTableTypeId, |
||||
|
DataCode = entity.DataCode, |
||||
|
SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName), |
||||
|
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<CommonTable>(_commonTableRepository) |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新
|
||||
|
/// </summary>
|
||||
|
/// <param name="sourceEntity"></param>
|
||||
|
/// <param name="targetEntity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateAsync( |
||||
|
CommonTable sourceEntity, |
||||
|
CommonTable targetEntity |
||||
|
) |
||||
|
{ |
||||
|
DataHelper.CheckEntityIsNull(sourceEntity); |
||||
|
DataHelper.CheckEntityIsNull(targetEntity); |
||||
|
DataHelper.CheckStringIsNull(sourceEntity.DisplayName, "名称"); |
||||
|
DataHelper.CheckStringIsNull(sourceEntity.DataCode, "对照值"); |
||||
|
DataHelper.CheckStringIsNull(sourceEntity.CommonTableTypeId, "通用字段对照类别"); |
||||
|
if (sourceEntity.DisplayName != targetEntity.DisplayName) |
||||
|
{ |
||||
|
|
||||
|
await EntityHelper.CheckSameName(_commonTableRepository, sourceEntity.DisplayName, targetEntity); |
||||
|
targetEntity.DisplayName = sourceEntity.DisplayName; |
||||
|
targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(targetEntity.DisplayName); |
||||
|
} |
||||
|
|
||||
|
targetEntity.DataCode = sourceEntity.DataCode; |
||||
|
targetEntity.CommonTableTypeId = sourceEntity.CommonTableTypeId; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// <exception cref="UserFriendlyException"></exception>
|
||||
|
public async Task CheckAndDeleteAsync(Guid id) |
||||
|
{ |
||||
|
await _commonTableRepository.DeleteAsync(id); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <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.UpdateManySortCommonAsync(_commonTableRepository, id, SortType); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改排序 拖拽
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||
|
/// <param name="repository"></param>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateSortManyAsync(UpdateSortManyCommonDto input) |
||||
|
{ |
||||
|
await EntityHelper.UpdateSortManyCommonAsync(_commonTableRepository, input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue