74 lines
2.8 KiB
C#
74 lines
2.8 KiB
C#
//--------------------------------------------------------------------
|
|
// 此代码由T4模板自动生成 byzhouhang 20210918
|
|
// 生成时间 2022-03-28 16:46:23
|
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
|
//--------------------------------------------------------------------
|
|
|
|
using IRaCIS.Core.Domain.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using IRaCIS.Core.Application.Interfaces;
|
|
using IRaCIS.Core.Application.ViewModel;
|
|
using Castle.Core.Internal;
|
|
|
|
namespace IRaCIS.Core.Application.Service
|
|
{
|
|
/// <summary>
|
|
/// FrontAuditConfigService
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Reviewer")]
|
|
public class FrontAuditConfigService : BaseService, IFrontAuditConfigService
|
|
{
|
|
|
|
private readonly IRepository<FrontAuditConfig> _frontAuditConfigRepository;
|
|
|
|
public FrontAuditConfigService(IRepository<FrontAuditConfig> frontAuditConfigRepository)
|
|
{
|
|
_frontAuditConfigRepository = frontAuditConfigRepository;
|
|
}
|
|
|
|
|
|
public async Task<List<FrontAuditConfigView>> GetFrontAuditConfigList(FrontAuditConfigQuery iq)
|
|
{
|
|
var query = _repository.GetQueryable<FrontAuditConfig>()
|
|
.WhereIf(!iq.Value.IsNullOrEmpty(), x => x.Value == iq.Value)
|
|
.WhereIf(!iq.Value.IsNullOrEmpty(), x => x.ValueCN == iq.ValueCN)
|
|
.WhereIf(!iq.Value.IsNullOrEmpty(), x => x.Description == iq.Description)
|
|
.WhereIf(!iq.Value.IsNullOrEmpty(), x => x.OptTypeId == iq.OptTypeId)
|
|
.WhereIf(!iq.Value.IsNullOrEmpty(), x => x.Code == iq.Code)
|
|
.WhereIf(!iq.Value.IsNullOrEmpty(), x => x.ChildrenTypeId == iq.ChildrenTypeId);
|
|
|
|
|
|
var frontAuditConfigQueryable = query
|
|
.ProjectTo<FrontAuditConfigView>(_mapper.ConfigurationProvider);
|
|
|
|
return await frontAuditConfigQueryable.ToListAsync();
|
|
}
|
|
|
|
|
|
public async Task<IResponseOutput> AddOrUpdateFrontAuditConfig(FrontAuditConfigAddOrEdit addOrEditFrontAuditConfig)
|
|
{
|
|
// 在此处拷贝automapper 映射
|
|
|
|
//CreateMap<FrontAuditConfig, FrontAuditConfigView>();
|
|
|
|
// CreateMap< FrontAuditConfig,FrontAuditConfigAddOrEdit>().ReverseMap();
|
|
|
|
|
|
var entity = await _repository.InsertOrUpdateAsync<FrontAuditConfig, FrontAuditConfigAddOrEdit>(addOrEditFrontAuditConfig, true);
|
|
|
|
return ResponseOutput.Ok(entity.Id.ToString());
|
|
|
|
}
|
|
|
|
|
|
[HttpDelete("{frontAuditConfigId:guid}")]
|
|
public async Task<IResponseOutput> DeleteFrontAuditConfig(Guid frontAuditConfigId)
|
|
{
|
|
var success = await _repository.DeleteFromQueryAsync<FrontAuditConfig>(t => t.Id == frontAuditConfigId);
|
|
return ResponseOutput.Result(success);
|
|
}
|
|
|
|
|
|
}
|
|
}
|