增加 Sequences parse(String formatted, String pattern)方法,用于根据格式反解析格式化后的字符串为序列号对象
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import com.mysql.cj.jdbc.MysqlDataSource;
|
||||
import com.yanghuanglin.seq.config.GeneratorConfig;
|
||||
import com.yanghuanglin.seq.config.TableConfig;
|
||||
import com.yanghuanglin.seq.po.Sequences;
|
||||
import com.yanghuanglin.seq.generator.Generator;
|
||||
import com.yanghuanglin.seq.generator.impl.SequencesGenerator;
|
||||
import com.mysql.cj.jdbc.MysqlDataSource;
|
||||
import com.yanghuanglin.seq.po.Sequences;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -73,4 +73,18 @@ public class SeqTest {
|
||||
String s = "select * from sequences where `%s`=? and `%s`=?";
|
||||
System.out.println(String.format(s, "key", "value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseTest() {
|
||||
String seqPattern = "ZZF#year##month##seq#";
|
||||
String formatted = "ZZF20220200008";
|
||||
|
||||
Sequences sequences = generator.parse(formatted, seqPattern);
|
||||
|
||||
String key = "zzfCode" + sequences.getYear();
|
||||
|
||||
sequences.setKey(key);
|
||||
sequences.setType("MISSION");
|
||||
System.out.println(sequences);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user