项目结构修改

This commit is contained in:
DK
2022-03-28 16:38:06 +08:00
parent dc78fd1a09
commit b31e70e573
11 changed files with 1150 additions and 178 deletions
@@ -1,13 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Castle.Core.Internal;
using IRaCIS.Application.Interfaces;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Application.Image.QA;
using IRaCIS.Core.Application.Service.Inspection.DTO;
using IRaCIS.Core.Application.Service.Inspection.Interface;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace IRaCIS.Core.API.Controllers
{
@@ -18,93 +27,153 @@ namespace IRaCIS.Core.API.Controllers
private readonly IRepository _repository;
private readonly IMapper _mapper;
private readonly IUserInfo _userInfo;
private readonly ITrialDocumentService _trialDocumentService;
private readonly IQCListService _qCListService;
private readonly ITrialConfigService _trialConfigService;
private readonly ISubjectService _subjectService;
private readonly IInspectionService _inspectionService;
private readonly IRepository<DataInspection> _dataInspectionRepository;
private delegate Task<IResponseOutput> executionFun(dynamic data);
public InspectionController(IRepository repository, IMapper mapper, IUserInfo userInfo)
public InspectionController(IRepository repository,
IRepository<DataInspection> _repositoryDataInspection,
IMapper mapper, IUserInfo userInfo,
ITrialDocumentService trialDocumentService,
IRepository<DataInspection> dataInspectionRepository,
IQCListService _qCListService,
IInspectionService sinspectionService,
ITrialConfigService _trialConfigService,
ISubjectService _subjectService)
{
_repository = repository;
_mapper = mapper;
_userInfo = userInfo;
this._inspectionService = sinspectionService;
this._trialDocumentService = trialDocumentService;
this._qCListService = _qCListService;
this._trialConfigService = _trialConfigService;
this._subjectService = _subjectService;
this._dataInspectionRepository = dataInspectionRepository;
}
[HttpPost, Route("trialDocument/userConfirm")]
public async Task<IResponseOutput> UserConfirm(TrialDocumentConfirmDTO opt, [FromServices] ITrialDocumentService _trialDocumentService)
/// <summary>
/// 获取稽查数据
/// </summary>
/// <returns></returns>
[HttpPost, Route("Inspection/GetInspectionData")]
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto)
{
var verifyResult = await VerifySignatureAsync(opt.SignInfo);
if (verifyResult.IsSuccess == false)
{
return verifyResult;
}
var bResult = await _trialDocumentService.UserConfirm(opt.OptCommand);
if (bResult.IsSuccess == false)
{
return bResult;
}
//SiteId SubjectId SubjectVisitId TrialId 最开始没有 需要特殊处理
//表冗余字段 前端只传递一次的话 后台模型就需要单独处理
if (opt.AuditInfo.IsSign)
{
var signId = await AddSignRecordAsync(opt.SignInfo);
await AddInspectionRecordAsync(opt.AuditInfo, signId);
}
else
{
await AddInspectionRecordAsync(opt.AuditInfo, null);
}
return bResult;
return await _inspectionService.GetInspectionData(dto);
}
/// <summary> 验证用户签名信息 </summary> ///
private async Task<IResponseOutput> VerifySignatureAsync(SignDTO signDTO)
/// <summary>
/// 用户 签名某个文档 签署文件
/// </summary>
/// <param name="opt"></param>
/// <returns></returns>
[HttpPost, Route("Inspection/trialDocument/userConfirm")]
[UnitOfWork]
public async Task<IResponseOutput> UserConfirm(TrialDocumentConfirmDTO opt)
{
var user = await _repository.FirstOrDefaultAsync<User>(u => u.UserName == signDTO.UserName && u.Password == signDTO.PassWord);
if (user == null)
{
return ResponseOutput.NotOk("password error");
}
else if (user.Status == UserStateEnum.Disable)
{
return ResponseOutput.NotOk("The user has been disabled!");
}
return ResponseOutput.Ok();
var fun = _trialDocumentService.UserConfirm;
return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun);
}
/// <summary> 添加签名记录 </summary> ///
private async Task<Guid> AddSignRecordAsync(SignDTO signDTO)
{
var add = await _repository.AddAsync(_mapper.Map<TrialSign>(signDTO));
#region setting
///// <summary>
///// 配置 基础逻辑信息
///// </summary>
///// <param name="opt"></param>
///// <returns></returns>
//[HttpPut, Route("configTrialBasicInfo/configTrialBasicInfo")]
//[UnitOfWork]
//public async Task<IResponseOutput> ConfigTrialBasicInfo(InsBasicTrialConfig opt)
//{
// var fun = _trialConfigService.ConfigTrialBasicInfo;
// return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun);
//}
var success = await _repository.SaveChangesAsync();
///// <summary>
///// 配置流程
///// </summary>
///// <param name="opt"></param>
///// <returns></returns>
//[HttpPut, Route("configTrialBasicInfo/configTrialProcessInfo")]
//[UnitOfWork]
//public async Task<IResponseOutput> ConfigTrialProcessInfo(InsTrialProcessConfig opt)
//{
// var fun = _trialConfigService.ConfigTrialProcessInfo;
// return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun);
//}
return add.Id;
///// <summary>
///// 配置加急信息
///// </summary>
///// <param name="opt"></param>
///// <returns></returns>
//[HttpPut, Route("configTrialBasicInfo/ConfigTrialUrgentInfo")]
//[UnitOfWork]
//public async Task<IResponseOutput> ConfigTrialUrgentInfo(InsTrialUrgentConfig opt)
//{
// var fun = _trialConfigService.ConfigTrialUrgentInfo;
// return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun);
//}
}
/// <summary> 添加稽查记录( 有的会签名,有的不会签名) </summary> ///
private async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId)
#endregion
#region
/// <summary>
/// 添加或更新受试者信息[New]
/// </summary>
/// <param name="opt"></param>
/// <returns></returns>
//[TypeFilter(typeof(TrialResourceFilter))]
[HttpPost, Route("Inspection/Subject/AddOrUpdateSubject")]
[UnitOfWork]
public async Task<IResponseOutput> AddOrUpdateSubject(InsSubjectCommand opt)
{
var add = await _repository.AddAsync(_mapper.Map<DataInspection>(addDto));
add.SignId = signId;
add.IP = _userInfo.IP;
var success = await _repository.SaveChangesAsync();
opt.AuditInfo.SubjectId = opt.OptCommand.Id;
var fun = _subjectService.AddOrUpdateSubject;
return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun);
}
/// <summary>
/// 修改受试者状态
/// </summary>
/// <param name="opt"></param>
/// <returns></returns>
///
[HttpPut, Route("Inspection/Subject/UpdateSubjectStatus")]
[UnitOfWork]
public async Task<IResponseOutput> UpdateSubjectStatus(InsUpdateSubjectStatus opt)
{
var fun = _subjectService.UpdateSubjectStatus;
return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun);
}
/// <summary>
/// 删除受试者
/// </summary>
/// <param name="opt"></param>
/// <returns></returns>
[HttpDelete, Route("Inspection/Subject/DeleteSubject")]
[UnitOfWork]
public async Task<IResponseOutput> DeleteSubject(InsDeleteSubjectDto opt)
{
var fun = _subjectService.DeleteSubject;
var data = await _subjectService.DeleteSubject(opt.OptCommand.SubjectId);
return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun, data);
}
#endregion
}