fix(channel): 修复问题模板重复校验 SQL 语法错误
避免 SqlSugar 翻译闭包 null 比较,改用分支与布尔标志构建查询条件。
This commit is contained in:
parent
4f5390ccb1
commit
0c763f9707
@ -101,12 +101,16 @@ public class IssueTemplateService : ApplicationService
|
|||||||
{
|
{
|
||||||
var normalizedOrg = NormalizeOrganizationId(organizationId);
|
var normalizedOrg = NormalizeOrganizationId(organizationId);
|
||||||
var normalizedType = issueType?.Trim();
|
var normalizedType = issueType?.Trim();
|
||||||
|
var hasOrgFilter = normalizedOrg != null;
|
||||||
|
var hasTypeFilter = !string.IsNullOrWhiteSpace(normalizedType);
|
||||||
|
var orgValue = normalizedOrg ?? string.Empty;
|
||||||
|
var typeValue = normalizedType ?? string.Empty;
|
||||||
|
|
||||||
var entities = await IssueTemplateRepository.GetListAsync(x =>
|
var entities = await IssueTemplateRepository.GetListAsync(x =>
|
||||||
x.Status == EnableStatus.Enabled
|
x.Status == EnableStatus.Enabled
|
||||||
&& (string.IsNullOrWhiteSpace(normalizedType) || x.IssueType == normalizedType)
|
&& (!hasTypeFilter || x.IssueType == typeValue)
|
||||||
&& (normalizedOrg == null
|
&& (!hasOrgFilter
|
||||||
|| x.OrganizationId == normalizedOrg
|
|| x.OrganizationId == orgValue
|
||||||
|| x.OrganizationId == null
|
|| x.OrganizationId == null
|
||||||
|| x.OrganizationId == string.Empty));
|
|| x.OrganizationId == string.Empty));
|
||||||
|
|
||||||
@ -136,12 +140,14 @@ public class IssueTemplateService : ApplicationService
|
|||||||
var organizationId = NormalizeOrganizationId(input.OrganizationId);
|
var organizationId = NormalizeOrganizationId(input.OrganizationId);
|
||||||
var issueType = input.IssueType?.Trim();
|
var issueType = input.IssueType?.Trim();
|
||||||
var keyword = input.Keyword?.Trim();
|
var keyword = input.Keyword?.Trim();
|
||||||
var status = input.Status;
|
var hasOrganizationFilter = organizationId != null;
|
||||||
|
var hasStatusFilter = input.Status.HasValue;
|
||||||
|
var statusValue = input.Status.GetValueOrDefault();
|
||||||
|
|
||||||
return entity =>
|
return entity =>
|
||||||
(organizationId == null || entity.OrganizationId == organizationId)
|
(!hasOrganizationFilter || entity.OrganizationId == organizationId)
|
||||||
&& (string.IsNullOrWhiteSpace(issueType) || entity.IssueType == issueType)
|
&& (string.IsNullOrWhiteSpace(issueType) || entity.IssueType == issueType)
|
||||||
&& (status == null || (byte)entity.Status == status.Value)
|
&& (!hasStatusFilter || (byte)entity.Status == statusValue)
|
||||||
&& (string.IsNullOrWhiteSpace(keyword)
|
&& (string.IsNullOrWhiteSpace(keyword)
|
||||||
|| entity.Title.Contains(keyword)
|
|| entity.Title.Contains(keyword)
|
||||||
|| entity.Content.Contains(keyword));
|
|| entity.Content.Contains(keyword));
|
||||||
|
|||||||
@ -15,13 +15,24 @@ public class IssueTemplateRepository : OmsSqlSugarRepository<IssueTemplate>, IIs
|
|||||||
{
|
{
|
||||||
var normalizedOrg = string.IsNullOrWhiteSpace(organizationId) ? null : organizationId.Trim();
|
var normalizedOrg = string.IsNullOrWhiteSpace(organizationId) ? null : organizationId.Trim();
|
||||||
var normalizedType = issueType.Trim();
|
var normalizedType = issueType.Trim();
|
||||||
|
var hasExcludeId = excludeId.HasValue;
|
||||||
|
var excludeIdValue = excludeId.GetValueOrDefault();
|
||||||
|
|
||||||
|
if (normalizedOrg == null)
|
||||||
|
{
|
||||||
|
return await AnyAsync(
|
||||||
|
x =>
|
||||||
|
x.IssueType == normalizedType
|
||||||
|
&& (x.OrganizationId == null || x.OrganizationId == string.Empty)
|
||||||
|
&& (!hasExcludeId || x.Id != excludeIdValue),
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
return await AnyAsync(
|
return await AnyAsync(
|
||||||
x =>
|
x =>
|
||||||
x.IssueType == normalizedType
|
x.IssueType == normalizedType
|
||||||
&& ((normalizedOrg == null && (x.OrganizationId == null || x.OrganizationId == string.Empty))
|
&& x.OrganizationId == normalizedOrg
|
||||||
|| x.OrganizationId == normalizedOrg)
|
&& (!hasExcludeId || x.Id != excludeIdValue),
|
||||||
&& (!excludeId.HasValue || x.Id != excludeId.Value),
|
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user