|
@@ -73,30 +73,52 @@ public class DefinitionDomainService : IDefinitionDomainService, IScopeDependenc
|
|
|
await PublishAsync(id, cancellationToken);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 查询最大版本号(含启用、禁用)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="code"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public async Task<int> GetLastVersionAsync(string code, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var definition = await GetLastVersionDefinitionAsync(code, cancellationToken);
|
|
|
- return definition?.Version ?? 0;
|
|
|
+ return await _definitionRepository.Queryable()
|
|
|
+ .Where(d => d.Code == code)
|
|
|
+ .MaxAsync(d => d.Version);
|
|
|
+
|
|
|
+ //var definition = await GetLastVersionDefinitionAsync(code, enable, cancellationToken);
|
|
|
+ //return definition?.Version ?? 0;
|
|
|
}
|
|
|
|
|
|
- public async Task<Definition?> GetLastVersionDefinitionAsync(string code, CancellationToken cancellationToken)
|
|
|
+ /// <summary>
|
|
|
+ /// 查询已启用的最后版本
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="moduleCode"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Definition?> GetLastEnableByModuleCodeAsync(string moduleCode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
return await _definitionRepository.Queryable()
|
|
|
- .Where(d => d.Code == code)
|
|
|
+ .Where(d => d.ModuleCode == moduleCode && d.Status == EDefinitionStatus.Enable)
|
|
|
.OrderByDescending(d => d.Version)
|
|
|
.Take(1)
|
|
|
.FirstAsync();
|
|
|
}
|
|
|
|
|
|
- public async Task<Definition?> GetLastVersionDefinitionByModuleCodeAsync(string moduleCode, CancellationToken cancellationToken)
|
|
|
+ /// <summary>
|
|
|
+ /// 查询已启用的最后版本
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="code"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Definition?> GetLastEnableAsync(string code, CancellationToken cancellationToken)
|
|
|
{
|
|
|
return await _definitionRepository.Queryable()
|
|
|
- .Where(d => d.ModuleCode == moduleCode)
|
|
|
+ .Where(d => d.Code == code && d.Status == EDefinitionStatus.Enable)
|
|
|
.OrderByDescending(d => d.Version)
|
|
|
.Take(1)
|
|
|
.FirstAsync();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 未开启的流程,查找第2个节点的模板配置信息,用作开始流程的时候传参
|
|
|
/// </summary>
|
|
@@ -105,7 +127,7 @@ public class DefinitionDomainService : IDefinitionDomainService, IScopeDependenc
|
|
|
/// <returns></returns>
|
|
|
public async Task<IReadOnlyList<StepDefine>> GetSecondStepsAsync(string definitionCode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var definition = await GetLastVersionDefinitionAsync(definitionCode, cancellationToken);
|
|
|
+ var definition = await GetLastEnableAsync(definitionCode, cancellationToken);
|
|
|
if (definition == null)
|
|
|
throw new UserFriendlyException($"无效模板编码, code:{definitionCode}", "无效模板编码");
|
|
|
return definition.FindSteps(definition.FindStartStep().NextSteps);
|