Skip to content

Commit 085669d

Browse files
committed
add copy
1 parent 535cf7f commit 085669d

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

admin-ui/src/api/flow.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export async function save(body: any) {
2020
return post('/api/cmd/flowWork/save', body);
2121
}
2222

23+
export async function copy(id: any) {
24+
return post('/api/cmd/flowWork/copy', {id});
25+
}
26+
2327
export async function remove(id: any) {
2428
return post('/api/cmd/flowWork/delete', {id});
2529
}

admin-ui/src/pages/flow/work/index.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
ProFormText, ProFormTextArea,
1010
ProTable
1111
} from "@ant-design/pro-components";
12-
import {changeState, list, remove, save, schema} from "@/api/flow";
12+
import {changeState, copy, list, remove, save, schema} from "@/api/flow";
1313
import {Button, Drawer, message, Popconfirm, Space} from "antd";
1414

1515
const FlowPage = () => {
@@ -30,6 +30,15 @@ const FlowPage = () => {
3030
actionRef.current?.reload();
3131
}
3232

33+
const handlerCopy = async (id: any) => {
34+
const res = await copy(id);
35+
if (res.success) {
36+
message.success("复制成功");
37+
}
38+
actionRef.current?.reload();
39+
}
40+
41+
3342
const handlerChangeState = async (id: any) => {
3443
const res = await changeState(id);
3544
if (res.success) {
@@ -109,6 +118,16 @@ const FlowPage = () => {
109118
title: '操作',
110119
valueType: 'option',
111120
render: (_: any, record: any) => [
121+
<a
122+
key="design"
123+
onClick={() => {
124+
setCurrent(record);
125+
setVisible(true);
126+
}}
127+
>
128+
设计
129+
</a>,
130+
112131
<a
113132
key="editable"
114133
onClick={() => {
@@ -118,15 +137,16 @@ const FlowPage = () => {
118137
>
119138
编辑
120139
</a>,
140+
121141
<a
122-
key="design"
123-
onClick={() => {
124-
setCurrent(record);
125-
setVisible(true);
142+
key="copy"
143+
onClick={async () => {
144+
await handlerCopy(record.id);
126145
}}
127146
>
128-
设计
147+
复制
129148
</a>,
149+
130150
<Popconfirm
131151
key="delete"
132152
title={"确认删除?"}

example/example-application/src/main/java/com/codingapi/example/command/FlowWorkCmdController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public Response save(@RequestBody FlowWorkCmd.CreateRequest request){
2525
return Response.buildSuccess();
2626
}
2727

28+
@PostMapping("/copy")
29+
public Response copy(@RequestBody IdRequest request){
30+
flowWorkRouter.copy(request.getLongId());
31+
return Response.buildSuccess();
32+
}
33+
2834
@PostMapping("/schema")
2935
public Response schema(@RequestBody FlowWorkCmd.SchemaRequest request){
3036
log.info("schema:{}",request);

example/example-application/src/main/java/com/codingapi/example/router/FlowWorkRouter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@ public void schema(FlowWorkCmd.SchemaRequest request) {
5353
flowWork.schema(request.getSchema());
5454
flowWorkRepository.save(flowWork);
5555
}
56+
57+
public void copy(Long id) {
58+
FlowWork flowWork = flowWorkRepository.getFlowWorkById(id);
59+
FlowWork flowCopy = flowWork.copy();
60+
flowWorkRepository.save(flowCopy);
61+
}
5662
}

0 commit comments

Comments
 (0)