|
|
@@ -1,9 +1,13 @@
|
|
|
package com.mooctest.crowd.domain.domainobject;
|
|
|
|
|
|
+import com.mooctest.crowd.domain.exception.CrowdTestTaskException;
|
|
|
+import com.mooctest.crowd.domain.exception.CrowdTestTaskNotExistException;
|
|
|
+import com.mooctest.crowd.domain.exception.UnauthorizedException;
|
|
|
import lombok.Data;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @author guochao
|
|
|
@@ -66,7 +70,46 @@ public class CrowdTestTask {
|
|
|
// throw new CrowdTestReportNotExistException();
|
|
|
// }
|
|
|
|
|
|
+ /**
|
|
|
+ * 接收任务(测评机构)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void receive(User user) {
|
|
|
+ //判断是否为测评机构
|
|
|
+ EvaluationAgency evaluationAgency = user.getEvaluationAgency();
|
|
|
+ if(evaluationAgency == null){
|
|
|
+ throw new UnauthorizedException("当前用户不是测评机构,没有权限接收任务");
|
|
|
+ }
|
|
|
+ //任务当前状态
|
|
|
+ if (this.getStatus()!=CrowdTestTaskStatus.HAS_RELEASED)
|
|
|
+ throw new CrowdTestTaskException("任务当前状态不能被接收,当前状态为:"+this.getStatus());
|
|
|
+ //定向发布类型
|
|
|
+ if (this.getDistributionType() == 0) {
|
|
|
+ if (!this.getEvaluationAgencyId().equals(user.getId()))
|
|
|
+ throw new CrowdTestTaskException("当前用户没有权限接收此定向发布的任务!");
|
|
|
+ }
|
|
|
+ this.setEvaluationAgencyId(user.getId());
|
|
|
+ this.setStatus(CrowdTestTaskStatus.HAS_RECEIVED);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void reject(Long userId){
|
|
|
+ if (this.getDistributionType()!=0 || this.getStatus()!=CrowdTestTaskStatus.HAS_RELEASED || !this.getEvaluationAgencyId().equals(userId)){
|
|
|
+ throw new CrowdTestTaskException("非法操作!");
|
|
|
+ }
|
|
|
+ this.setStatus(CrowdTestTaskStatus.HAS_REJECTED);
|
|
|
+ }
|
|
|
+
|
|
|
public void removeCrowdTestTask() {
|
|
|
this.isDeleted = DeletedStatus.isDeleted;
|
|
|
}
|
|
|
+
|
|
|
+ public void commit(Long userId) {
|
|
|
+ if (this.getStatus()!=CrowdTestTaskStatus.HAS_RECEIVED || this.getCrowdTestReportList()==null || this.getCrowdTestReportList().size()<1){
|
|
|
+ throw new CrowdTestTaskException("当前状态不能提交任务");
|
|
|
+ }
|
|
|
+ if (!this.getEvaluationAgencyId().equals(userId)){
|
|
|
+ throw new UnauthorizedException("无权对此任务进行操作");
|
|
|
+ }
|
|
|
+ this.setStatus(CrowdTestTaskStatus.HAS_COMMITED);
|
|
|
+ }
|
|
|
}
|