Skip to content

Dev #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 14, 2025
Merged

Dev #93

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
2 changes: 1 addition & 1 deletion admin-ui/src/pages/flow/leave/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const LeavePage = () => {
view={LeaveForm}
workCode={"leave"}
formParams={{
clazzName: 'com.codingapi.example.domain.Leave',
clazzName: 'com.codingapi.example.infra.flow.form.LeaveForm',
username: username
}}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.codingapi.example.app.cmd.domain.configuration;

import com.codingapi.example.domain.leave.repository.LeaveRepository;
import com.codingapi.example.domain.leave.service.LeaveService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LeaveDomainConfiguration {

@Bean
public LeaveService leaveService(LeaveRepository leaveRepository){
return new LeaveService(leaveRepository);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.codingapi.example.app.cmd.domain.configuration;

import com.codingapi.example.domain.user.gateway.PasswordEncoder;
import com.codingapi.example.domain.user.repository.UserRepository;
import com.codingapi.example.domain.user.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserDomainConfiguration {

@Bean
public UserService userService(UserRepository userRepository, PasswordEncoder passwordEncoder) {
return new UserService(userRepository, passwordEncoder);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.codingapi.example.app.cmd.domain.pojo;

import com.codingapi.example.domain.user.entity.UserMetric;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -12,6 +13,11 @@ public static class UpdateRequest{
private String name;
private String username;
private String password;

public UserMetric toMetric(){
return new UserMetric(name, username, password);
}

private boolean flowManager;

public boolean hasId(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
package com.codingapi.example.app.cmd.domain.router;

import com.codingapi.example.app.cmd.domain.pojo.UserCmd;
import com.codingapi.example.domain.user.entity.User;
import com.codingapi.example.domain.user.gateway.PasswordEncoder;
import com.codingapi.example.domain.user.repository.UserRepository;
import com.codingapi.example.domain.user.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
public class UserRouter {

private final UserRepository userRepository;
private final PasswordEncoder passwordEncoder;

public void save(UserCmd.UpdateRequest request){
if(request.hasId()){
User user = userRepository.getUserById(request.getId());
user.setName(request.getName());
user.setPassword(request.getPassword());
user.setFlowManager(request.isFlowManager());
user.encodePassword(passwordEncoder);
userRepository.save(user);
}else {
User user = new User();
user.setName(request.getName());
user.setPassword(request.getPassword());
user.setFlowManager(request.isFlowManager());
user.encodePassword(passwordEncoder);
userRepository.save(user);
private final UserService userService;

public void createOrUpdate(UserCmd.UpdateRequest request) {
if (request.hasId()) {
userService.update(request.getId(), request.toMetric());
} else {
userService.create(request.toMetric());
}
}

public void removeEntrust(long id) {
userService.removeEntrust(id);
}

public void createEntrust(UserCmd.EntrustRequest request) {
userService.createEntrust(request.getId(),request.getEntrustUserId());
}

public void changeManager(long id) {
userService.changeManager(id);
}

public void removeUser(long id) {
userService.removeUser(id);
}
}
12 changes: 12 additions & 0 deletions example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra-flow</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra-security</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.codingapi.example.pojo.cmd;
package com.codingapi.example.app.cmd.meta.pojo;

import com.alibaba.fastjson.JSONObject;
import com.codingapi.springboot.flow.bind.IBindData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.codingapi.example.pojo.cmd;
package com.codingapi.example.app.cmd.meta.pojo;

import com.codingapi.springboot.security.gateway.TokenContext;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.codingapi.example.app.cmd.meta.service;

import com.codingapi.example.app.cmd.meta.pojo.FlowCmd;
import com.codingapi.example.infra.flow.user.FlowUserRepository;
import com.codingapi.springboot.flow.pojo.FlowResult;
import com.codingapi.springboot.flow.pojo.FlowStepResult;
import com.codingapi.springboot.flow.pojo.FlowSubmitResult;
import com.codingapi.springboot.flow.result.MessageResult;
import com.codingapi.springboot.flow.service.FlowService;
import com.codingapi.springboot.flow.user.IFlowOperator;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class FlowRecordRouter {


private final FlowService flowService;
private final FlowUserRepository flowUserRepository;

public FlowResult startFlow(FlowCmd.StartFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
return flowService.startFlow(request.getWorkCode(), current, request.getBindData(), request.getAdvice());
}

public FlowStepResult getFlowStep(FlowCmd.FlowStep request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
return flowService.getFlowStep(request.getWorkCode(), request.getBindData(), current);
}


public FlowSubmitResult trySubmitFlow(FlowCmd.SubmitFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
if (request.getRecordId() > 0) {
return flowService.trySubmitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion());
} else {
return flowService.trySubmitFlow(request.getWorkCode(), current, request.getBindData(), request.getOpinion());
}
}


public FlowResult submitFlow(FlowCmd.SubmitFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
if (current.isFlowManager()) {
return flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion());
} else {
return flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion());
}
}

public MessageResult customFlowEvent(FlowCmd.CustomFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
return flowService.customFlowEvent(request.getRecordId(), current, request.getButtonId(), request.getBindData(), request.getOpinion());
}


public void save(FlowCmd.SaveFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
flowService.save(request.getRecordId(), current, request.getBindData(), request.getAdvice());
}

public void recall(FlowCmd.RecallFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
flowService.recall(request.getRecordId(), current);
}


public void transfer(FlowCmd.TransferFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
IFlowOperator target = flowUserRepository.getFlowOperatorById(request.getTargetUserId());
flowService.transfer(request.getRecordId(), current, target, request.getBindData(), request.getAdvice());
}


public void postponed(FlowCmd.PostponedFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
flowService.postponed(request.getRecordId(), current, request.getTimeOut());
}


public void urge(FlowCmd.UrgeFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
flowService.urge(request.getRecordId(), current);
}


public void remove(FlowCmd.RemoveFlow request) {
IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName());
flowService.remove(request.getRecordId(), current);
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
package com.codingapi.example.router;
package com.codingapi.example.app.cmd.meta.service;

import com.codingapi.example.domain.User;
import com.codingapi.example.entity.FlowWorkEntity;
import com.codingapi.example.jpa.FlowWorkEntityRepository;
import com.codingapi.example.pojo.cmd.FlowWorkCmd;
import com.codingapi.example.repository.UserRepository;
import com.codingapi.example.app.cmd.meta.pojo.FlowWorkCmd;
import com.codingapi.example.infra.flow.entity.FlowWorkEntity;
import com.codingapi.example.infra.flow.jpa.FlowWorkEntityRepository;
import com.codingapi.example.infra.flow.user.FlowUserRepository;
import com.codingapi.springboot.flow.domain.FlowWork;
import com.codingapi.springboot.flow.repository.FlowWorkRepository;
import com.codingapi.springboot.flow.user.IFlowOperator;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@AllArgsConstructor
@Transactional
public class FlowWorkRouter {

private final FlowWorkRepository flowWorkRepository;
private final FlowWorkEntityRepository flowWorkEntityRepository;
private final UserRepository userRepository;
private final FlowUserRepository flowUserRepository;

public void delete(long id) {
flowWorkRepository.delete(id);
}

public void save(FlowWorkCmd.CreateRequest request) {
User user = userRepository.getUserByUsername(request.getUsername());
IFlowOperator user = flowUserRepository.getUserByUsername(request.getUsername());
long id = request.getId();
if (id == 0) {
FlowWork flowWork = new FlowWork(
Expand Down
20 changes: 20 additions & 0 deletions example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,24 @@
</properties>


<dependencies>
<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra-jpa</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra-flow</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra-security</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
</project>
Loading