调整
This commit is contained in:
+44
@@ -55,6 +55,50 @@ public class OnboardingTaskLifecycleService : IOnboardingTaskLifecycleService
|
||||
await Log(task, OnboardingAuditAction.Revoke, input.AuditOpinion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除已撤销的入职任务及其全部关联快照数据。
|
||||
/// </summary>
|
||||
public async Task Delete(BaseIdInput input)
|
||||
{
|
||||
var task = await Authorize(input.Id);
|
||||
if (task.TaskStatus != OnboardingTaskStatus.Revoked)
|
||||
{
|
||||
throw Oops.Bah("仅已撤销的任务可以删除");
|
||||
}
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var taskContractIds = await _db.Queryable<ObTaskContract>()
|
||||
.Where(x => x.TaskId == task.Id)
|
||||
.Select(x => x.Id)
|
||||
.ToListAsync();
|
||||
|
||||
if (taskContractIds.Count > 0)
|
||||
{
|
||||
await _db.Deleteable<ObTaskContractVariable>()
|
||||
.Where(x => taskContractIds.Contains(x.TaskContractId))
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Deleteable<ObTaskContract>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskLink>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskFormRequirement>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskMaterialRequirement>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskMaterial>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskFormValue>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskEmployeeInfo>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObTaskAudit>().Where(x => x.TaskId == task.Id).ExecuteCommandAsync();
|
||||
await _db.Deleteable<ObOnboardingTask>().In(task.Id).ExecuteCommandAsync();
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<ObOnboardingTask> Authorize(long taskId)
|
||||
{
|
||||
var task = await _db.Queryable<ObOnboardingTask>().InSingleAsync(taskId)
|
||||
|
||||
Reference in New Issue
Block a user