Exemplo n.º 1
0
        public async Task CancelAuditAsync(Resume resume, Guid auditedUserId, ResumeAuditRecord auditRecord)
        {
            if (resume == null)
            {
                throw new ArgumentNullException(nameof(resume));
            }
            if (auditedUserId == null)
            {
                throw new ArgumentNullException(nameof(auditedUserId));
            }
            if (auditRecord == null)
            {
                throw new ArgumentNullException(nameof(auditRecord));
            }

            if (auditRecord.CreatorUserId != auditedUserId)
            {
                throw new InvalidOperationException("当前审核记录非当前用户所有,无法撤销操作。");
            }

            await ResumeStore.RemoveAuditRecordAsync(resume, auditRecord, CancellationToken);

            resume.AuditStatus = AuditStatus.Ongoing;
            await ResumeStore.UpdateAsync(resume, CancellationToken);
        }
Exemplo n.º 2
0
        public async Task AuditAsync(Resume resume, bool passed, Guid auditedUserId, ResumeAuditRecord auditRecord)
        {
            if (resume == null)
            {
                throw new ArgumentNullException(nameof(resume));
            }

            if (resume.AuditStatus == AuditStatus.Complete || resume.AuditStatus == AuditStatus.Unpassed)
            {
                throw new InvalidOperationException("当前简历已处理,请勿重复操作。");
            }

            // 检查审批进度
            var auditSettings = await ResumeAuditSettingStore.GetAuditSettingsAsync(CancellationToken);

            // 检查当前用户符合审批条件
            var auditSetting = auditSettings.FirstOrDefault(f => f.UserId == auditedUserId);

            if (auditSetting == null)
            {
                throw new InvalidOperationException("当前用户无审核权限。");
            }
            // 设置审核状态
            // 如果当前节点序号大于或等于整个审批人总数,则表示审批结束
            AuditStatus auditStatus = AuditStatus.Ongoing;

            if (auditSetting.Order >= auditSettings.Count - 1)
            {
                auditStatus = AuditStatus.Complete;
            }
            if (!passed)
            {
                auditStatus = AuditStatus.Unpassed;
            }

            var audit = await ResumeStore.AddAuditRecordAsync(resume, auditRecord, CancellationToken);

            resume.AuditStatus = auditStatus;
            await ResumeStore.UpdateAsync(resume, CancellationToken);
        }