129 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
| 
 | |
| using IRaCIS.Application.Contracts;
 | |
| using IRaCIS.Application.Interfaces;
 | |
| using IRaCIS.Core.Domain.Share;
 | |
| using Microsoft.AspNetCore.Mvc;
 | |
| 
 | |
| namespace IRaCIS.Core.Application.Service
 | |
| {
 | |
|     [ApiExplorerSettings(GroupName = "Reviewer")]
 | |
|     public class EducationService(IRepository<Postgraduate> _postgraduateRepository,
 | |
|         IRepository<Hospital> _hospitalRepository,
 | |
|         IRepository<Education> _educationRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IEducationService
 | |
|     {
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据医生Id获取医生教育经历和继续学习经历列表
 | |
|         /// </summary>
 | |
|         [HttpGet("{doctorId:Guid}")]
 | |
|         public async Task<DoctorEducationExperienceDTO> GetEducation(Guid doctorId)
 | |
|         {
 | |
|             var educationList = await _educationRepository.Where(o => o.DoctorId == doctorId)
 | |
|                 .OrderBy(t => t.CreateTime).ProjectTo<EducationInfoViewModel>(_mapper.ConfigurationProvider).ToListAsync();
 | |
| 
 | |
|             var postgraduateList = await _postgraduateRepository.Where(o => o.DoctorId == doctorId)
 | |
|                 .OrderBy(t => t.CreateTime).ProjectTo<PostgraduateViewModel>(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }).ToListAsync();
 | |
| 
 | |
| 
 | |
|             return new DoctorEducationExperienceDTO()
 | |
|             {
 | |
|                 EducationList = educationList,
 | |
|                 PostgraduateList = postgraduateList
 | |
|             };
 | |
| 
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 新增医生教育经历
 | |
|         /// </summary>
 | |
|         /// <param name="educationInfoViewModel"></param>
 | |
|         /// <returns></returns>
 | |
|         [HttpPost]
 | |
|         public async Task<IResponseOutput> AddOrUpdateEducationInfo(EducationCommand educationInfoViewModel)
 | |
|         {
 | |
|             if (educationInfoViewModel.Id == Guid.Empty || educationInfoViewModel.Id == null)
 | |
|             {
 | |
|                 var doctorEducationInfo = _mapper.Map<Education>(educationInfoViewModel);
 | |
|                 switch (educationInfoViewModel.Degree)
 | |
|                 {
 | |
|                     case StaticData.ReviewerDegree.Bachelor:
 | |
|                         doctorEducationInfo.ShowOrder = 1;
 | |
|                         break;
 | |
|                     case StaticData.ReviewerDegree.Master:
 | |
|                         doctorEducationInfo.ShowOrder = 2;
 | |
|                         break;
 | |
|                     case StaticData.ReviewerDegree.Doctorate:
 | |
|                         doctorEducationInfo.ShowOrder = 3;
 | |
|                         break;
 | |
|                 }
 | |
|                 await _educationRepository.AddAsync(doctorEducationInfo);
 | |
|                 var success = await _educationRepository.SaveChangesAsync();
 | |
| 
 | |
|                 return ResponseOutput.Result(success, doctorEducationInfo.Id.ToString());
 | |
|             }
 | |
| 
 | |
|             else
 | |
|             {
 | |
|                 var needUpdate = await _educationRepository.FirstOrDefaultAsync(t => t.Id == educationInfoViewModel.Id);
 | |
| 
 | |
|                 if (needUpdate == null) return Null404NotFound(needUpdate);
 | |
| 
 | |
|                 _mapper.Map(educationInfoViewModel, needUpdate);
 | |
| 
 | |
|                 var success = await _educationRepository.SaveChangesAsync();
 | |
| 
 | |
|                 return ResponseOutput.Ok(success);
 | |
| 
 | |
|             }
 | |
|             //_educationRepository.Update(needUpdate);
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         [HttpDelete, Route("{id:guid}")]
 | |
|         public async Task<IResponseOutput> DeleteEducationInfo(Guid id)
 | |
|         {
 | |
|             var success = await _educationRepository.BatchDeleteNoTrackingAsync(o => o.Id == id);
 | |
| 
 | |
|             return ResponseOutput.Result(success);
 | |
|         }
 | |
|         /// <summary> 添加/更新医生继续学习经历</summary>
 | |
| 
 | |
|         [HttpPost]
 | |
|         public async Task<IResponseOutput> AddOrUpdatePostgraduateInfo(PostgraduateCommand inDto)
 | |
|         {
 | |
|             #region 封装前
 | |
| 
 | |
|             //if (postgraduateViewModel.Id == Guid.Empty || postgraduateViewModel.Id == null)
 | |
|             //{
 | |
|             //    var doctorContinueLearning = _mapper.Map<Postgraduate>(postgraduateViewModel);
 | |
|             //    _postgraduateRepository.Add(doctorContinueLearning);
 | |
|             //    var success = _postgraduateRepository.SaveChanges();
 | |
| 
 | |
|             //    return ResponseOutput.Result(success, doctorContinueLearning.Id.ToString());
 | |
|             //}
 | |
|             //else
 | |
|             //{
 | |
|             //    _postgraduateRepository.Update(_mapper.Map<Postgraduate>(postgraduateViewModel));
 | |
|             //    var success = _postgraduateRepository.SaveChanges();
 | |
| 
 | |
|             //    return ResponseOutput.Result(success);
 | |
| 
 | |
|             //}
 | |
|             #endregion
 | |
|             var entity = await _postgraduateRepository.InsertOrUpdateAsync(inDto, true);
 | |
|             return ResponseOutput.Ok(entity.Id);
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 删除医生继续学习经历
 | |
|         /// </summary>
 | |
|         /// <param name="doctorId">医生Id</param>
 | |
|         /// <returns></returns>
 | |
| 
 | |
|         [HttpDelete("{doctorId:guid}")]
 | |
|         public async Task<IResponseOutput> DeletePostgraduateInfo(Guid doctorId)
 | |
|         {
 | |
|             var success = await _postgraduateRepository.BatchDeleteNoTrackingAsync(o => o.Id == doctorId);
 | |
|             return ResponseOutput.Result(success);
 | |
|         }
 | |
|     }
 | |
| } |