61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
|
|
//--------------------------------------------------------------------
|
|
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
|
// 生成时间 2024-09-20 01:22:34Z
|
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
|
//--------------------------------------------------------------------
|
|
using IRaCIS.Core.Domain.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using IRaCIS.Core.Application.Interfaces;
|
|
using IRaCIS.Core.Application.ViewModel;
|
|
using IRaCIS.Core.Infrastructure.Extention;
|
|
using System.Threading.Tasks;
|
|
using IRaCIS.Core.Infra.EFCore;
|
|
namespace IRaCIS.Core.Application.Service;
|
|
|
|
[ ApiExplorerSettings(GroupName = "Test")]
|
|
public class DictionaryService(IRepository<Dictionary> _dictionaryRepository): BaseService, IDictionaryService
|
|
{
|
|
|
|
|
|
[HttpPost]
|
|
public async Task<PageOutput<DictionaryView>> GetDictionaryList(DictionaryQuery inQuery)
|
|
{
|
|
|
|
var dictionaryQueryable =_dictionaryRepository
|
|
.ProjectTo<DictionaryView>(_mapper.ConfigurationProvider);
|
|
|
|
var pageList= await dictionaryQueryable.ToPagedListAsync(inQuery);
|
|
|
|
return pageList;
|
|
}
|
|
|
|
|
|
|
|
public async Task<IResponseOutput> AddOrUpdateDictionary(DictionaryAddOrEdit addOrEditDictionary)
|
|
{
|
|
// 在此处拷贝automapper 映射
|
|
|
|
CreateMap<Dictionary, DictionaryView>();
|
|
CreateMap<Dictionary,DictionaryAddOrEdit>().ReverseMap();
|
|
|
|
|
|
var entity = await _dictionaryRepository.InsertOrUpdateAsync(addOrEditDictionary, true);
|
|
|
|
return ResponseOutput.Ok(entity.Id.ToString());
|
|
|
|
}
|
|
|
|
|
|
[HttpDelete("{dictionaryId:guid}")]
|
|
public async Task<IResponseOutput> DeleteDictionary(Guid dictionaryId)
|
|
{
|
|
var success = await _<#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Repository.DeleteFromQueryAsync(t => t.Id == dictionaryId,true);
|
|
return ResponseOutput.Ok();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|