
//--------------------------------------------------------------------
//     此代码由liquid模板自动生成  byzhouhang 20240909
//     生成时间 2025-11-12 06:46:38Z 
//     对此文件的更改可能会导致不正确的行为，并且如果重新生成代码，这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Domain.Models;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Infrastructure.Extention;
using System.Threading.Tasks;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Application.Service.Reading.Interface;
namespace IRaCIS.Core.Application.Service;


/// <summary>
/// 系统标准阅片关键点文件服务
/// </summary>
/// <param name="_systemCriterionKeyFileRepository"></param>
/// <param name="_mapper"></param>
/// <param name="_userInfo"></param>
/// <param name="_localizer"></param>
[ApiExplorerSettings(GroupName = "Reading")]
public class SystemCriterionKeyFileService(IRepository<SystemCriterionKeyFile> _systemCriterionKeyFileRepository,
                                  IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, ISystemCriterionKeyFileService
{

    /// <summary>
    /// 获取系统标准阅片关键点文件列表
    /// </summary>
    /// <param name="inQuery"></param>
    /// <returns></returns>
    [HttpPost]
	public async Task<PageOutput<SystemCriterionKeyFileView>>  GetSystemCriterionKeyFileList(SystemCriterionKeyFileQuery inQuery)
	{
			
		    var systemCriterionKeyFileQueryable =_systemCriterionKeyFileRepository
            .Where(x=>x.SystemCriterionId==inQuery.SystemCriterionId)
             .WhereIf(!string.IsNullOrWhiteSpace(inQuery.FileName),x=>x.FileName.Contains(inQuery.FileName))
                                        .ProjectTo<SystemCriterionKeyFileView>(_mapper.ConfigurationProvider);

            var pageList= await systemCriterionKeyFileQueryable.ToPagedListAsync(inQuery);

        return pageList;
	}


    /// <summary>
    /// 新增或者修改系统标准阅片关键点文件
    /// </summary>
    /// <param name="addOrEditSystemCriterionKeyFile"></param>
    /// <returns></returns>
    public async  Task<IResponseOutput> AddOrUpdateSystemCriterionKeyFile(SystemCriterionKeyFileAddOrEdit addOrEditSystemCriterionKeyFile)
	{
		    //  在此处拷贝automapper 映射
			var entity = await _systemCriterionKeyFileRepository.InsertOrUpdateAsync(addOrEditSystemCriterionKeyFile, true);

        return ResponseOutput.Ok(entity.Id.ToString());
		
	}

    /// <summary>
    /// 删除系统标准阅片关键点文件
    /// </summary>
    /// <param name="systemCriterionKeyFileId"></param>
    /// <returns></returns>
	[HttpDelete("{systemCriterionKeyFileId:guid}")]
    public async Task<IResponseOutput> DeleteSystemCriterionKeyFile(Guid systemCriterionKeyFileId)
	{
			var success = await _systemCriterionKeyFileRepository.DeleteFromQueryAsync(t => t.Id == systemCriterionKeyFileId,true);
            return ResponseOutput.Ok();
	}
      
}



