增加 Sequences parse(String formatted, String pattern)方法,用于根据格式反解析格式化后的字符串为序列号对象

This commit is contained in:
yhl452493373
2022-02-11 13:57:12 +08:00
parent 54e2f9dffb
commit 0fa5cc1e7e
8 changed files with 230 additions and 15 deletions

View File

@@ -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);
}
}