Java Code Examples for com.baomidou.mybatisplus.core.toolkit.StringUtils#isEmpty()
The following examples show how to use
com.baomidou.mybatisplus.core.toolkit.StringUtils#isEmpty() .
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: MyBatisUtil.java From summerframework with Apache License 2.0 | 6 votes |
public static <T> String getFieldName(EntityGetterMethod<T, Object> expression) { if (expression == null) throw new IllegalArgumentException("Expression should not be null"); try { Method method = expression.getClass().getDeclaredMethod("writeReplace"); method.setAccessible(Boolean.TRUE); SerializedLambda serializedLambda = (SerializedLambda)method.invoke(expression); String fieldName = StringUtils.resolveFieldName(serializedLambda.getImplMethodName()); String className = serializedLambda.getImplClass().replace("/", "."); Field field = ReflectionUtils.findField(Class.forName(className), fieldName); String columnName = field.getName(); TableField[] tableField = field.getAnnotationsByType(TableField.class); if (null != tableField && tableField.length == 1) { if (!StringUtils.isEmpty(tableField[0].value())) { columnName = tableField[0].value(); } } String ret = StringUtils.camelToUnderline(columnName); return ret; } catch (ReflectiveOperationException e) { throw new RuntimeException("This will never happen!", e); } }
Example 2
Source File: AbstractLogicCustomMethod.java From albedo with GNU Lesser General Public License v3.0 | 6 votes |
public String getAllSqlWhere(TableInfo table, boolean ignoreLogicDelFiled, boolean withId, String prefix, String columnPrefix) { String newPrefix = prefix == null ? "" : prefix; String filedSqlScript = table.getFieldList().stream().filter((i) -> { if (!ignoreLogicDelFiled) { return true; } else { return !table.isLogicDelete() || !i.isLogicDelete(); } }).map((i) -> i.getSqlWhere(newPrefix)).collect(Collectors.joining("\n")); if (withId && !StringUtils.isEmpty(table.getKeyProperty())) { String newKeyProperty = newPrefix + table.getKeyProperty(); String keySqlScript = columnPrefix + table.getKeyColumn() + "=" + SqlScriptUtils.safeParam(newKeyProperty); return SqlScriptUtils.convertIf(keySqlScript, String.format("%s != null", newKeyProperty), false) + "\n" + filedSqlScript; } else { return filedSqlScript; } }
Example 3
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 4
Source File: AccountHeadService.java From jshERP with GNU General Public License v3.0 | 5 votes |
/** * create by: qiankunpingtai * website:https://qiankunpingtai.cn * description: * 正常删除,要考虑数据完整性,进行完整性校验 * create time: 2019/4/10 15:49 * @Param: ids * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteAccountHeadByIdsNormal(String ids) throws Exception { /** * 校验 * 1、财务子表 jsh_accountitem * 是否有相关数据 * */ int deleteTotal=0; if(StringUtils.isEmpty(ids)){ return deleteTotal; } String [] idArray=ids.split(","); /** * 校验财务子表 jsh_accountitem * */ List<AccountItem> accountItemList = null; try{ accountItemList = accountItemMapperEx.getAccountItemListByHeaderIds(idArray); }catch(Exception e){ JshException.readFail(logger, e); } if(accountItemList!=null&&accountItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,HeaderIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); } /** * 校验通过执行删除操作 * */ deleteTotal= batchDeleteAccountHeadByIds(ids); return deleteTotal; }
Example 5
Source File: UnitService.java From jshERP with GNU General Public License v3.0 | 5 votes |
/** * create by: qiankunpingtai * website:https://qiankunpingtai.cn * description: * 正常删除,要考虑数据完整性,进行完整性校验 * create time: 2019/4/11 10:20 * @Param: ids * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteUnitByIdsNormal(String ids) throws Exception { /** * 校验 * 1、产品表 jsh_material * 是否有相关数据 * */ int deleteTotal=0; if(StringUtils.isEmpty(ids)){ return deleteTotal; } String [] idArray=ids.split(","); /** * 校验产品表 jsh_material * */ List<Material> materialList=null; try{ materialList=materialMapperEx.getMaterialListByUnitIds(idArray); }catch(Exception e){ JshException.readFail(logger, e); } if(materialList!=null&&materialList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,UnitIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); } /** * 校验通过执行删除操作 * */ deleteTotal= batchDeleteUnitByIds(ids); return deleteTotal; }
Example 6
Source File: InOutItemService.java From jshERP with GNU General Public License v3.0 | 5 votes |
/** * create by: qiankunpingtai * website:https://qiankunpingtai.cn * description: * 正常删除,要考虑数据完整性,进行完整性校验 * create time: 2019/4/10 16:23 * @Param: ids * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteInOutItemByIdsNormal(String ids) throws Exception { /** * 校验 * 1、财务子表 jsh_accountitem * 是否有相关数据 * */ int deleteTotal=0; if(StringUtils.isEmpty(ids)){ return deleteTotal; } String [] idArray=ids.split(","); /** * 校验财务子表 jsh_accountitem * */ List<AccountItem> accountItemList=null; try{ accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray); }catch(Exception e){ JshException.readFail(logger, e); } if(accountItemList!=null&&accountItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); } /** * 校验通过执行删除操作 * */ deleteTotal= batchDeleteInOutItemByIds(ids); return deleteTotal; }
Example 7
Source File: MaterialService.java From jshERP with GNU General Public License v3.0 | 5 votes |
/** * create by: qiankunpingtai * website:https://qiankunpingtai.cn * description: * 正常删除,要考虑数据完整性,进行完整性校验 * create time: 2019/4/10 18:00 * @Param: ids * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteMaterialByIdsNormal(String ids) throws Exception{ /** * 校验 * 1、单据子表 jsh_depotitem * 是否有相关数据 * */ int deleteTotal=0; if(StringUtils.isEmpty(ids)){ return deleteTotal; } String [] idArray=ids.split(","); /** * 校验单据子表 jsh_depotitem * */ List<DepotItem> depotItemList =null; try{ depotItemList= depotItemMapperEx.getDepotItemListListByMaterialIds(idArray); }catch(Exception e){ JshException.readFail(logger, e); } if(depotItemList!=null&&depotItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,MaterialIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); } /** * 校验通过执行删除操作 * */ deleteTotal= batchDeleteMaterialByIds(ids); return deleteTotal; }
Example 8
Source File: DepotService.java From jshERP with GNU General Public License v3.0 | 5 votes |
/** * create by: qiankunpingtai * website:https://qiankunpingtai.cn * description: * 正常删除,要考虑数据完整性,进行完整性校验 * create time: 2019/4/10 16:52 * @Param: ids * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteDepotByIdsNormal(String ids) throws Exception { /** * 校验 * 1、单据主表 jsh_depothead * 2、单据子表 jsh_depotitem * 是否有相关数据 * */ int deleteTotal=0; if(StringUtils.isEmpty(ids)){ return deleteTotal; } String [] idArray=ids.split(","); /** * 校验单据子表 jsh_depotitem * */ List<DepotItem> depotItemList=null; try{ depotItemList= depotItemMapperEx.getDepotItemListListByDepotIds(idArray); }catch(Exception e){ JshException.readFail(logger, e); } if(depotItemList!=null&&depotItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); } /** * 校验通过执行删除操作 * */ deleteTotal= batchDeleteDepotByIds(ids); return deleteTotal; }