|
|
@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -21,6 +22,7 @@ import com.goafanti.common.model.ValueEvaluation;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.evaluation.bo.Step1;
|
|
|
+import com.goafanti.evaluation.bo.Step2;
|
|
|
import com.goafanti.evaluation.service.ValueEvaluationService;
|
|
|
|
|
|
@RestController
|
|
|
@@ -32,14 +34,14 @@ public class EvaluationController extends BaseApiController {
|
|
|
@Autowired
|
|
|
ValueEvaluationService valueEvaluationService;
|
|
|
|
|
|
- @RequestMapping(value = "/create", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/create", method = RequestMethod.GET)
|
|
|
public Result create() {
|
|
|
ValueEvaluation ve = new ValueEvaluation();
|
|
|
ve.setUid(TokenManager.getUserId());
|
|
|
- ve.setStep(1);
|
|
|
+ ve.setStep(0);
|
|
|
ve.setLog("{}");
|
|
|
valueEvaluationService.insert(ve);
|
|
|
- return new Result(ve.getId());
|
|
|
+ return new Result(ve.getId().toString());
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
@@ -47,14 +49,14 @@ public class EvaluationController extends BaseApiController {
|
|
|
return new Result().data(valueEvaluationService.list(handlePageNo(pageNo), handlePageSize(pageSize)));
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/info", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
- public String info(String id) {
|
|
|
+ @RequestMapping(value = "/info/{id}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
+ public String info(@PathVariable String id) {
|
|
|
Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
|
return valueEvaluationService.getMyEvaluationSteps(Long.valueOf(id));
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/step1", method = RequestMethod.POST)
|
|
|
- public Result update(String id, @Valid Step1 data, BindingResult bindingResult) {
|
|
|
+ public Result step1(String id, @Valid Step1 data, BindingResult bindingResult) {
|
|
|
Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
|
Result res = new Result();
|
|
|
if (handleBindingError(res, bindingResult)) {
|
|
|
@@ -63,6 +65,24 @@ public class EvaluationController extends BaseApiController {
|
|
|
ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));
|
|
|
Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
|
|
|
ve.setName(data.getName());
|
|
|
+ ve.setStep(1);
|
|
|
+ JSONObject jo = JSON.parseObject(ve.getLog());
|
|
|
+ jo.put("0", data);
|
|
|
+ ve.setLog(jo.toJSONString());
|
|
|
+ res.data(valueEvaluationService.update(ve));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/step2", method = RequestMethod.POST)
|
|
|
+ public Result step2(String id, @Valid Step2 data, BindingResult bindingResult) {
|
|
|
+ Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
|
+ Result res = new Result();
|
|
|
+ if (handleBindingError(res, bindingResult)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));
|
|
|
+ Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
|
|
|
+ ve.setStep(2);
|
|
|
JSONObject jo = JSON.parseObject(ve.getLog());
|
|
|
jo.put("1", data);
|
|
|
ve.setLog(jo.toJSONString());
|