feat: 归档L03与L09审批发布能力
- 新增统一审批中心与审批管理页面,支持流程配置、审批详情与角色/用户审批对象 - 接入聊天助手、知识库、工作流的发布与删除审批,并补齐发布态校验与快照展示
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
<artifactId>easyflow-api-admin</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>tech.easyflow</groupId>
|
||||
<artifactId>easyflow-module-approval</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tech.easyflow</groupId>
|
||||
<artifactId>easyflow-module-ai</artifactId>
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
import tech.easyflow.ai.easyagents.listener.PromptChoreChatStreamListener;
|
||||
import tech.easyflow.ai.entity.*;
|
||||
import tech.easyflow.ai.publish.BotPublishAppService;
|
||||
import tech.easyflow.ai.service.*;
|
||||
import tech.easyflow.ai.service.impl.BotServiceImpl;
|
||||
import tech.easyflow.common.audio.core.AudioServiceManager;
|
||||
@@ -67,6 +68,8 @@ public class BotController extends BaseCurdController<BotService, Bot> {
|
||||
private AudioServiceManager audioServiceManager;
|
||||
@Resource
|
||||
private CategoryPermissionService categoryPermissionService;
|
||||
@Resource
|
||||
private BotPublishAppService botPublishAppService;
|
||||
|
||||
public BotController(BotService service, ModelService modelService, BotWorkflowService botWorkflowService,
|
||||
BotDocumentCollectionService botDocumentCollectionService, BotMessageService botMessageService) {
|
||||
@@ -184,17 +187,23 @@ public class BotController extends BaseCurdController<BotService, Bot> {
|
||||
@GetMapping("getDetail")
|
||||
@SaIgnore
|
||||
public Result<Bot> getDetail(String id) {
|
||||
Bot bot = botService.getDetail(id);
|
||||
Bot bot = StpUtil.isLogin() ? botService.getDetail(id) : botService.getPublishedDetail(id);
|
||||
if (bot != null && StpUtil.isLogin()) {
|
||||
categoryPermissionService.assertCategoryResourceVisible("BOT", bot.getCreatedBy(), bot.getCategoryId(), "无权限访问聊天助手");
|
||||
}
|
||||
if (bot == null) {
|
||||
return Result.ok(null);
|
||||
}
|
||||
if (!StpUtil.isLogin() && !tech.easyflow.ai.enums.PublishStatus.from(bot.getPublishStatus()).isExternallyVisible()) {
|
||||
throw new BusinessException("聊天助手尚未发布");
|
||||
}
|
||||
return Result.ok(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SaIgnore
|
||||
public Result<Bot> detail(String id) {
|
||||
Bot data = botService.getDetail(id);
|
||||
Bot data = StpUtil.isLogin() ? botService.getDetail(id) : botService.getPublishedDetail(id);
|
||||
if (data == null) {
|
||||
return Result.ok(data);
|
||||
}
|
||||
@@ -202,6 +211,10 @@ public class BotController extends BaseCurdController<BotService, Bot> {
|
||||
categoryPermissionService.assertCategoryResourceVisible("BOT", data.getCreatedBy(), data.getCategoryId(), "无权限访问聊天助手");
|
||||
}
|
||||
|
||||
if (!StpUtil.isLogin() && !tech.easyflow.ai.enums.PublishStatus.from(data.getPublishStatus()).isExternallyVisible()) {
|
||||
throw new BusinessException("聊天助手尚未发布");
|
||||
}
|
||||
|
||||
Map<String, Object> llmOptions = data.getModelOptions();
|
||||
if (llmOptions == null) {
|
||||
llmOptions = new HashMap<>();
|
||||
@@ -232,6 +245,18 @@ public class BotController extends BaseCurdController<BotService, Bot> {
|
||||
return Result.ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/submitPublishApproval")
|
||||
@SaCheckPermission("/api/v1/bot/save")
|
||||
public Result<BigInteger> submitPublishApproval(@JsonBody("id") BigInteger id) {
|
||||
return Result.ok(botPublishAppService.submitPublishApproval(id));
|
||||
}
|
||||
|
||||
@PostMapping("/submitDeleteApproval")
|
||||
@SaCheckPermission("/api/v1/bot/remove")
|
||||
public Result<BigInteger> submitDeleteApproval(@JsonBody("id") BigInteger id) {
|
||||
return Result.ok(botPublishAppService.submitDeleteApproval(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Bot>> list(Bot entity, Boolean asTree, String sortKey, String sortType) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create(entity, buildOperators(entity));
|
||||
@@ -360,6 +385,12 @@ public class BotController extends BaseCurdController<BotService, Bot> {
|
||||
return super.onRemoveBefore(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("remove")
|
||||
public Result<?> remove(@JsonBody(value = "id", required = true) Serializable id) {
|
||||
return Result.fail(1, "请提交删除审批");
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统提示词优化
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import tech.easyflow.ai.dto.BotKnowledgeBindingRequest;
|
||||
import tech.easyflow.ai.entity.BotDocumentCollection;
|
||||
import tech.easyflow.ai.entity.DocumentCollection;
|
||||
import tech.easyflow.ai.enums.PublishStatus;
|
||||
import tech.easyflow.ai.permission.KnowledgeReadAccessSnapshot;
|
||||
import tech.easyflow.ai.permission.KnowledgeVisibilityQueryHelper;
|
||||
import tech.easyflow.ai.service.BotDocumentCollectionService;
|
||||
@@ -76,6 +77,9 @@ public class BotDocumentCollectionController extends BaseCurdController<BotDocum
|
||||
continue;
|
||||
}
|
||||
resourceAccessService.assertAccess(CategoryResourceType.KNOWLEDGE, collection, ResourceAction.READ, "无权限绑定知识库");
|
||||
if (PublishStatus.from(collection.getPublishStatus()) != PublishStatus.PUBLISHED) {
|
||||
throw new tech.easyflow.common.web.exceptions.BusinessException("仅已发布知识库可被聊天助手引用");
|
||||
}
|
||||
}
|
||||
}
|
||||
service.saveBotAndKnowledge(botId, knowledgeBindings);
|
||||
|
||||
@@ -3,6 +3,7 @@ package tech.easyflow.admin.controller.ai;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import tech.easyflow.ai.entity.BotWorkflow;
|
||||
import tech.easyflow.ai.entity.Workflow;
|
||||
import tech.easyflow.ai.enums.PublishStatus;
|
||||
import tech.easyflow.ai.permission.WorkflowReadAccessSnapshot;
|
||||
import tech.easyflow.ai.permission.WorkflowVisibilityQueryHelper;
|
||||
import tech.easyflow.ai.service.BotWorkflowService;
|
||||
@@ -77,6 +78,9 @@ public class BotWorkflowController extends BaseCurdController<BotWorkflowService
|
||||
continue;
|
||||
}
|
||||
resourceAccessService.assertAccess(CategoryResourceType.WORKFLOW, workflow, ResourceAction.READ, "无权限绑定工作流");
|
||||
if (PublishStatus.from(workflow.getPublishStatus()) != PublishStatus.PUBLISHED) {
|
||||
throw new tech.easyflow.common.web.exceptions.BusinessException("仅已发布工作流可被聊天助手引用");
|
||||
}
|
||||
}
|
||||
}
|
||||
service.saveBotAndWorkflowTool(botId, workflowIds);
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.easyagents.rag.retrieval.RagRetrievalMetadataKeys;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -17,6 +19,8 @@ import tech.easyflow.ai.dto.KnowledgeSearchResultItem;
|
||||
import tech.easyflow.ai.entity.BotDocumentCollection;
|
||||
import tech.easyflow.ai.entity.DocumentCollection;
|
||||
import tech.easyflow.ai.entity.Model;
|
||||
import tech.easyflow.ai.enums.PublishStatus;
|
||||
import tech.easyflow.ai.publish.KnowledgePublishAppService;
|
||||
import tech.easyflow.ai.rag.KnowledgeRetrievalRequest;
|
||||
import tech.easyflow.ai.rag.KnowledgeRetrievalModes;
|
||||
import tech.easyflow.ai.service.BotDocumentCollectionService;
|
||||
@@ -65,6 +69,8 @@ public class DocumentCollectionController extends BaseCurdController<DocumentCol
|
||||
private ResourceAccessService resourceAccessService;
|
||||
@Resource
|
||||
private KnowledgeVisibilityQueryHelper knowledgeVisibilityQueryHelper;
|
||||
@Resource
|
||||
private KnowledgePublishAppService knowledgePublishAppService;
|
||||
|
||||
public DocumentCollectionController(DocumentCollectionService service, DocumentChunkService chunkService, ModelService llmService) {
|
||||
super(service);
|
||||
@@ -180,6 +186,30 @@ public class DocumentCollectionController extends BaseCurdController<DocumentCol
|
||||
return Result.ok(llmService.listSelectableModels(entity, asTree, sortKey, sortType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交发布审批。
|
||||
*
|
||||
* @param id 知识库 ID
|
||||
* @return 审批实例 ID
|
||||
*/
|
||||
@PostMapping("/submitPublishApproval")
|
||||
@SaCheckPermission("/api/v1/documentCollection/save")
|
||||
public Result<BigInteger> submitPublishApproval(@JsonBody("id") BigInteger id) {
|
||||
return Result.ok(knowledgePublishAppService.submitPublishApproval(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交删除审批。
|
||||
*
|
||||
* @param id 知识库 ID
|
||||
* @return 审批实例 ID
|
||||
*/
|
||||
@PostMapping("/submitDeleteApproval")
|
||||
@SaCheckPermission("/api/v1/documentCollection/remove")
|
||||
public Result<BigInteger> submitDeleteApproval(@JsonBody("id") BigInteger id) {
|
||||
return Result.ok(knowledgePublishAppService.submitDeleteApproval(id));
|
||||
}
|
||||
|
||||
@PostMapping("splitterProfile/save")
|
||||
@SaCheckPermission("/api/v1/documentCollection/save")
|
||||
@RequireResourceAccess(
|
||||
@@ -218,6 +248,7 @@ public class DocumentCollectionController extends BaseCurdController<DocumentCol
|
||||
public Result<List<DocumentCollection>> list(DocumentCollection entity, Boolean asTree, String sortKey, String sortType) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create(entity, buildOperators(entity));
|
||||
knowledgeVisibilityQueryHelper.applyReadableAccess(queryWrapper);
|
||||
applyPublishedOnlyFilter(queryWrapper);
|
||||
queryWrapper.orderBy(buildOrderBy(sortKey, sortType, getDefaultOrderBy()));
|
||||
return Result.ok(service.list(queryWrapper));
|
||||
}
|
||||
@@ -225,9 +256,16 @@ public class DocumentCollectionController extends BaseCurdController<DocumentCol
|
||||
@Override
|
||||
protected Page<DocumentCollection> queryPage(Page<DocumentCollection> page, QueryWrapper queryWrapper) {
|
||||
knowledgeVisibilityQueryHelper.applyReadableAccess(queryWrapper);
|
||||
applyPublishedOnlyFilter(queryWrapper);
|
||||
return super.queryPage(page, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("remove")
|
||||
public Result<?> remove(@JsonBody(value = "id", required = true) Serializable id) {
|
||||
return Result.fail(1, "请提交删除审批");
|
||||
}
|
||||
|
||||
private void normalizeVisibilityScope(DocumentCollection entity, boolean isSave) {
|
||||
if (entity == null) {
|
||||
return;
|
||||
@@ -275,6 +313,17 @@ public class DocumentCollectionController extends BaseCurdController<DocumentCol
|
||||
return "kb_" + UUID.randomUUID().toString().replace("-", "").substring(0, 28);
|
||||
}
|
||||
|
||||
private void applyPublishedOnlyFilter(QueryWrapper queryWrapper) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (attributes == null) {
|
||||
return;
|
||||
}
|
||||
String publishedOnly = attributes.getRequest().getParameter("publishedOnly");
|
||||
if ("true".equalsIgnoreCase(publishedOnly)) {
|
||||
queryWrapper.eq("publish_status", PublishStatus.PUBLISHED.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
private List<KnowledgeSearchResultItem> toKnowledgeSearchResult(List<Document> documents) {
|
||||
List<KnowledgeSearchResultItem> results = new ArrayList<>();
|
||||
if (documents == null) {
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.easyagents.flow.core.chain.runtime.ChainExecutor;
|
||||
import com.easyagents.flow.core.parser.ChainParser;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import tech.easyflow.ai.permission.WorkflowVisibilityQueryHelper;
|
||||
@@ -23,6 +25,8 @@ import tech.easyflow.ai.easyagentsflow.service.TinyFlowService;
|
||||
import tech.easyflow.ai.easyagentsflow.service.WorkflowCheckService;
|
||||
import tech.easyflow.ai.easyagentsflow.service.WorkflowDatacenterContentService;
|
||||
import tech.easyflow.ai.entity.Workflow;
|
||||
import tech.easyflow.ai.enums.PublishStatus;
|
||||
import tech.easyflow.ai.publish.WorkflowPublishAppService;
|
||||
import tech.easyflow.ai.service.BotWorkflowService;
|
||||
import tech.easyflow.ai.service.ModelService;
|
||||
import tech.easyflow.ai.service.WorkflowService;
|
||||
@@ -82,6 +86,8 @@ public class WorkflowController extends BaseCurdController<WorkflowService, Work
|
||||
private ResourceAccessService resourceAccessService;
|
||||
@Resource
|
||||
private WorkflowVisibilityQueryHelper workflowVisibilityQueryHelper;
|
||||
@Resource
|
||||
private WorkflowPublishAppService workflowPublishAppService;
|
||||
|
||||
public WorkflowController(WorkflowService service, ModelService modelService) {
|
||||
super(service);
|
||||
@@ -239,6 +245,30 @@ public class WorkflowController extends BaseCurdController<WorkflowService, Work
|
||||
return Result.ok(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交发布审批。
|
||||
*
|
||||
* @param id 工作流 ID
|
||||
* @return 审批实例 ID
|
||||
*/
|
||||
@PostMapping("/submitPublishApproval")
|
||||
@SaCheckPermission("/api/v1/workflow/save")
|
||||
public Result<BigInteger> submitPublishApproval(@JsonBody("id") BigInteger id) {
|
||||
return Result.ok(workflowPublishAppService.submitPublishApproval(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交删除审批。
|
||||
*
|
||||
* @param id 工作流 ID
|
||||
* @return 审批实例 ID
|
||||
*/
|
||||
@PostMapping("/submitDeleteApproval")
|
||||
@SaCheckPermission("/api/v1/workflow/remove")
|
||||
public Result<BigInteger> submitDeleteApproval(@JsonBody("id") BigInteger id) {
|
||||
return Result.ok(workflowPublishAppService.submitDeleteApproval(id));
|
||||
}
|
||||
|
||||
@GetMapping("/supportedCodeEngines")
|
||||
@SaCheckPermission("/api/v1/workflow/query")
|
||||
public Result<?> supportedCodeEngines() {
|
||||
@@ -336,6 +366,7 @@ public class WorkflowController extends BaseCurdController<WorkflowService, Work
|
||||
public Result<List<Workflow>> list(Workflow entity, Boolean asTree, String sortKey, String sortType) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create(entity, buildOperators(entity));
|
||||
workflowVisibilityQueryHelper.applyReadableAccess(queryWrapper);
|
||||
applyPublishedOnlyFilter(queryWrapper);
|
||||
queryWrapper.orderBy(buildOrderBy(sortKey, sortType, getDefaultOrderBy()));
|
||||
return Result.ok(service.list(queryWrapper));
|
||||
}
|
||||
@@ -343,9 +374,16 @@ public class WorkflowController extends BaseCurdController<WorkflowService, Work
|
||||
@Override
|
||||
protected Page<Workflow> queryPage(Page<Workflow> page, QueryWrapper queryWrapper) {
|
||||
workflowVisibilityQueryHelper.applyReadableAccess(queryWrapper);
|
||||
applyPublishedOnlyFilter(queryWrapper);
|
||||
return super.queryPage(page, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("remove")
|
||||
public Result<?> remove(@JsonBody(value = "id", required = true) Serializable id) {
|
||||
return Result.fail(1, "请提交删除审批");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result onRemoveBefore(Collection<Serializable> ids) {
|
||||
for (Serializable id : ids) {
|
||||
@@ -381,4 +419,15 @@ public class WorkflowController extends BaseCurdController<WorkflowService, Work
|
||||
}
|
||||
return workflow;
|
||||
}
|
||||
|
||||
private void applyPublishedOnlyFilter(QueryWrapper queryWrapper) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (attributes == null) {
|
||||
return;
|
||||
}
|
||||
String publishedOnly = attributes.getRequest().getParameter("publishedOnly");
|
||||
if ("true".equalsIgnoreCase(publishedOnly)) {
|
||||
queryWrapper.eq("publish_status", PublishStatus.PUBLISHED.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
package tech.easyflow.admin.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import tech.easyflow.common.domain.Result;
|
||||
import tech.easyflow.common.satoken.util.SaTokenUtil;
|
||||
import tech.easyflow.common.web.exceptions.BusinessException;
|
||||
import tech.easyflow.common.web.jsonbody.JsonBody;
|
||||
import tech.easyflow.approval.entity.vo.ApprovalAssigneeOptionVo;
|
||||
import tech.easyflow.approval.entity.vo.ApprovalFlowDetailVo;
|
||||
import tech.easyflow.approval.entity.vo.ApprovalFlowPageVo;
|
||||
import tech.easyflow.approval.service.ApprovalAssigneeService;
|
||||
import tech.easyflow.approval.service.ApprovalFlowService;
|
||||
import tech.easyflow.system.service.CategoryPermissionService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 审批流程管理控制器。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/approvalFlow")
|
||||
public class ApprovalFlowController {
|
||||
|
||||
@Resource
|
||||
private ApprovalFlowService approvalFlowService;
|
||||
|
||||
@Resource
|
||||
private CategoryPermissionService categoryPermissionService;
|
||||
|
||||
@Resource
|
||||
private ApprovalAssigneeService approvalAssigneeService;
|
||||
|
||||
/**
|
||||
* 分页查询审批流程。
|
||||
*
|
||||
* @param name 流程名称
|
||||
* @param resourceType 资源类型
|
||||
* @param actionType 动作类型
|
||||
* @param status 流程状态
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 分页结果
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/query")
|
||||
public Result<Page<ApprovalFlowPageVo>> page(String name, String resourceType, String actionType, String status,
|
||||
Long pageNumber, Long pageSize) {
|
||||
return Result.ok(approvalFlowService.pageFlows(name, resourceType, actionType, status, pageNumber, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审批流程详情。
|
||||
*
|
||||
* @param id 流程ID
|
||||
* @return 流程详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/query")
|
||||
public Result<ApprovalFlowDetailVo> detail(BigInteger id) {
|
||||
return Result.ok(approvalFlowService.getFlowDetail(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审批角色选项。
|
||||
*
|
||||
* @return 角色选项
|
||||
*/
|
||||
@GetMapping("/assigneeRoleOptions")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/query")
|
||||
public Result<List<ApprovalAssigneeOptionVo>> assigneeRoleOptions() {
|
||||
return Result.ok(approvalAssigneeService.listRoleOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询审批用户选项。
|
||||
*
|
||||
* @param keyword 关键词
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 用户选项分页
|
||||
*/
|
||||
@GetMapping("/assigneeAccountPage")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/query")
|
||||
public Result<Page<ApprovalAssigneeOptionVo>> assigneeAccountPage(String keyword, Long pageNumber, Long pageSize) {
|
||||
return Result.ok(approvalAssigneeService.pageAccountOptions(keyword, pageNumber, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增审批流程。
|
||||
*
|
||||
* @param request 流程请求体
|
||||
* @return 新增流程ID
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/save")
|
||||
public Result<BigInteger> save(@JsonBody ApprovalFlowDetailVo request) {
|
||||
assertSuperAdmin();
|
||||
BigInteger operatorId = SaTokenUtil.getLoginAccount().getId();
|
||||
return Result.ok(approvalFlowService.saveFlow(request, operatorId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新审批流程。
|
||||
*
|
||||
* @param request 流程请求体
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/save")
|
||||
public Result<Void> update(@JsonBody ApprovalFlowDetailVo request) {
|
||||
assertSuperAdmin();
|
||||
BigInteger operatorId = SaTokenUtil.getLoginAccount().getId();
|
||||
approvalFlowService.updateFlow(request, operatorId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用审批流程。
|
||||
*
|
||||
* @param id 流程ID
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/enable")
|
||||
public Result<Void> enable(@JsonBody(value = "id", required = true) BigInteger id) {
|
||||
assertSuperAdmin();
|
||||
approvalFlowService.enableFlow(id, SaTokenUtil.getLoginAccount().getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用审批流程。
|
||||
*
|
||||
* @param id 流程ID
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/disable")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/disable")
|
||||
public Result<Void> disable(@JsonBody(value = "id", required = true) BigInteger id) {
|
||||
assertSuperAdmin();
|
||||
approvalFlowService.disableFlow(id, SaTokenUtil.getLoginAccount().getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除审批流程。
|
||||
*
|
||||
* @param id 流程ID
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@SaCheckPermission("/api/v1/approvalFlow/remove")
|
||||
public Result<Void> remove(@JsonBody(value = "id", required = true) BigInteger id) {
|
||||
assertSuperAdmin();
|
||||
approvalFlowService.removeFlow(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
private void assertSuperAdmin() {
|
||||
if (!categoryPermissionService.isCurrentSuperAdmin()) {
|
||||
throw new BusinessException("仅超级管理员可管理审批流程");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package tech.easyflow.admin.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import tech.easyflow.common.domain.Result;
|
||||
import tech.easyflow.common.satoken.util.SaTokenUtil;
|
||||
import tech.easyflow.common.web.jsonbody.JsonBody;
|
||||
import tech.easyflow.approval.entity.vo.ApprovalActionRequest;
|
||||
import tech.easyflow.approval.entity.vo.ApprovalInstanceDetailVo;
|
||||
import tech.easyflow.approval.entity.vo.ApprovalInstancePageVo;
|
||||
import tech.easyflow.approval.service.ApprovalInstanceService;
|
||||
import tech.easyflow.approval.service.ApprovalQueryService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 审批实例控制器。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/approvalInstance")
|
||||
public class ApprovalInstanceController {
|
||||
|
||||
@Resource
|
||||
private ApprovalQueryService approvalQueryService;
|
||||
|
||||
@Resource
|
||||
private ApprovalInstanceService approvalInstanceService;
|
||||
|
||||
/**
|
||||
* 分页查询待审批列表。
|
||||
*
|
||||
* @param resourceType 资源类型
|
||||
* @param actionType 动作类型
|
||||
* @param keyword 关键词
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 分页结果
|
||||
*/
|
||||
@GetMapping("/pendingPage")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/query")
|
||||
public Result<Page<ApprovalInstancePageVo>> pendingPage(String resourceType, String actionType, String keyword,
|
||||
Long pageNumber, Long pageSize) {
|
||||
return Result.ok(approvalQueryService.pendingPage(resourceType, actionType, keyword, pageNumber, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询已审批列表。
|
||||
*
|
||||
* @param resourceType 资源类型
|
||||
* @param actionType 动作类型
|
||||
* @param keyword 关键词
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 分页结果
|
||||
*/
|
||||
@GetMapping("/processedPage")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/query")
|
||||
public Result<Page<ApprovalInstancePageVo>> processedPage(String resourceType, String actionType, String keyword,
|
||||
Long pageNumber, Long pageSize) {
|
||||
return Result.ok(approvalQueryService.processedPage(resourceType, actionType, keyword, pageNumber, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询我发起的审批列表。
|
||||
*
|
||||
* @param resourceType 资源类型
|
||||
* @param actionType 动作类型
|
||||
* @param keyword 关键词
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 分页结果
|
||||
*/
|
||||
@GetMapping("/initiatedPage")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/query")
|
||||
public Result<Page<ApprovalInstancePageVo>> initiatedPage(String resourceType, String actionType, String keyword,
|
||||
Long pageNumber, Long pageSize) {
|
||||
return Result.ok(approvalQueryService.initiatedPage(resourceType, actionType, keyword, pageNumber, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审批实例详情。
|
||||
*
|
||||
* @param id 审批实例ID
|
||||
* @return 详情结果
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/query")
|
||||
public Result<ApprovalInstanceDetailVo> detail(BigInteger id) {
|
||||
return Result.ok(approvalQueryService.detail(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过审批。
|
||||
*
|
||||
* @param request 审批动作请求
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/approve")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/approve")
|
||||
public Result<Void> approve(@JsonBody ApprovalActionRequest request) {
|
||||
approvalInstanceService.approve(request.getInstanceId(), request.getComment(), currentOperatorId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回审批。
|
||||
*
|
||||
* @param request 审批动作请求
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/reject")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/reject")
|
||||
public Result<Void> reject(@JsonBody ApprovalActionRequest request) {
|
||||
approvalInstanceService.reject(request.getInstanceId(), request.getComment(), currentOperatorId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回审批。
|
||||
*
|
||||
* @param request 审批动作请求
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/revoke")
|
||||
@SaCheckPermission("/api/v1/approvalInstance/revoke")
|
||||
public Result<Void> revoke(@JsonBody ApprovalActionRequest request) {
|
||||
approvalInstanceService.revoke(request.getInstanceId(), request.getComment(), currentOperatorId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
private BigInteger currentOperatorId() {
|
||||
return SaTokenUtil.getLoginAccount().getId();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user