提交 c6e65a2b authored 作者: 黄夏豪's avatar 黄夏豪

[工作流模块] 为UserService增加了默认实现

上级 92367aee
...@@ -2,7 +2,6 @@ package com.tykj.workflowcore; ...@@ -2,7 +2,6 @@ package com.tykj.workflowcore;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
/** /**
* 测试时的启动类 * 测试时的启动类
......
package com.tykj.workflowcore; package com.tykj.workflowcore;
import com.tykj.workflowcore.api.service.ApiService;
import com.tykj.workflowcore.model_layer.service.ModelService; import com.tykj.workflowcore.model_layer.service.ModelService;
import liquibase.pro.packaged.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
......
package com.tykj.workflowcore; package com.tykj.workflowcore.config;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
......
//package com.tykj.workflowcore.workflow_editer.controller;
//
//import com.tykj.workflowcore.model_layer.model.TableInfo;
//import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
//import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
//import io.swagger.annotations.Api;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.List;
//
///**
// * ClassName: PageEntityController
// * Package: com.tykj.controller
// * Description:
// * Datetime: 2021/3/4 9:50
// *
// * @Author: zsp
// */
//@RestController
//@RequestMapping("/pageEntity")
//@Api("页面跟实体的管理")
//
//public class PageEntityController {
//
// @Autowired
// private PageEntityService pageEntityService;
//
// @PostMapping("/savePageEntity")
// public void savePageEntity(@RequestBody PageEntity pageEntity){
// pageEntityService.savePageEntity(pageEntity);
// }
//
// @PostMapping("/findByPages")
// public List<TableInfo> findByPages(List<Integer> pageIds){
//
// return pageEntityService.findByPageIds(pageIds);
// }
//}
package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowRole;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowRoleType;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser;
import com.tykj.workflowcore.workflow_editer.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class UserController
* @packageName com.tykj.workflowcore.workflow_editer.controller
**/
@RestController()
@RequestMapping("/workflow/user")
@Api("页面管理接口")
public class UserController {
@Autowired(required = false)
UserService userService;
@PostMapping("/getCurrentUser")
public ResponseEntity getCurrentUser(){
WorkFlowUser currentUser = userService.getCurrentUser();
return ResultUtil.success(currentUser,"查询成功");
}
@PostMapping("/getAllUser")
public ResponseEntity getAllUser(){
List<WorkFlowUser> allUser = userService.getAllUser();
return ResultUtil.success(allUser,"查询成功");
}
@PostMapping("/getAllRole")
public ResponseEntity getAllRole(String roleType){
List<WorkFlowRole> allRole = userService.getAllRole(roleType);
return ResultUtil.success(allRole,"查询成功");
}
@PostMapping("/getRoleType")
public ResponseEntity getRoleType(){
List<WorkFlowRoleType> roleType = userService.getRoleType();
return ResultUtil.success(roleType,"查询成功");
}
}
//package com.tykj.workflowcore.workflow_editer.service;
//
//import com.tykj.workflowcore.model_layer.model.TableInfo;
//import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
//
//import java.util.List;
//
///**
// * ClassName: PageEntityService
// * Package: com.tykj.service
// * Description:
// * Datetime: 2021/3/4 9:52
// *
// * @Author: zsp
// */
//public interface PageEntityService {
//
// /**
// * 保存
// * @param pageEntity 页面实体之间关系
// */
// void savePageEntity(PageEntity pageEntity);
//
// /**
// * 根据页面id查询tableInfo
// * @param pageIds 页面id
// * @return
// */
// List<TableInfo> findByPageIds(List<Integer> pageIds);
//
//
//}
package com.tykj.workflowcore.workflow_editer.service.impl;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowRole;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowRoleType;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser;
import com.tykj.workflowcore.workflow_editer.service.UserService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DefaultUserSerbiveImpl
* @packageName com.tykj.workflowcore.workflow_editer.service.impl
**/
@Service
@Order
public class DefaultUserServiceImpl implements UserService {
@Override
public WorkFlowUser getCurrentUser() {
WorkFlowUser workFlowUser = new WorkFlowUser();
workFlowUser.setId(1L);
workFlowUser.setUserName("张三");
return workFlowUser;
}
@Override
public List<WorkFlowUser> getAllUser() {
List<WorkFlowUser> workFlowUsers = new ArrayList<>();
for (int i = 0; i < 10; i++) {
WorkFlowUser workFlowUser = new WorkFlowUser();
workFlowUser.setUserName("张1");
workFlowUser.setId((long) i);
workFlowUsers.add(workFlowUser);
}
return workFlowUsers;
}
@Override
public List<WorkFlowRole> getAllRole(String roleType) {
List<WorkFlowRole> workFlowUsers = new ArrayList<>();
if (roleType.equals("department")){
workFlowUsers.add(new WorkFlowRole("开发部","department","1"));
workFlowUsers.add(new WorkFlowRole("运营部","department","2"));
workFlowUsers.add(new WorkFlowRole("测试部","department","3"));
}else {
workFlowUsers.add(new WorkFlowRole("管理员","role","1"));
workFlowUsers.add(new WorkFlowRole("普通用户","role","2"));
workFlowUsers.add(new WorkFlowRole("运维人员","role","3"));
}
return workFlowUsers;
}
@Override
public List<WorkFlowRoleType> getRoleType() {
List<WorkFlowRoleType> workFlowRoleTypes = new ArrayList<>();
workFlowRoleTypes.add(new WorkFlowRoleType("部门","department"));
workFlowRoleTypes.add(new WorkFlowRoleType("角色","role"));
return workFlowRoleTypes;
}
}
//package com.tykj.workflowcore.workflow_editer.service.impl;
//
//import com.github.wenhao.jpa.PredicateBuilder;
//import com.github.wenhao.jpa.Specifications;
//import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
//import com.tykj.workflowcore.model_layer.model.TableInfo;
//import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
//import com.tykj.workflowcore.workflow_editer.mapper.PageEntityMapper;
//import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * ClassName: PageEntityServiceImpl
// * Package: com.tykj.service.impl
// * Description:
// * Datetime: 2021/3/4 9:55
// *
// * @Author: zsp
// */
//@Service
//public class PageEntityServiceImpl implements PageEntityService {
//
// @Autowired
// private PageEntityMapper pageEntityMapper;
// @Autowired
// private TableInfoDao tableInfoDao;
// @Override
// public void savePageEntity(PageEntity pageEntity) {
// pageEntityMapper.save(pageEntity);
// }
//
// @Override
// public List<TableInfo> findByPageIds(List<Integer> pageIds) {
// ArrayList<TableInfo> list = new ArrayList<>();
// for (Integer pageId : pageIds) {
// String entityId = pageEntityMapper.findByPageId(pageId).getEntityId();
// //根据entityId查询出表
// PredicateBuilder<TableInfo> builder = Specifications.and();
// builder.eq("id",entityId);
// List<TableInfo> tableInfoList = tableInfoDao.findAll(builder.build());
// list.addAll(tableInfoList);
// }
// return list;
// }
//}
...@@ -3,12 +3,14 @@ package com.tykj.workflowcore.workflow_editer.service.impl; ...@@ -3,12 +3,14 @@ package com.tykj.workflowcore.workflow_editer.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.api.entity.InvokeRequest; import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter; import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.api.service.SpringBeanService;
import com.tykj.workflowcore.workflow_editer.entity.*; import com.tykj.workflowcore.workflow_editer.entity.*;
import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.service.NodeInfoService; import com.tykj.workflowcore.workflow_editer.service.NodeInfoService;
import com.tykj.workflowcore.workflow_editer.service.UserService; import com.tykj.workflowcore.workflow_editer.service.UserService;
import com.tykj.workflowcore.workflow_editer.service.VariableStorageService; import com.tykj.workflowcore.workflow_editer.service.VariableStorageService;
import com.tykj.workflowcore.workflow_editer.service.WorkFlowService; import com.tykj.workflowcore.workflow_editer.service.WorkFlowService;
import com.tykj.workflowcore.workflow_editer.util.UserServiceBeanUtil;
import com.tykj.workflowcore.workflow_editer.vo.*; import com.tykj.workflowcore.workflow_editer.vo.*;
import org.dom4j.Attribute; import org.dom4j.Attribute;
import org.dom4j.Document; import org.dom4j.Document;
...@@ -30,6 +32,7 @@ import org.flowable.task.api.TaskQuery; ...@@ -30,6 +32,7 @@ import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -51,30 +54,35 @@ import java.util.*; ...@@ -51,30 +54,35 @@ import java.util.*;
@Service @Service
public class WorkFlowServiceImpl implements WorkFlowService { public class WorkFlowServiceImpl implements WorkFlowService {
@Autowired private final RepositoryService repositoryService;
private RepositoryService repositoryService; private final RuntimeService runtimeService;
@Autowired private final TaskService taskService;
private RuntimeService runtimeService; private final FlowsInfoMapper flowsInfoMapper;
@Autowired
private TaskService taskService; private final UserService userService;
@Autowired private final HistoryService historyService;
private FlowsInfoMapper flowsInfoMapper; private final ProcessEngineConfigurationImpl processEngineConfiguration;
@Autowired private final ProcessEngine processEngine;
private UserService userService;
@Autowired private final VariableStorageService variableStorageService;
private HistoryService historyService;
@Autowired final
private NodeInfoService nodeInfoService;
@Autowired
ProcessEngineConfigurationImpl processEngineConfiguration;
@Autowired
private ProcessEngine processEngine;
@Autowired
private VariableStorageService variableStorageService;
@Autowired
ClassLoader classLoader; ClassLoader classLoader;
public WorkFlowServiceImpl(SpringBeanService springBeanService,HistoryService historyService, RepositoryService repositoryService, RuntimeService runtimeService, TaskService taskService, FlowsInfoMapper flowsInfoMapper, ProcessEngineConfigurationImpl processEngineConfiguration, ProcessEngine processEngine, VariableStorageService variableStorageService, ClassLoader classLoader) {
this.historyService = historyService;
this.repositoryService = repositoryService;
this.runtimeService = runtimeService;
this.taskService = taskService;
this.flowsInfoMapper = flowsInfoMapper;
this.userService = UserServiceBeanUtil.getUserService(springBeanService);
this.processEngineConfiguration = processEngineConfiguration;
this.processEngine = processEngine;
this.variableStorageService = variableStorageService;
this.classLoader = classLoader;
System.out.println(userService!=null?"成功":"失败");
}
@Override @Override
public String saveXml(@RequestParam("file") MultipartFile file) { public String saveXml(@RequestParam("file") MultipartFile file) {
......
package com.tykj.workflowcore.workflow_editer.util;
import com.tykj.workflowcore.api.service.SpringBeanService;
import com.tykj.workflowcore.workflow_editer.service.UserService;
import java.util.Map;
import java.util.Set;
/**
* @author HuangXiahao
* @version V1.0
* @class UserServiceBeanUtil
* @packageName com.tykj.workflowcore.workflow_editer.util
**/
public class UserServiceBeanUtil {
public static UserService getUserService(SpringBeanService springBeanService) {
Map<String, UserService> beansOfType = springBeanService.getApplicationContext().getBeansOfType(UserService.class);
Set<String> strings = beansOfType.keySet();
if (strings.size()>1){
for (String key : strings) {
if (!key.equals("defaultUserServiceImpl")){
return beansOfType.get(key);
}
}
}
return beansOfType.get("defaultUserServiceImpl");
}
}
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
username: root username: root
password: 123456 password: Huang123+
url: jdbc:mysql://localhost:3306/model_layer?serverTimezone=UTC&characterEncoding=UTF-8&useUnicode=true url: jdbc:mysql://47.106.142.73:3306/www?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8&nullCatalogMeansCurrent=true
driver-class-name: com.mysql.cj.jdbc.Driver
jpa: jpa:
show-sql: true
hibernate: hibernate:
ddl-auto: update ddl-auto: update
naming:
implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
show-sql: true
server: server:
port: 8900 port: 8900
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论