|
@@ -7,6 +7,7 @@ import api.common.pojo.po.scene.ScoringRulesPO;
|
|
import api.common.pojo.vo.scene.ScoringRulesVO;
|
|
import api.common.pojo.vo.scene.ScoringRulesVO;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.PythonUtil;
|
|
import api.common.util.PythonUtil;
|
|
|
|
+import api.common.util.StringUtil;
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.scene.service.ScoringRulesService;
|
|
import com.css.simulation.resource.scene.service.ScoringRulesService;
|
|
@@ -77,15 +78,7 @@ public class ScoringRulesController {
|
|
@PostMapping("/saveScoringRules")
|
|
@PostMapping("/saveScoringRules")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public ResponseBodyVO<String> saveScoringRules(@RequestBody ScoringRulesPO scoringRulesPO) {
|
|
public ResponseBodyVO<String> saveScoringRules(@RequestBody ScoringRulesPO scoringRulesPO) {
|
|
- ScoringRulesParam vo = new ScoringRulesParam();
|
|
|
|
- BeanUtils.copyProperties(scoringRulesPO, vo);
|
|
|
|
- vo.setShare("0");
|
|
|
|
- //1 检查是否存在同名平分规则
|
|
|
|
- ScoringRulesPO tmPo = scoringRulesService.querySelfOnly(vo.getRuleName(), AuthUtil.getCurrentUserId());
|
|
|
|
- if (ObjectUtil.isNotNull(tmPo)) {
|
|
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "规则 " + tmPo.getRuleName() + " 已存在,请重新命名。");
|
|
|
|
- }
|
|
|
|
- //2 校验 python 语法错误
|
|
|
|
|
|
+ //1 校验 python 语法错误
|
|
String pylint = PythonUtil.pylint(scoringRulesPO.getRuleDetails(),
|
|
String pylint = PythonUtil.pylint(scoringRulesPO.getRuleDetails(),
|
|
PythonUtil.C,
|
|
PythonUtil.C,
|
|
PythonUtil.R,
|
|
PythonUtil.R,
|
|
@@ -96,11 +89,23 @@ public class ScoringRulesController {
|
|
if (!pylint.contains(PythonUtil.PASS)) {
|
|
if (!pylint.contains(PythonUtil.PASS)) {
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "代码格式错误,请检查。");
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "代码格式错误,请检查。");
|
|
}
|
|
}
|
|
-
|
|
|
|
- //3 保存
|
|
|
|
- if (ObjectUtil.isNull(scoringRulesPO.getRulesId())) {
|
|
|
|
|
|
+ //2 判断 ruleId 是否为空
|
|
|
|
+ if (StringUtil.isEmpty(scoringRulesPO.getRulesId())) {
|
|
|
|
+ /*
|
|
|
|
+ 1 共有另存为私有
|
|
|
|
+ 2 私有另存为私有
|
|
|
|
+ 3 新增
|
|
|
|
+ */
|
|
|
|
+ // 检查私有是否存在同名平分规则
|
|
|
|
+ ScoringRulesPO tmPo = scoringRulesService.querySelfOnly(scoringRulesPO.getRuleName(), AuthUtil.getCurrentUserId());
|
|
|
|
+ if (ObjectUtil.isNotNull(tmPo)) {
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "规则 " + tmPo.getRuleName() + " 已存在,请重新命名。");
|
|
|
|
+ }
|
|
scoringRulesService.saveScoringRules(scoringRulesPO);
|
|
scoringRulesService.saveScoringRules(scoringRulesPO);
|
|
} else {
|
|
} else {
|
|
|
|
+ /*
|
|
|
|
+ 修改保存
|
|
|
|
+ */
|
|
scoringRulesService.updateScoringRules(scoringRulesPO);
|
|
scoringRulesService.updateScoringRules(scoringRulesPO);
|
|
}
|
|
}
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|