项目,个人速度和团队速度,计分规则非必填
This commit is contained in:
parent
a745c8b662
commit
b370d7f4ab
@ -23,8 +23,7 @@ public class ProjectQueryInput : Pagination
|
|||||||
|
|
||||||
public class AddProjectInput
|
public class AddProjectInput
|
||||||
{
|
{
|
||||||
/// <summary>计分规则ID。</summary>
|
/// <summary>计分规则ID(速度项目可为空,花样项目必填)。</summary>
|
||||||
[Required(ErrorMessage = "请选择计分规则")]
|
|
||||||
public long? ScoreRuleId { get; set; }
|
public long? ScoreRuleId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 项目名称
|
/// 项目名称
|
||||||
|
|||||||
@ -104,7 +104,7 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
|||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
public async Task Add(AddProjectInput input)
|
public async Task Add(AddProjectInput input)
|
||||||
{
|
{
|
||||||
await ValidateScoreRule(input.ScoreRuleId);
|
await ValidateScoreRule(input.ScoreRuleId, (ProjectTypeEnum)input.ProjectType);
|
||||||
// 验证完成人数字段
|
// 验证完成人数字段
|
||||||
if (input.CompletionCountType == 0)
|
if (input.CompletionCountType == 0)
|
||||||
{
|
{
|
||||||
@ -158,7 +158,7 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
|||||||
[UnitOfWork]
|
[UnitOfWork]
|
||||||
public async Task Update(UpdateProjectInput input)
|
public async Task Update(UpdateProjectInput input)
|
||||||
{
|
{
|
||||||
await ValidateScoreRule(input.ScoreRuleId);
|
await ValidateScoreRule(input.ScoreRuleId, (ProjectTypeEnum)input.ProjectType);
|
||||||
var entity = await _repository.GetByIdAsync(input.Id);
|
var entity = await _repository.GetByIdAsync(input.Id);
|
||||||
if (entity == null) throw new InvalidOperationException("项目不存在");
|
if (entity == null) throw new InvalidOperationException("项目不存在");
|
||||||
|
|
||||||
@ -281,9 +281,17 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
|||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ValidateScoreRule(long? scoreRuleId)
|
private async Task ValidateScoreRule(long? scoreRuleId, ProjectTypeEnum projectType)
|
||||||
{
|
{
|
||||||
if (!scoreRuleId.HasValue || !await _scoreRuleRepository.IsAnyAsync(x => x.Id == scoreRuleId.Value && x.Status == AvailabilityStatus.Enable))
|
var isSpeedProject = projectType is ProjectTypeEnum.PersonalSpeed or ProjectTypeEnum.TeamSpeed;
|
||||||
|
if (!scoreRuleId.HasValue)
|
||||||
|
{
|
||||||
|
if (isSpeedProject) return;
|
||||||
|
|
||||||
|
throw Oops.Bah("请选择有效的计分规则");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!await _scoreRuleRepository.IsAnyAsync(x => x.Id == scoreRuleId.Value && x.Status == AvailabilityStatus.Enable))
|
||||||
throw Oops.Bah("请选择有效的计分规则");
|
throw Oops.Bah("请选择有效的计分规则");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user