com.baomidou.mybatisplus.core.handlers.MetaObjectHandler Java Examples
The following examples show how to use
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomMybatisPlusParameterHandler.java From sqlhelper with GNU Lesser General Public License v3.0 | 5 votes |
public static Object populateKeys(MetaObjectHandler metaObjectHandler, TableInfo tableInfo, MappedStatement ms, Object parameterObject, boolean isInsert) { if (null == tableInfo) { return parameterObject; } else { MetaObject metaObject = ms.getConfiguration().newMetaObject(parameterObject); if (isInsert && !StringUtils.isEmpty(tableInfo.getKeyProperty()) && null != tableInfo.getIdType() && tableInfo.getIdType().getKey() >= 3) { Object idValue = metaObject.getValue(tableInfo.getKeyProperty()); if (StringUtils.checkValNull(idValue)) { if (tableInfo.getIdType() == IdType.ID_WORKER) { metaObject.setValue(tableInfo.getKeyProperty(), IdWorker.getId()); } else if (tableInfo.getIdType() == IdType.ID_WORKER_STR) { metaObject.setValue(tableInfo.getKeyProperty(), IdWorker.getIdStr()); } else if (tableInfo.getIdType() == IdType.UUID) { metaObject.setValue(tableInfo.getKeyProperty(), IdWorker.get32UUID()); } } } if (metaObjectHandler != null) { if (isInsert && metaObjectHandler.openInsertFill()) { metaObjectHandler.insertFill(metaObject); } else if (!isInsert) { metaObjectHandler.updateFill(metaObject); } } return metaObject.getOriginalObject(); } }
Example #2
Source File: MybatisPlusAutoConfigure.java From microservices-platform with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "zlt.mybatis-plus.auto-fill", name = "enabled", havingValue = "true", matchIfMissing = true) public MetaObjectHandler metaObjectHandler() { return new DateMetaObjectHandler(autoFillProperties); }
Example #3
Source File: MybatisPlusConfig.java From ruoyiplus with MIT License | 4 votes |
@Bean public MetaObjectHandler metaObjectHandler() { return new CustomMetaObjectHandler(); }