1.增加更新方法

This commit is contained in:
chenweilong 2022-12-09 17:02:12 +08:00
parent cf4600f404
commit acbc45124c
4 changed files with 23 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}
}

View File

@ -17,4 +17,6 @@ public interface ChainService {
ChainEntity getChainName(String chainName);
String deleteChain(String id);
String updateChain(ChainEntity chainEntity);
}

View File

@ -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 "更新失败";
}
}
}