update - 移除部分无用的类和代码, 并将表单 service 拆分为表单定义和表单实例两个服务
This commit is contained in:
parent
32d7f8206c
commit
cdba73c836
@ -1,4 +0,0 @@
|
||||
package cn.axzo.workflow.core.common.enums;
|
||||
|
||||
public class BpmErrorCodeConstants {
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package cn.axzo.workflow.core.service;
|
||||
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormContentUpdateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelSearchDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelUpdateDTO;
|
||||
@ -11,12 +10,12 @@ import org.flowable.form.api.FormInfo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 表单定义相关服务接口
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/19 16:46
|
||||
*/
|
||||
public interface BpmFormService {
|
||||
public interface BpmFormDefinitionService {
|
||||
String createFormModel(FormModelCreateDTO dto);
|
||||
|
||||
String updateFormModel(FormModelUpdateDTO dto);
|
||||
@ -25,10 +24,5 @@ public interface BpmFormService {
|
||||
|
||||
List<FormInfo> get(String deploymentId, String tenantId);
|
||||
|
||||
/**
|
||||
* 更新表单填写的数据
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
void updateFormContent(FormContentUpdateDTO dto);
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.axzo.workflow.core.service;
|
||||
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormContentUpdateDTO;
|
||||
|
||||
/**
|
||||
* 表单实例相关接口
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/21 15:19
|
||||
*/
|
||||
public interface BpmFormInstanceService {
|
||||
|
||||
/**
|
||||
* 更新表单填写的数据
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
void updateFormContent(FormContentUpdateDTO dto);
|
||||
}
|
||||
@ -1,8 +1,7 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.service.BpmFormService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormContentUpdateDTO;
|
||||
import cn.axzo.workflow.core.service.BpmFormDefinitionService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelSearchDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelUpdateDTO;
|
||||
@ -14,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.form.api.*;
|
||||
import org.flowable.form.engine.impl.persistence.entity.FormDeploymentEntityImpl;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -27,7 +25,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 表单定义 Service 实现
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/19 16:47
|
||||
@ -35,7 +33,7 @@ import java.util.Objects;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BpmFormServiceImpl implements BpmFormService {
|
||||
public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
|
||||
|
||||
@Autowired
|
||||
private FormRepositoryService formRepositoryService;
|
||||
@ -125,26 +123,4 @@ public class BpmFormServiceImpl implements BpmFormService {
|
||||
return formInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFormContent(FormContentUpdateDTO dto) {
|
||||
Task task = taskService.createTaskQuery().taskId(dto.getTaskId()).singleResult();
|
||||
if (Objects.isNull(task)) {
|
||||
throw new WorkflowEngineException("未找到指定任务");
|
||||
}
|
||||
|
||||
if (Objects.equals(dto.getUserId(), task.getAssignee())) {
|
||||
throw new WorkflowEngineException("当前任务不归属于你");
|
||||
}
|
||||
|
||||
FormInfo formInfo = formRepositoryService.getFormModelById(dto.getFormDefinitionId());
|
||||
if (Objects.nonNull(task.getProcessInstanceId())) {
|
||||
formService.saveFormInstanceByFormDefinitionId(dto.getFormVariables(), dto.getFormDefinitionId(),
|
||||
dto.getTaskId(),
|
||||
task.getProcessInstanceId(),
|
||||
task.getProcessDefinitionId(), task.getTenantId(), null);
|
||||
} else {
|
||||
formService.saveFormInstanceWithScopeId(dto.getFormVariables(), dto.getFormDefinitionId(), dto.getTaskId(),
|
||||
task.getScopeId(), task.getScopeType(), task.getScopeDefinitionId(), task.getTenantId(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.service.BpmFormInstanceService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormContentUpdateDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.form.api.FormInfo;
|
||||
import org.flowable.form.api.FormRepositoryService;
|
||||
import org.flowable.form.api.FormService;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 表单实例 Service 实现
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/21 15:27
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BpmFormInstanceServiceImpl implements BpmFormInstanceService {
|
||||
|
||||
@Autowired
|
||||
private FormRepositoryService formRepositoryService;
|
||||
@Autowired
|
||||
private FormService formService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Override
|
||||
public void updateFormContent(FormContentUpdateDTO dto) {
|
||||
Task task = taskService.createTaskQuery().taskId(dto.getTaskId()).singleResult();
|
||||
if (Objects.isNull(task)) {
|
||||
throw new WorkflowEngineException("未找到指定任务");
|
||||
}
|
||||
|
||||
if (Objects.equals(dto.getUserId(), task.getAssignee())) {
|
||||
throw new WorkflowEngineException("当前任务不归属于你");
|
||||
}
|
||||
|
||||
FormInfo formInfo = formRepositoryService.getFormModelById(dto.getFormDefinitionId());
|
||||
if (Objects.nonNull(task.getProcessInstanceId())) {
|
||||
formService.saveFormInstanceByFormDefinitionId(dto.getFormVariables(), dto.getFormDefinitionId(),
|
||||
dto.getTaskId(),
|
||||
task.getProcessInstanceId(),
|
||||
task.getProcessDefinitionId(), task.getTenantId(), null);
|
||||
} else {
|
||||
formService.saveFormInstanceWithScopeId(dto.getFormVariables(), dto.getFormDefinitionId(), dto.getTaskId(),
|
||||
task.getScopeId(), task.getScopeType(), task.getScopeDefinitionId(), task.getTenantId(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
{
|
||||
"key": "form1",
|
||||
"name": "My first form",
|
||||
"fields":[
|
||||
{
|
||||
"fieldType":"FormField",
|
||||
"id":"user",
|
||||
"name":"User",
|
||||
"type":"text",
|
||||
"value":null,
|
||||
"required":false,
|
||||
"readOnly":false,
|
||||
"overrideId":false,
|
||||
"placeholder":null,
|
||||
"layout":null
|
||||
},
|
||||
{
|
||||
"fieldType":"FormField",
|
||||
"id":"number",
|
||||
"name":"Number",
|
||||
"type":"integer",
|
||||
"value":null,
|
||||
"required":false,
|
||||
"readOnly":false,
|
||||
"overrideId":false,
|
||||
"placeholder":null,
|
||||
"layout":null
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package cn.axzo.workflow.server.controller.web;
|
||||
|
||||
import cn.axzo.workflow.core.service.BpmFormService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormContentUpdateDTO;
|
||||
import cn.axzo.workflow.core.service.BpmFormDefinitionService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelSearchDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormModelUpdateDTO;
|
||||
@ -17,45 +16,38 @@ import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 表单定义相关 Controller
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/19 16:45
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/web/v1/api/form")
|
||||
@RequestMapping("/web/v1/api/form/definition")
|
||||
@RestController
|
||||
public class BpmFormController {
|
||||
public class BpmFormDefinitionController {
|
||||
|
||||
@Autowired
|
||||
private BpmFormService bpmFormService;
|
||||
private BpmFormDefinitionService bpmFormDefinitionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
public CommonResponse<String> createFormModel(@Valid @RequestBody FormModelCreateDTO dto) {
|
||||
return CommonResponse.success(bpmFormService.createFormModel(dto));
|
||||
return CommonResponse.success(bpmFormDefinitionService.createFormModel(dto));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
public CommonResponse<String> updateFormModel(@Valid @RequestBody FormModelUpdateDTO dto) {
|
||||
return CommonResponse.success(bpmFormService.updateFormModel(dto));
|
||||
return CommonResponse.success(bpmFormDefinitionService.updateFormModel(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public CommonResponse<BpmPageResult<FormDeployment>> list(@Valid @RequestBody FormModelSearchDTO dto) {
|
||||
return CommonResponse.success(bpmFormService.listFormModel(dto));
|
||||
return CommonResponse.success(bpmFormDefinitionService.listFormModel(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/deployment/get")
|
||||
public CommonResponse<List<FormInfo>> get(@RequestParam String deploymentId,
|
||||
@RequestParam(required = false) String tenantId) {
|
||||
return CommonResponse.success(bpmFormService.get(deploymentId, tenantId));
|
||||
return CommonResponse.success(bpmFormDefinitionService.get(deploymentId, tenantId));
|
||||
}
|
||||
|
||||
@PostMapping("/content/update")
|
||||
public CommonResponse<Void> updateFormContent(@Valid @RequestBody FormContentUpdateDTO dto) {
|
||||
bpmFormService.updateFormContent(dto);
|
||||
return CommonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package cn.axzo.workflow.server.controller.web;
|
||||
|
||||
import cn.axzo.workflow.core.service.BpmFormInstanceService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.FormContentUpdateDTO;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 表单实例相关 Controller
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/21 15:23
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/web/v1/api/form/instance")
|
||||
@RestController
|
||||
public class BpmFormInstanceController {
|
||||
|
||||
@Autowired
|
||||
private BpmFormInstanceService bpmFormInstanceService;
|
||||
|
||||
@PostMapping("/content/update")
|
||||
public CommonResponse<Void> updateFormContent(@Valid @RequestBody FormContentUpdateDTO dto) {
|
||||
bpmFormInstanceService.updateFormContent(dto);
|
||||
return CommonResponse.success();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user