修改授权临时提交
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
14b8cbac23
commit
1095e07f87
|
@ -53,7 +53,7 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
|
||||
var isAdminOrQA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.QA;
|
||||
|
||||
var auditRecordQueryable = _auditRecordRepository.Where(t => t.BeginTime < dateTimeNow && t.EndTime > dateTimeNow)
|
||||
var auditRecordQueryable = _auditRecordRepository.Where(t => t.BeginTime < dateTimeNow && t.EndTime > dateTimeNow)
|
||||
//过滤查看用户
|
||||
.WhereIf(isAdminOrQA == false, t => t.AuditRecordIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
|
||||
.WhereIf(inQuery.BeginAuditTime != null, t => t.AuditTime >= inQuery.BeginAuditTime)
|
||||
|
@ -361,16 +361,30 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetIsAuthorization(SetIsAuthorizationInDto inDto)
|
||||
{
|
||||
//闭包表中找到 设置Id为祖先的所有 后代 包括自己
|
||||
var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
|
||||
if (inDto.IsAuthorization)
|
||||
{
|
||||
|
||||
//闭包表中找到 设置Id为后代的所有 祖先 包括自己
|
||||
var matchIdQuery2 = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.DescendantId)).Select(t => t.AncestorId);
|
||||
//闭包表中找到 设置Id为祖先的所有 后代 包括自己
|
||||
var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
|
||||
|
||||
//闭包表中找到 设置Id为后代的所有 祖先 包括自己
|
||||
var matchIdQuery2 = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.DescendantId)).Select(t => t.AncestorId);
|
||||
|
||||
|
||||
var unionQuery = matchIdQuery.Union(matchIdQuery2);
|
||||
var unionQuery = matchIdQuery.Union(matchIdQuery2);
|
||||
|
||||
await _auditDocumentRepository.BatchUpdateNoTrackingAsync(t => unionQuery.Contains(t.Id), u => new AuditDocument() { IsAuthorization = inDto.IsAuthorization });
|
||||
await _auditDocumentRepository.BatchUpdateNoTrackingAsync(t => unionQuery.Contains(t.Id), u => new AuditDocument() { IsAuthorization = inDto.IsAuthorization });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//闭包表中找到 设置Id为祖先的所有 后代 包括自己
|
||||
var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
|
||||
|
||||
await _auditDocumentRepository.BatchUpdateNoTrackingAsync(t => matchIdQuery.Contains(t.Id), u => new AuditDocument() { IsAuthorization = inDto.IsAuthorization });
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
|
@ -378,44 +392,6 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动文件或者文件夹 到其他文件夹
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> MovieFileOrFolder(MovieFileOrFolderInDto inDto)
|
||||
{
|
||||
|
||||
//闭包表中找到 设置Id为祖先的所有 后代 包括自己
|
||||
var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
|
||||
|
||||
//无法将当前文件夹移动到当前目录以及子文件夹
|
||||
|
||||
if (matchIdQuery.Any(t => t == inDto.ParentId))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMove"]);
|
||||
}
|
||||
|
||||
foreach (var id in inDto.Ids)
|
||||
{
|
||||
|
||||
//移动ParentId
|
||||
var node = await _auditDocumentRepository.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
node.ParentId = inDto.ParentId;
|
||||
await _auditDocumentRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
// 删除原有闭包关系
|
||||
await _auditDocumentClosureRepository.BatchDeleteNoTrackingAsync(t => t.DescendantId == id || t.AncestorId == id);
|
||||
|
||||
//建立新的闭包关系
|
||||
await AddClosureRelationsAsync(node.Id, inDto.ParentId);
|
||||
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -592,6 +568,63 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
|
||||
#region 闭包维护关系,只处理最底层调用 AddOrUpdateAuditDocument
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动文件或者文件夹 到其他文件夹
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> MovieFileOrFolder(MovieFileOrFolderInDto inDto)
|
||||
{
|
||||
|
||||
//闭包表中找到 设置Id为祖先的所有 后代 包括自己
|
||||
var matchIdQuery = _auditDocumentClosureRepository.Where(t => inDto.Ids.Contains(t.AncestorId)).Select(t => t.DescendantId);
|
||||
|
||||
//无法将当前文件夹移动到当前目录以及子文件夹
|
||||
|
||||
if (matchIdQuery.Any(t => t == inDto.ParentId))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMove"]);
|
||||
}
|
||||
|
||||
foreach (var id in inDto.Ids)
|
||||
{
|
||||
var node = await _auditDocumentRepository.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
//找到设置父节点的儿子节点
|
||||
var existSameName = await _auditDocumentClosureRepository
|
||||
.Where(t => t.AncestorId == inDto.ParentId && t.Depth == 1)
|
||||
.Select(t => t.Descendant).AnyAsync(t => t.Name == node.Name && t.AuditDocumentTypeEnum == node.AuditDocumentTypeEnum);
|
||||
|
||||
//不存在同名节点,那么直接移动
|
||||
if (!existSameName)
|
||||
{
|
||||
//移动ParentId
|
||||
|
||||
|
||||
node.ParentId = inDto.ParentId;
|
||||
|
||||
await _auditDocumentRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
// 删除原有闭包关系
|
||||
await _auditDocumentClosureRepository.BatchDeleteNoTrackingAsync(t => matchIdQuery.Contains(t.DescendantId) || matchIdQuery.Contains(t.AncestorId));
|
||||
|
||||
|
||||
//建立新的节点的闭包关系
|
||||
await AddClosureRelationsAsync(node.Id, inDto.ParentId);
|
||||
|
||||
//建立新的节点后的子孙后代闭包关系 不包括自己
|
||||
|
||||
//var chai _auditDocumentClosureRepository.Where(t => t.AncestorId == id && t.Depth > 0).OrderBy(t => t.Depth).Select(t => t.DescendantId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复制文件或者文件夹
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue