125 lines
5.5 KiB
C#
125 lines
5.5 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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="iq"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<List<FrontAuditConfigView>> GetFrontAuditConfigList(FrontAuditConfigQuery iq)
|
|
{
|
|
|
|
|
|
var query = from data in _repository.GetQueryable<FrontAuditConfig>()
|
|
join childrenType in _repository.GetQueryable<Dictionary>() on data.ChildrenTypeId equals childrenType.Id.ToString() into childrenTypetemp
|
|
from leftchildrenType in childrenTypetemp.DefaultIfEmpty()
|
|
join ModuleType in _repository.GetQueryable<Dictionary>() on data.ModuleTypeId equals ModuleType.Id.ToString() into ModuleTypetemp
|
|
from leftModuleType in ModuleTypetemp.DefaultIfEmpty()
|
|
join OptTypeId in _repository.GetQueryable<Dictionary>() on data.OptTypeId equals OptTypeId.Id.ToString() into OptTypeIdtemp
|
|
from leftOptTypeId in OptTypeIdtemp.DefaultIfEmpty()
|
|
select new FrontAuditConfigView()
|
|
{
|
|
|
|
IsShowParent = data.IsShowParent,
|
|
ChildrenTypeId = data.ChildrenTypeId,
|
|
Code = data.Code,
|
|
ConfigType = data.ConfigType,
|
|
CreateTime = data.CreateTime,
|
|
CreateUserId = data.CreateUserId,
|
|
Description = data.Description,
|
|
IsConfig = data.IsConfig,
|
|
IsEnable = data.IsEnable,
|
|
ModuleTypeId = data.ModuleTypeId,
|
|
Id = data.Id,
|
|
ParentId = data.ParentId,
|
|
UpdateTime = data.UpdateTime,
|
|
Value = data.Value,
|
|
ChildrenTypeValueCN = leftchildrenType.ValueCN,
|
|
ModuleTypeValue = leftModuleType.Value,
|
|
ModuleTypeValueCN = leftModuleType.ValueCN,
|
|
OptTypeId = data.Value,
|
|
OptTypeValue = leftOptTypeId.Value,
|
|
OptTypeValueCN = leftOptTypeId.ValueCN,
|
|
UpdateUserId = data.UpdateUserId,
|
|
ValueCN = data.ValueCN,
|
|
ChildrenTypeValue = leftchildrenType.Value,
|
|
};
|
|
|
|
query = query
|
|
.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);
|
|
|
|
return await query.ToListAsync();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 新增或者修改
|
|
/// </summary>
|
|
/// <param name="addOrEditFrontAuditConfig"></param>
|
|
/// <returns></returns>
|
|
public async Task<IResponseOutput> AddOrUpdateFrontAuditConfig(FrontAuditConfigAddOrEdit addOrEditFrontAuditConfig)
|
|
{
|
|
// 在此处拷贝automapper 映射
|
|
|
|
//CreateMap<FrontAuditConfig, FrontAuditConfigView>();
|
|
|
|
// CreateMap< FrontAuditConfig,FrontAuditConfigAddOrEdit>().ReverseMap();
|
|
|
|
addOrEditFrontAuditConfig.CreateTime= DateTime.Now;
|
|
addOrEditFrontAuditConfig.UpdateTime= DateTime.Now;
|
|
addOrEditFrontAuditConfig.CreateUserId = _userInfo.Id;
|
|
addOrEditFrontAuditConfig.UpdateUserId= _userInfo.Id;
|
|
|
|
var entity = await _repository.InsertOrUpdateAsync<FrontAuditConfig, FrontAuditConfigAddOrEdit>(addOrEditFrontAuditConfig, true);
|
|
|
|
return ResponseOutput.Ok(entity.Id.ToString());
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="frontAuditConfigId"></param>
|
|
/// <returns></returns>
|
|
[HttpDelete("{frontAuditConfigId:guid}")]
|
|
public async Task<IResponseOutput> DeleteFrontAuditConfig(Guid frontAuditConfigId)
|
|
{
|
|
var success = await _repository.DeleteFromQueryAsync<FrontAuditConfig>(t => t.Id == frontAuditConfigId);
|
|
return ResponseOutput.Result(success);
|
|
}
|
|
|
|
|
|
}
|
|
}
|