ID 使用 mybatis-plus 自动生成雪花id
This commit is contained in:
@ -8,8 +8,8 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class Demo {
|
||||
|
||||
private String id;
|
||||
|
||||
private Long id;
|
||||
private String col1;
|
||||
private String col2;
|
||||
private String createBy;
|
||||
|
@ -10,6 +10,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import com.chinaunicom.mall.ebtp.cloud.mybatis.example.mapper.DemoMapper;
|
||||
import com.chinaunicom.mall.ebtp.cloud.mybatis.example.model.Demo;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class MybatisPlusExampleTest {
|
||||
@ -22,10 +24,12 @@ public class MybatisPlusExampleTest {
|
||||
@Test
|
||||
public void testInsert() {
|
||||
Demo demo = new Demo();
|
||||
demo.setId("10");
|
||||
demo.setCol1("test");
|
||||
demo.setCol2("test01");
|
||||
// demo.setId("10");
|
||||
// demo.setCol1("test");
|
||||
// demo.setCol2("test01");
|
||||
//
|
||||
|
||||
System.out.println(IdUtil.getSnowflake(30, 30).nextId());
|
||||
Assertions.assertThat(mapper.insert(demo)).isGreaterThan(0);
|
||||
}
|
||||
//
|
||||
|
Reference in New Issue
Block a user