Skip to content

Commit

Permalink
feature: 脚本已下线版本可以禁用 #1374
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 authored and jsonwan committed Sep 26, 2022
1 parent 5a6422e commit f04d995
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Response publishScriptVersion(
Long scriptVersionId
);

@ApiOperation(value = "下线脚本", produces = "application/json")
@ApiOperation(value = "禁用脚本", produces = "application/json")
@PutMapping("/scope/{scopeType}/{scopeId}/script/{scriptId}/scriptVersion/{scriptVersionId}/disable")
Response disableScriptVersion(
@ApiParam("用户名,网关自动传入")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@

/**
* JOB资源状态
*
* @date 2019/09/19
*/

public enum JobResourceStatusEnum {
/**
* 未上线-草稿
* 未上线
*/
DRAFT(0),
/**
Expand All @@ -48,7 +46,7 @@ public enum JobResourceStatusEnum {
*/
DISABLED(3);

private int status;
private final int status;

JobResourceStatusEnum(int status) {
this.status = status;
Expand All @@ -67,7 +65,7 @@ public static JobResourceStatusEnum getJobResourceStatus(Integer status) {
} else if (status == OFFLINE.getValue()) {
return OFFLINE;
} else {
return null;
throw new IllegalArgumentException("No JobResourceStatusEnum constant: " + status);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ public void disableScript(
throw new NotFoundException(ErrorCode.SCRIPT_NOT_EXIST);
}

if (!scriptVersionToBeDisabled.getStatus().equals(JobResourceStatusEnum.ONLINE.getValue())) {
if (!scriptVersionToBeDisabled.getStatus().equals(JobResourceStatusEnum.ONLINE.getValue())
&& !scriptVersionToBeDisabled.getStatus().equals(JobResourceStatusEnum.OFFLINE.getValue())) {
log.warn("Disable script, scriptVersion:{}, status:{} could not disable", scriptVersionId,
scriptVersionToBeDisabled.getStatus());
throw new FailedPreconditionException(ErrorCode.UNSUPPORTED_OPERATION);
Expand Down

0 comments on commit f04d995

Please sign in to comment.