//-------------------------------------------------------------------- // 此代码由T4模板自动生成 byzhouhang 20210918 // 生成时间 2022-03-04 13:33:56 // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.Filter; using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using Medallion.Threading; using Microsoft.AspNetCore.Mvc; namespace IRaCIS.Core.Application.Service { /// /// 项目外部人员 录入流程相关 /// [ApiExplorerSettings(GroupName = "Trial")] public class TrialExternalUserService(IRepository _trialExternalUseRepository, IRepository _userRoleRepository, IRepository _trialUserRepository, IRepository _trialRepository, IRepository _userTypeRepository, IMailVerificationService _mailVerificationService, IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialExternalUserService { [HttpPost] public async Task> GetTrialExternalUserList(TrialExternalUserQuery queryTrialExternalUser) { var trialExternalUserQueryable = _trialExternalUseRepository.Where(t => t.TrialId == queryTrialExternalUser.TrialId) .WhereIf(!string.IsNullOrEmpty(queryTrialExternalUser.Phone), t => t.Phone.Contains(queryTrialExternalUser.Phone)) .WhereIf(!string.IsNullOrEmpty(queryTrialExternalUser.Email), t => t.Email.Contains(queryTrialExternalUser.Email)) .WhereIf(!string.IsNullOrEmpty(queryTrialExternalUser.Name), t => (t.LastName + " / " + t.FirstName).Contains(queryTrialExternalUser.Name)) .ProjectTo(_mapper.ConfigurationProvider); return await trialExternalUserQueryable.ToListAsync(); } [HttpDelete("{trialExternalUserId:guid}/{isSystemUser:bool}/{systemUserId}")] //[Authorize(Policy = IRaCISPolicy.PM_APM)] public async Task DeleteTrialExternalUser(Guid trialExternalUserId, bool isSystemUser, Guid systemUserId) { var trialExternalUser = await _trialExternalUseRepository.FirstOrDefaultAsync(t => t.Id == trialExternalUserId); if (await _trialUserRepository.AnyAsync(t => t.TrialId == trialExternalUser.TrialId && t.UserId == trialExternalUser.SystemUserId)) { //---当前用户已参与到项目,不允许删除 return ResponseOutput.NotOk(_localizer["TrialExternalUser_CannotDelete"]); } var success = await _trialExternalUseRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialExternalUserId); if (isSystemUser == false) { await _userRoleRepository.BatchDeleteNoTrackingAsync(t => t.Id == systemUserId); } return ResponseOutput.Result(success); } } }