1.增加更新方法
This commit is contained in:
parent
cf4600f404
commit
acbc45124c
|
@ -3,7 +3,6 @@ package com.example.liteflow.mysql.bean;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.googlecode.aviator.AviatorEvaluator;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -40,4 +40,9 @@ public class ChainController {
|
|||
public String deleteChain(@PathVariable("id") String id) {
|
||||
return chainService.deleteChain(id);
|
||||
}
|
||||
|
||||
@PostMapping("/updateChain")
|
||||
public String updateChain(@RequestBody ChainEntity chainEntity) {
|
||||
return chainService.updateChain(chainEntity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,6 @@ public interface ChainService {
|
|||
ChainEntity getChainName(String chainName);
|
||||
|
||||
String deleteChain(String id);
|
||||
|
||||
String updateChain(ChainEntity chainEntity);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.example.liteflow.mysql.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.liteflow.mysql.entity.ChainEntity;
|
||||
import com.example.liteflow.mysql.mapper.ChainMapper;
|
||||
|
@ -97,9 +99,23 @@ public class ChainServiceImpl extends ServiceImpl<ChainMapper, ChainEntity> imp
|
|||
LambdaQueryWrapper<ChainEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ChainEntity::getId, id);
|
||||
if (this.remove(queryWrapper)) {
|
||||
flowExecutor.reloadRule();
|
||||
return "删除成功";
|
||||
} else {
|
||||
return "删除失败";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String updateChain(ChainEntity chainEntity) {
|
||||
String id = chainEntity.getId();
|
||||
String elData = chainEntity.getElData();
|
||||
LambdaUpdateWrapper<ChainEntity> queryWrapper = new LambdaUpdateWrapper<>();
|
||||
queryWrapper.set(ChainEntity::getElData, elData).eq(ChainEntity::getId, id);
|
||||
if (this.update(queryWrapper)) {
|
||||
flowExecutor.reloadRule();
|
||||
return "更新成功";
|
||||
} else {
|
||||
return "更新失败";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue