1.补充接口返回参数

This commit is contained in:
chenweilong 2022-12-14 18:34:58 +08:00
parent a8a34b1612
commit a0ce94a351
5 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package com.example.liteflow.mysql.controller;
import com.example.liteflow.mysql.model.CommonResult;
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
import com.example.liteflow.mysql.service.BaseChainService;
import com.example.liteflow.mysql.service.BaseNodeService;
@ -21,13 +22,13 @@ public class BaseChainController {
private BaseChainService baseChainService;
@PostMapping("/generateDynamicChain")
public void generateDynamicChain() {
baseChainService.generateDynamicChain();
public CommonResult generateDynamicChain() {
return baseChainService.generateDynamicChain();
}
@GetMapping("/executeChain/{chainName}")
public void executeChain(@PathVariable String chainName) {
baseChainService.executeChain(chainName);
public CommonResult executeChain(@PathVariable String chainName) {
return baseChainService.executeChain(chainName);
}
}

View File

@ -1,5 +1,6 @@
package com.example.liteflow.mysql.controller;
import com.example.liteflow.mysql.model.CommonResult;
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
import com.example.liteflow.mysql.service.BaseNodeService;
import lombok.extern.slf4j.Slf4j;
@ -23,8 +24,8 @@ public class BaseNodeController {
private BaseNodeService baseNodeService;
@PostMapping("/createNode")
public void createNode(@RequestBody CreateNodeFrom createNodeFrom) {
baseNodeService.createNode(createNodeFrom);
public CommonResult createNode(@RequestBody CreateNodeFrom createNodeFrom) {
return baseNodeService.createNode(createNodeFrom);
}
}

View File

@ -43,5 +43,10 @@ public class CommonResult<T> {
commonResult.setData(obj);
return commonResult;
}
public static CommonResult success(Object obj) {
CommonResult commonResult = new CommonResult();
commonResult.setCode(200);
commonResult.setData(obj);
return commonResult;
}
}

View File

@ -19,5 +19,5 @@ public interface BaseChainService extends IService<BaseChainEntity> {
void initMainChain();
List<BaseCenter> executeChain(String chainName);
CommonResult executeChain(String chainName);
}

View File

@ -276,7 +276,7 @@ public class BaseChainServiceImpl extends ServiceImpl<BaseChainMapper, BaseChain
}
@Override
public List<BaseCenter> executeChain(String chainName) {
public CommonResult executeChain(String chainName) {
List<BaseCenter> list = this.generateCostCenterTestData();
log.info("before-list = {}", JSONUtil.toJsonStr(list));
list.forEach(item -> {
@ -288,7 +288,7 @@ public class BaseChainServiceImpl extends ServiceImpl<BaseChainMapper, BaseChain
}
});
log.info("after-list = {}", JSONUtil.toJsonStr(list));
return list;
return CommonResult.success(list);
}
private List<BaseCenter> generateCostCenterTestData() {