Commit 97a45972 by huangfusuper

增加版本号解析工具方法

parent f80c036e
......@@ -181,7 +181,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//当版本号不存在
if(StringUtils.isBlank(versionName)){
String version = oldFlow.getVersionName();
Integer versionTag = Integer.valueOf(version.split("\\.")[1]);
Integer versionTag = JobVersionGenUtil.parsingVersionName(version);
flow.setVersionName(JobVersionGenUtil.generateVersionName(versionTag));
}else{
......
package com.byit.utils;
import org.springframework.util.StringUtils;
/**
* 版本号生成策略
*
......@@ -7,14 +9,30 @@ package com.byit.utils;
*/
public class JobVersionGenUtil {
public static final String VERSION_NAME_PRE = "V.%s";
private static final String VERSION_NAME_PRE = "V.%s";
private static final String SEGMENTATION = "\\.";
/**
* 调度版本生成策略
*
* @param versionIndex 版本索号
* @return 对应的版本名称
*/
public static String generateVersionName(Integer versionIndex){
public static String generateVersionName(Integer versionIndex) {
return String.format(VERSION_NAME_PRE, versionIndex);
}
/**
* 解析版本号为版本索引
*
* @param versionName 版本名称
* @return 对应的版本索引
*/
public static Integer parsingVersionName(String versionName) {
if (StringUtils.isEmpty(versionName)) {
return 0;
}
return Integer.valueOf(versionName.split(SEGMENTATION)[1]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment