Package cn.lm.mybatis.mapper.genid
Interface GenId<T>
- All Known Implementing Classes:
GenId.NULL,SnowflakeGenId
public interface GenId<T>
不提供具体的实现,这里提供一个思路。
在 Spring 集成环境中,可以通过配置静态方式获取 Spring 的 context 对象。
如果使用 vesta(https://gitee.com/free/vesta-id-generator) 来生成 ID,假设已经提供了 vesta 的 idService。
那么可以在实现中获取该类,然后生成 Id 返回,示例代码如下:
public class VestaGenId implement GenId{ public Long genId(String table, String column){ //ApplicationUtil.getBean 需要自己实现 IdService idService = ApplicationUtil.getBean(IdService.class); return idService.genId(); } }
- Author:
- liuzh
-
Nested Class Summary
Nested Classes -
Method Summary
-
Method Details
-
genId
-