Skip to content
Merged

Dev #74

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ v.3.x 为springboot 3.x版本,使用jdk17版本

* springboot-starter | Springboot领域驱动框架
* springboot-starter-data-fast | 快速数据呈现框架
* springboot-starter-flow | 流程引擎框架
* springboot-starter-security | security权限框架支持基于JWT的无状态权限认证与Redis的有状态权限认证

## SpringBoot DDD Architecture | SpringBoot DDD 框架图
Expand All @@ -41,6 +42,13 @@ v.3.x 为springboot 3.x版本,使用jdk17版本
<version>${last.version}</version>
</dependency>

<!-- 快速数据呈现框架 -->
<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-starter-flow</artifactId>
<version>${last.version}</version>
</dependency>

<!-- security&jwt权限框架 -->
<dependency>
<groupId>com.codingapi.springboot</groupId>
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/src/components/Flow/utils/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class GroovyScript {

public static defaultOutTrigger = "def run(content) {return true;}";
public static defaultTitleGenerator = "def run(content){ return content.getCreateOperator().getName() + \'-\' + content.getFlowWork().getTitle() + \'-\' + content.getFlowNode().getName();}";
public static defaultTitleGenerator = "def run(content){ return content.getCurrentOperator().getName() + '-' + content.getFlowWork().getTitle() + '-' + content.getFlowNode().getName();}";

public static anyOperatorMatcher="def run(content) {return [content.getCurrentOperator().getUserId()];}";
public static creatorOperatorMatcher="def run(content) {return [content.getCreateOperator().getUserId()];}";
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/src/pages/flow/leave/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const LeavePage = () => {
>

<ProFormText
name={"flowId"}
name={"flowCode"}
hidden={true}
/>

Expand Down Expand Up @@ -143,7 +143,7 @@ const LeavePage = () => {

<FlowSelect visible={flowSelectVisible} setVisible={setFlowSelectVisible} onSelect={(flow) => {

form.setFieldValue('flowId', flow.id);
form.setFieldValue('flowCode', flow.code);
form.setFieldValue('flowName', flow.title);

}}/>
Expand Down
15 changes: 15 additions & 0 deletions admin-ui/src/pages/flow/work/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const FlowPage = () => {
dataIndex: 'id',
search: false,
},
{
title: '编码',
dataIndex: 'code',
},
{
title: '标题',
dataIndex: 'title',
Expand Down Expand Up @@ -218,6 +222,17 @@ const FlowPage = () => {
]}
/>

<ProFormText
name={"code"}
label={"编码"}
rules={[
{
required: true,
message: "请输入编码"
}
]}
/>

<ProFormTextArea
name={"description"}
label={"描述"}
Expand Down
2 changes: 1 addition & 1 deletion example/example-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.1</version>
<version>3.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.codingapi.example.domain.User;
import com.codingapi.example.pojo.cmd.FlowCmd;
import com.codingapi.example.repository.UserRepository;
import com.codingapi.springboot.flow.pojo.FlowDetail;
import com.codingapi.springboot.flow.pojo.FlowResult;
import com.codingapi.springboot.flow.record.FlowRecord;
import com.codingapi.springboot.flow.service.FlowService;
import com.codingapi.springboot.framework.dto.response.Response;
import com.codingapi.springboot.framework.dto.response.SingleResponse;
Expand All @@ -24,22 +25,20 @@ public class FlowRecordCmdController {
private final UserRepository userRepository;

@PostMapping("/startFlow")
public Response startFlow(@RequestBody FlowCmd.StartFlow request) {
public SingleResponse<FlowResult> startFlow(@RequestBody FlowCmd.StartFlow request) {
User current = userRepository.getUserByUsername(request.getUserName());
flowService.startFlow(request.getWorkId(), current, request.getBindData(), request.getAdvice());
return Response.buildSuccess();
return SingleResponse.of(flowService.startFlow(request.getWorkCode(), current, request.getBindData(), request.getAdvice()));
}


@PostMapping("/submitFlow")
public Response submitFlow(@RequestBody FlowCmd.SubmitFlow request) {
public SingleResponse<FlowResult> submitFlow(@RequestBody FlowCmd.SubmitFlow request) {
User current = userRepository.getUserByUsername(request.getUserName());
if(current.isFlowManager()){
flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion());
return SingleResponse.of(flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion()));
}else {
flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion());
return SingleResponse.of(flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion()));
}
return Response.buildSuccess();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import com.codingapi.example.domain.User;
import com.codingapi.example.pojo.cmd.LeaveCmd;
import com.codingapi.example.repository.UserRepository;
import com.codingapi.springboot.flow.pojo.FlowResult;
import com.codingapi.springboot.flow.service.FlowService;
import com.codingapi.springboot.framework.dto.response.Response;
import com.codingapi.springboot.framework.dto.response.SingleResponse;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -22,7 +23,7 @@ public class LeaveCmdController {


@PostMapping("/startLeave")
public Response startLeave(@RequestBody LeaveCmd.StartLeave request) {
public SingleResponse<FlowResult> startLeave(@RequestBody LeaveCmd.StartLeave request) {
User user = userRepository.getUserByUsername(request.getUsername());

Leave leave = new Leave();
Expand All @@ -31,8 +32,6 @@ public Response startLeave(@RequestBody LeaveCmd.StartLeave request) {
leave.setDays(request.getDays());
leave.setCreateTime(System.currentTimeMillis());

flowService.startFlow(request.getFlowId(), user, leave, request.getDesc());

return Response.buildSuccess();
return SingleResponse.of(flowService.startFlow(request.getFlowCode(), user, leave, request.getDesc()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FlowCmd {
@Getter
public static class StartFlow {

private long workId;
private String workCode;
private String advice;
private JSONObject formData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class CreateRequest{

private long id;
private String title;
private String code;
private String description;
private int postponedMax;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LeaveCmd {
public static class StartLeave{
private String desc;
private int days;
private long flowId;
private String flowCode;


public String getUsername(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public void save(FlowWorkCmd.CreateRequest request) {
User user = userRepository.getUserByUsername(request.getUsername());
long id = request.getId();
if (id == 0) {
FlowWork flowWork = new FlowWork(request.getTitle(), request.getDescription(), request.getPostponedMax(), user);
FlowWork flowWork = new FlowWork(request.getCode(),request.getTitle(), request.getDescription(), request.getPostponedMax(), user);
flowWorkRepository.save(flowWork);
} else {
FlowWorkEntity flowWork = flowWorkEntityRepository.getFlowWorkEntityById(id);
flowWork.setTitle(request.getTitle());
flowWork.setCode(request.getCode());
flowWork.setDescription(request.getDescription());
flowWork.setPostponedMax(request.getPostponedMax());
flowWork.setUpdateTime(System.currentTimeMillis());
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.1</version>
<version>3.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.3.1</version>
<version>3.3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class FlowRecordConvertor {

public static FlowRecordEntity convert(FlowRecord flowRecord, UserRepository userRepository) {
public static FlowRecordEntity convert(FlowRecord flowRecord) {
if (flowRecord == null) {
return null;
}
Expand All @@ -22,7 +22,7 @@ public static FlowRecordEntity convert(FlowRecord flowRecord, UserRepository use
entity.setProcessId(flowRecord.getProcessId());
entity.setNodeCode(flowRecord.getNodeCode());
entity.setTitle(flowRecord.getTitle());
entity.setCurrentOperatorId(flowRecord.getCurrentOperatorId());
entity.setCurrentOperatorId(flowRecord.getCurrentOperator().getUserId());
entity.setFlowType(flowRecord.getFlowType().name());
if (flowRecord.getFlowSourceDirection() != null) {
entity.setFlowSourceDirection(flowRecord.getFlowSourceDirection().name());
Expand All @@ -32,32 +32,34 @@ public static FlowRecordEntity convert(FlowRecord flowRecord, UserRepository use
entity.setFinishTime(flowRecord.getFinishTime());
entity.setTimeoutTime(flowRecord.getTimeoutTime());
entity.setPostponedCount(flowRecord.getPostponedCount());
entity.setCreateOperatorId(flowRecord.getCreateOperatorId());
entity.setCreateOperatorId(flowRecord.getCreateOperator().getUserId());
if (flowRecord.getOpinion() != null) {
entity.setOpinionAdvice(flowRecord.getOpinion().getAdvice());
entity.setOpinionType(flowRecord.getOpinion().getType());
entity.setOpinionResult(flowRecord.getOpinion().getResult());
}

entity.setCurrentOperatorName(userRepository.getUserById(flowRecord.getCurrentOperatorId()).getName());
entity.setCreateOperatorName(userRepository.getUserById(flowRecord.getCreateOperatorId()).getName());

entity.setCurrentOperatorName(flowRecord.getCurrentOperator().getName());
entity.setCreateOperatorName(flowRecord.getCreateOperator().getName());

entity.setFlowStatus(flowRecord.getFlowStatus().name());
entity.setErrMessage(flowRecord.getErrMessage());
entity.setBindClass(flowRecord.getBindClass());
entity.setSnapshotId(flowRecord.getSnapshotId());
entity.setRead(flowRecord.isRead());
entity.setInterfere(flowRecord.isInterfere());
entity.setInterferedOperatorId(flowRecord.getInterferedOperatorId());
if (flowRecord.isInterfere() && flowRecord.getInterferedOperatorId() > 0) {
entity.setInterferedOperatorName(userRepository.getUserById(flowRecord.getInterferedOperatorId()).getName());

if (flowRecord.getInterferedOperator()!=null) {
entity.setInterferedOperatorId(flowRecord.getInterferedOperator().getUserId());
entity.setInterferedOperatorName(flowRecord.getInterferedOperator().getName());
}
entity.setReadTime(flowRecord.getReadTime());
return entity;
}


public static FlowRecord convert(FlowRecordEntity entity) {
public static FlowRecord convert(FlowRecordEntity entity, UserRepository userRepository) {
if (entity == null) {
return null;
}
Expand All @@ -69,15 +71,15 @@ public static FlowRecord convert(FlowRecordEntity entity) {
flowRecord.setProcessId(entity.getProcessId());
flowRecord.setNodeCode(entity.getNodeCode());
flowRecord.setTitle(entity.getTitle());
flowRecord.setCurrentOperatorId(entity.getCurrentOperatorId());
flowRecord.setCurrentOperator(userRepository.getUserById(entity.getCurrentOperatorId()));
flowRecord.setFlowType(FlowType.parser(entity.getFlowType()));
flowRecord.setFlowSourceDirection(FlowSourceDirection.parser(entity.getFlowSourceDirection()));
flowRecord.setCreateTime(entity.getCreateTime());
flowRecord.setUpdateTime(entity.getUpdateTime());
flowRecord.setFinishTime(entity.getFinishTime());
flowRecord.setTimeoutTime(entity.getTimeoutTime());
flowRecord.setPostponedCount(entity.getPostponedCount());
flowRecord.setCreateOperatorId(entity.getCreateOperatorId());
flowRecord.setCreateOperator(userRepository.getUserById(entity.getCreateOperatorId()));
if (entity.getOpinionResult() != null && entity.getOpinionType() != null) {
flowRecord.setOpinion(new Opinion(entity.getOpinionAdvice(), entity.getOpinionResult(), entity.getOpinionType()));
}
Expand All @@ -87,6 +89,9 @@ public static FlowRecord convert(FlowRecordEntity entity) {
flowRecord.setSnapshotId(entity.getSnapshotId());
flowRecord.setRead(entity.getRead());
flowRecord.setInterfere(entity.getInterfere());
if(entity.getInterferedOperatorId()!=null) {
flowRecord.setInterferedOperator(userRepository.getUserById(entity.getInterferedOperatorId()));
}
flowRecord.setReadTime(entity.getReadTime());
return flowRecord;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static FlowWorkEntity convert(FlowWork flowWork) {
}
FlowWorkEntity entity = new FlowWorkEntity();
entity.setId(flowWork.getId());
entity.setCode(flowWork.getCode());
entity.setTitle(flowWork.getTitle());
entity.setDescription(flowWork.getDescription());
entity.setCreateUser(flowWork.getCreateUser().getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class FlowWorkEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(unique = true)
private String code;

private String title;

private String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public interface FlowWorkEntityRepository extends FastRepository<FlowWorkEntity,

FlowWorkEntity getFlowWorkEntityById(long id);

FlowWorkEntity getFlowWorkEntityByCode(String code);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.codingapi.example.convert.FlowRecordConvertor;
import com.codingapi.example.entity.FlowRecordEntity;
import com.codingapi.example.jpa.FlowRecordEntityRepository;
import com.codingapi.example.repository.UserRepository;
import com.codingapi.springboot.flow.query.FlowRecordQuery;
import com.codingapi.springboot.flow.record.FlowRecord;
import lombok.AllArgsConstructor;
Expand All @@ -15,41 +16,42 @@
public class FlowRecordQueryImpl implements FlowRecordQuery {

private final FlowRecordEntityRepository flowRecordEntityRepository;
private final UserRepository userRepository;


@Override
public Page<FlowRecord> findAll(PageRequest pageRequest) {
Page<FlowRecordEntity> page = flowRecordEntityRepository.findAll(pageRequest);
return page.map(FlowRecordConvertor::convert);
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
}

@Override
public Page<FlowRecord> findTodoByOperatorId(long operatorId, PageRequest pageRequest) {
Page<FlowRecordEntity> page = flowRecordEntityRepository.findTodoByOperatorId(operatorId,pageRequest);
return page.map(FlowRecordConvertor::convert);
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
}

@Override
public Page<FlowRecord> findDoneByOperatorId(long operatorId, PageRequest pageRequest) {
Page<FlowRecordEntity> page = flowRecordEntityRepository.findDoneByOperatorId(operatorId,pageRequest);
return page.map(FlowRecordConvertor::convert);
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
}

@Override
public Page<FlowRecord> findInitiatedByOperatorId(long operatorId, PageRequest pageRequest) {
Page<FlowRecordEntity> page = flowRecordEntityRepository.findInitiatedByOperatorId(operatorId,pageRequest);
return page.map(FlowRecordConvertor::convert);
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
}

@Override
public Page<FlowRecord> findTimeoutTodoByOperatorId(long operatorId, PageRequest pageRequest) {
Page<FlowRecordEntity> page = flowRecordEntityRepository.findTimeoutTodoByOperatorId(operatorId,System.currentTimeMillis(), pageRequest);
return page.map(FlowRecordConvertor::convert);
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
}

@Override
public Page<FlowRecord> findPostponedTodoByOperatorId(long operatorId, PageRequest pageRequest) {
Page<FlowRecordEntity> page = flowRecordEntityRepository.findPostponedTodoByOperatorId(operatorId,pageRequest);
return page.map(FlowRecordConvertor::convert);
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
}
}
Loading