Skip to content

Commit 1a520e3

Browse files
committed
add record.ts
1 parent a80591d commit 1a520e3

5 files changed

Lines changed: 200 additions & 8 deletions

File tree

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/jpa/FlowRecordEntityRepository.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import com.codingapi.flow.infra.entity.FlowRecordEntity;
44
import com.codingapi.springboot.fast.jpa.repository.FastRepository;
5+
import org.springframework.data.domain.Page;
6+
import org.springframework.data.domain.PageRequest;
7+
import org.springframework.data.jpa.repository.Query;
58

69
import java.util.List;
710

8-
public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEntity,Long> {
11+
public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEntity, Long> {
912

1013
FlowRecordEntity getFlowRecordEntityById(long id);
1114

@@ -14,11 +17,20 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
1417
List<FlowRecordEntity> findFlowRecordEntityByFromIdAndNodeIdAndRevoked(long fromId, String nodeId, boolean revoked);
1518

1619
List<FlowRecordEntity> findFlowRecordEntityByProcessIdAndRecordStateAndFlowStateAndHiddenAndRevoked(String processId,
17-
int recordState,
18-
int flowState,
19-
boolean hidden,
20-
boolean revoked);
20+
int recordState,
21+
int flowState,
22+
boolean hidden,
23+
boolean revoked);
2124

2225
List<FlowRecordEntity> findFlowRecordEntityByProcessIdAndFromIdGreaterThanEqual(String processId, long fromId);
2326

27+
28+
@Query("from FlowRecordEntity r where r.currentOperatorId = ?1 and (r.recordState = 0 and r.flowState = 0 and r.hidden=false and r.revoked = false)")
29+
Page<FlowRecordEntity> findTodoPage(long operatorId, PageRequest pageRequest);
30+
31+
32+
@Query("from FlowRecordEntity r where r.currentOperatorId = ?1 and (r.recordState = 1 and r.hidden=false and r.revoked = false) ")
33+
Page<FlowRecordEntity> findDonePage(long operatorId, PageRequest pageRequest);
34+
35+
2436
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.codingapi.flow.query.controller;
2+
3+
import com.codingapi.flow.infra.entity.FlowRecordEntity;
4+
import com.codingapi.flow.infra.jpa.FlowRecordEntityRepository;
5+
import com.codingapi.flow.operator.IFlowOperator;
6+
import com.codingapi.springboot.framework.dto.request.SearchRequest;
7+
import com.codingapi.springboot.framework.dto.response.MultiResponse;
8+
import com.codingapi.springboot.framework.user.UserContext;
9+
import lombok.AllArgsConstructor;
10+
import org.springframework.data.domain.PageRequest;
11+
import org.springframework.web.bind.annotation.GetMapping;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RestController;
14+
15+
@RestController
16+
@RequestMapping("/api/query/record")
17+
@AllArgsConstructor
18+
public class FlowRecordQueryController {
19+
20+
private final FlowRecordEntityRepository flowRecordEntityRepository;
21+
22+
/**
23+
* 全部流程记录接口
24+
*/
25+
@GetMapping("/list")
26+
public MultiResponse<FlowRecordEntity> list(SearchRequest request) {
27+
return MultiResponse.of(flowRecordEntityRepository.searchRequest(request));
28+
}
29+
30+
31+
/**
32+
* 我的待办记录
33+
*/
34+
@GetMapping("/todo")
35+
public MultiResponse<FlowRecordEntity> todo(SearchRequest request) {
36+
IFlowOperator current = (IFlowOperator) UserContext.getInstance().current();
37+
PageRequest pageRequest = request.toPageRequest(FlowRecordEntity.class);
38+
return MultiResponse.of(flowRecordEntityRepository.findTodoPage(current.getUserId(),pageRequest));
39+
}
40+
41+
42+
/**
43+
* 我的已办记录
44+
*/
45+
@GetMapping("/done")
46+
public MultiResponse<FlowRecordEntity> done(SearchRequest request) {
47+
IFlowOperator current = (IFlowOperator) UserContext.getInstance().current();
48+
PageRequest pageRequest = request.toPageRequest(FlowRecordEntity.class);
49+
return MultiResponse.of(flowRecordEntityRepository.findDonePage(current.getUserId(),pageRequest));
50+
}
51+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { httpClient } from "."
2+
3+
export const list = (request: any) => {
4+
return httpClient.page('/api/query/record/list', request, {}, {}, []);
5+
}
6+
7+
export const todo = (request: any) => {
8+
return httpClient.page('/api/query/record/todo', request, {}, {}, []);
9+
}
10+
11+
export const done = (request: any) => {
12+
return httpClient.page('/api/query/record/done', request, {}, {}, []);
13+
}

frontend/apps/app-pc/src/config/routers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const routers = [
1515
{
1616
path:'/user',
1717
element:<UserPage/>,
18-
name: '用户界面'
18+
name: '用户管理'
1919
},
2020
{
2121
path:'/design',

frontend/apps/app-pc/src/pages/todo.tsx

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,127 @@
11
import React from "react";
2-
2+
import {list,todo,done} from "@/api/record.ts";
3+
import {type ActionType, type TableProps,Table} from "@flow-engine/flow-design";
4+
import {Button, Space, Tabs,type TabsProps } from "antd";
35

46
const TodoPage:React.FC = ()=>{
57

8+
const actionAll = React.useRef<ActionType>(null);
9+
const actionTodo = React.useRef<ActionType>(null);
10+
const actionDone = React.useRef<ActionType>(null);
11+
12+
const columns: TableProps<any>['columns'] = [
13+
{
14+
dataIndex: 'id',
15+
title: '编号',
16+
},
17+
{
18+
dataIndex: 'title',
19+
title: '流程名称',
20+
},
21+
{
22+
dataIndex: 'readTime',
23+
title: '读取状态',
24+
},
25+
{
26+
dataIndex: 'createTime',
27+
title: '创建时间',
28+
},
29+
{
30+
dataIndex: 'currentOperatorId',
31+
title: '审批人',
32+
},
33+
{
34+
dataIndex: 'recordState',
35+
title: '状态',
36+
},
37+
{
38+
dataIndex: 'option',
39+
title: '操作',
40+
render: (value, record) => {
41+
return (
42+
<Space>
43+
<a onClick={() => {
44+
45+
}}>办理</a>
46+
</Space>
47+
)
48+
}
49+
}
50+
];
51+
52+
53+
const items:TabsProps['items'] = [
54+
{
55+
key:'all',
56+
label:'全部流程',
57+
children:(
58+
<Table
59+
rowKey={"id"}
60+
actionType={actionAll}
61+
columns={columns}
62+
request={(request) => {
63+
return list(request);
64+
}}
65+
/>
66+
)
67+
},
68+
{
69+
key:'todo',
70+
label:'我的待办',
71+
children:(
72+
<Table
73+
rowKey={"id"}
74+
actionType={actionTodo}
75+
columns={columns}
76+
request={(request) => {
77+
return todo(request);
78+
}}
79+
/>
80+
)
81+
},
82+
{
83+
key:'done',
84+
label:'我的已办',
85+
children:(
86+
<Table
87+
rowKey={"id"}
88+
actionType={actionDone}
89+
columns={columns}
90+
request={(request) => {
91+
return done(request);
92+
}}
93+
/>
94+
)
95+
}
96+
]
97+
698
return (
799
<div>
8-
todo
100+
<Tabs
101+
items={items}
102+
centered={true}
103+
onChange={(currentKey)=>{
104+
if(currentKey==='all'){
105+
actionAll.current?.reload();
106+
}
107+
if(currentKey==='done'){
108+
actionDone.current?.reload();
109+
}
110+
if(currentKey==='todo'){
111+
actionTodo.current?.reload();
112+
}
113+
}}
114+
tabBarExtraContent={{
115+
right:(
116+
<Button
117+
key={"create"}
118+
type={'primary'}
119+
onClick={() => {
120+
121+
}}>发起流程</Button>
122+
)
123+
}}
124+
/>
9125
</div>
10126
)
11127
}

0 commit comments

Comments
 (0)