feat: 重构标准 Skill 管理与发布链路
- 统一标准 ZIP 导入导出与通用资源模型 - 收口分类范围权限和创建人查询 - 完善发布快照、审批幂等与数据库清理迁移
This commit is contained in:
@@ -47,6 +47,32 @@ public interface AiResourceLifecycleHandler {
|
||||
*/
|
||||
void applyApprovedAction(String actionType, BigInteger resourceId, Map<String, Object> resourceSnapshot, BigInteger operatorId);
|
||||
|
||||
/**
|
||||
* 执行带审批实例身份的通过回调。
|
||||
*
|
||||
* @param actionType 动作类型
|
||||
* @param resourceId 资源 ID
|
||||
* @param resourceSnapshot 审批冻结快照
|
||||
* @param operatorId 操作人 ID
|
||||
* @param approvalInstanceId 审批实例 ID
|
||||
*/
|
||||
default void applyApprovedAction(String actionType,
|
||||
BigInteger resourceId,
|
||||
Map<String, Object> resourceSnapshot,
|
||||
BigInteger operatorId,
|
||||
BigInteger approvalInstanceId) {
|
||||
applyApprovedAction(actionType, resourceId, resourceSnapshot, operatorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在实际提交或直接执行前持有冻结快照所需资源。
|
||||
*
|
||||
* @param actionType 动作类型
|
||||
* @param resourceSnapshot 冻结快照
|
||||
*/
|
||||
default void retainSubmittedSnapshot(String actionType, Map<String, Object> resourceSnapshot) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 按提交前真实状态恢复资源状态。
|
||||
*
|
||||
@@ -54,4 +80,17 @@ public interface AiResourceLifecycleHandler {
|
||||
* @param previousStatus 提交前状态
|
||||
*/
|
||||
void restoreState(BigInteger resourceId, PublishStatus previousStatus);
|
||||
|
||||
/**
|
||||
* 按审批实例身份恢复提交前状态。
|
||||
*
|
||||
* @param resourceId 资源 ID
|
||||
* @param previousStatus 提交前状态
|
||||
* @param approvalInstanceId 审批实例 ID
|
||||
*/
|
||||
default void restoreState(BigInteger resourceId,
|
||||
PublishStatus previousStatus,
|
||||
BigInteger approvalInstanceId) {
|
||||
restoreState(resourceId, previousStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,10 @@ public class AiResourceLifecycleServiceImpl implements AiResourceLifecycleServic
|
||||
AiResourceLifecycleHandler handler = getHandler(resourceType);
|
||||
ApprovalSubmitRequest request = handler.buildSubmitRequest(resourceId, actionType, operatorId);
|
||||
ApprovalFlowDetailVo flow = approvalMatchService.matchFlowOrNull(request);
|
||||
Map<String, Object> resourceSnapshot = readResourceSnapshot(request.getSnapshotJson());
|
||||
if (flow == null) {
|
||||
handler.applyApprovedAction(actionType, resourceId, readResourceSnapshot(request.getSnapshotJson()), operatorId);
|
||||
handler.retainSubmittedSnapshot(actionType, resourceSnapshot);
|
||||
handler.applyApprovedAction(actionType, resourceId, resourceSnapshot, operatorId);
|
||||
return ApprovalActionResult.direct();
|
||||
}
|
||||
request.setApplicationReason(ApprovalApplicationReasonPolicy.normalize(
|
||||
@@ -73,6 +75,7 @@ public class AiResourceLifecycleServiceImpl implements AiResourceLifecycleServic
|
||||
applicationReason
|
||||
));
|
||||
BigInteger instanceId = approvalInstanceService.submitApproval(request);
|
||||
handler.retainSubmittedSnapshot(actionType, resourceSnapshot);
|
||||
handler.updatePendingState(
|
||||
resourceId,
|
||||
resolveSubmittedStatus(actionType, resolvePreviousStatus(request.getSnapshotJson())),
|
||||
@@ -100,12 +103,14 @@ public class AiResourceLifecycleServiceImpl implements AiResourceLifecycleServic
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleApproved(ApprovalInstance instance, BigInteger operatorId, String comment) {
|
||||
getHandler(instance.getResourceType()).applyApprovedAction(
|
||||
instance.getActionType(),
|
||||
instance.getResourceId(),
|
||||
readResourceSnapshot(instance.getSnapshotJson()),
|
||||
operatorId
|
||||
operatorId,
|
||||
instance.getId()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,10 +118,12 @@ public class AiResourceLifecycleServiceImpl implements AiResourceLifecycleServic
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleRejected(ApprovalInstance instance, BigInteger operatorId, String comment) {
|
||||
getHandler(instance.getResourceType()).restoreState(
|
||||
instance.getResourceId(),
|
||||
resolvePreviousStatus(instance.getSnapshotJson())
|
||||
resolvePreviousStatus(instance.getSnapshotJson()),
|
||||
instance.getId()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,10 +131,12 @@ public class AiResourceLifecycleServiceImpl implements AiResourceLifecycleServic
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleRevoked(ApprovalInstance instance, BigInteger operatorId, String comment) {
|
||||
getHandler(instance.getResourceType()).restoreState(
|
||||
instance.getResourceId(),
|
||||
resolvePreviousStatus(instance.getSnapshotJson())
|
||||
resolvePreviousStatus(instance.getSnapshotJson()),
|
||||
instance.getId()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user