|
@@ -105,13 +105,38 @@ public class FormulaController {
|
|
|
this.jdbcTemplate.batchUpdate(sql);
|
|
|
return R.success("公式已删除");
|
|
|
}
|
|
|
- return R.status(this.service.updateById(fa));
|
|
|
+ this.service.updateById(fa);
|
|
|
+ return R.data(fa.getId());
|
|
|
}
|
|
|
}
|
|
|
return R.fail("保存不成功,请检查elementId、formula、scope字段是否为空");
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "删除元素公式", notes = "删除元素公式")
|
|
|
+ public R delete(@RequestParam String ids,Integer scope) {
|
|
|
+ if(StringUtils.isNotEmpty(ids,scope)){
|
|
|
+ String[] arr = ids.split(",");
|
|
|
+ for(String id:arr){
|
|
|
+ String[] sql;
|
|
|
+ if(this.elementFormulaMappingService.count(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getFormulaId,id))>1){
|
|
|
+ this.jdbcTemplate.execute("delete from m_element_formula_mapping where formula_id="+id +" and scope="+scope);
|
|
|
+ }else {
|
|
|
+ /*假设这个公式没有别的有效关联,一并删除*/
|
|
|
+ sql =new String[]{
|
|
|
+ "delete from m_formula where id ="+id,
|
|
|
+ "delete from m_element_formula_mapping where formula_id="+id +" and scope="+scope
|
|
|
+ };
|
|
|
+ this.jdbcTemplate.batchUpdate(sql);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ return R.success("删除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.fail("无效id");
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
@@ -121,9 +146,9 @@ public class FormulaController {
|
|
|
@ApiOperation(value = "删除", notes = "传入id集合")
|
|
|
public R remove(@RequestParam String ids) {
|
|
|
if(StringUtils.isNotEmpty(ids)) {
|
|
|
- List<Long> ids_d=Func.toLongList(ids);
|
|
|
- this.elementFormulaMappingService.update(Wrappers.<ElementFormulaMapping>lambdaUpdate().set(ElementFormulaMapping::getIsDeleted, 1).in(ElementFormulaMapping::getFormulaId,ids_d));
|
|
|
- return R.status(this.service.deleteLogic(ids_d));
|
|
|
+ List<Long> idsDel=Func.toLongList(ids);
|
|
|
+ this.elementFormulaMappingService.update(Wrappers.<ElementFormulaMapping>lambdaUpdate().set(ElementFormulaMapping::getIsDeleted, 1).in(ElementFormulaMapping::getFormulaId,idsDel));
|
|
|
+ return R.status(this.service.deleteLogic(idsDel));
|
|
|
}
|
|
|
return R.fail("无效id");
|
|
|
}
|
|
@@ -142,9 +167,9 @@ public class FormulaController {
|
|
|
if(Func.isNotEmpty(f.getProjectId())){
|
|
|
sb.append(" and a.project_id=").append(f.getProjectId());
|
|
|
}
|
|
|
- List<Map<String,Object>> maplist = this.jdbcTemplate.queryForList("select b.* from m_element_formula_mapping a INNER JOIN m_formula b on a.formula_id=b.id where a.element_id="+f.getElementId()+" and b.is_deleted=0 and a.scope ="+f.getScope());
|
|
|
- if(Func.isNotEmpty(maplist)){
|
|
|
- return R.data(BeanUtil.toBean(maplist.get(0),FormulaBean.class));
|
|
|
+ List<Map<String,Object>> listMap = this.jdbcTemplate.queryForList("select b.* from m_element_formula_mapping a INNER JOIN m_formula b on a.formula_id=b.id where a.element_id="+f.getElementId()+" and b.is_deleted=0 and a.scope ="+f.getScope());
|
|
|
+ if(Func.isNotEmpty(listMap)){
|
|
|
+ return R.data(BeanUtil.toBean(listMap.get(0),FormulaBean.class));
|
|
|
}
|
|
|
|
|
|
}
|