Java Code Examples for cn.hutool.core.collection.CollectionUtil#join()
The following examples show how to use
cn.hutool.core.collection.CollectionUtil#join() .
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: Wrapper.java From yue-library with Apache License 2.0 | 6 votes |
/** * 包装字段名<br> * 有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突 * @param field 字段名 * @return 包装后的字段名 */ public String wrap(String field){ if(preWrapQuote == null || sufWrapQuote == null || StrUtil.isBlank(field)) { return field; } //如果已经包含包装的引号,返回原字符 if(StrUtil.isSurround(field, preWrapQuote, sufWrapQuote)){ return field; } //如果字段中包含通配符或者括号(字段通配符或者函数),不做包装 if(StrUtil.containsAnyIgnoreCase(field, "*", "(", " ", " as ")) { return field; } //对于Oracle这类数据库,表名中包含用户名需要单独拆分包装 if(field.contains(StrUtil.DOT)){ final Collection<String> target = CollectionUtil.filter(StrUtil.split(field, StrUtil.C_DOT), (Editor<String>) t -> StrUtil.format("{}{}{}", preWrapQuote, t, sufWrapQuote)); return CollectionUtil.join(target, StrUtil.DOT); } return StrUtil.format("{}{}{}", preWrapQuote, field, sufWrapQuote); }
Example 2
Source File: DataScopeInterceptor.java From smaker with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Object intercept(Invocation invocation) throws Throwable { StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget()); MetaObject metaObject = SystemMetaObject.forObject(statementHandler); this.sqlParser(metaObject); // 先判断是不是SELECT操作 MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement"); if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) { return invocation.proceed(); } BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql"); String originalSql = boundSql.getSql(); Object parameterObject = boundSql.getParameterObject(); //查找参数中包含DataScope类型的参数 DataScope dataScope = findDataScopeObject(parameterObject); if (dataScope == null) { return invocation.proceed(); } else { String scopeName = dataScope.getScopeName(); List<Integer> deptIds = dataScope.getDeptIds(); if (StrUtil.isNotBlank(scopeName) && CollectionUtil.isNotEmpty(deptIds)) { String join = CollectionUtil.join(deptIds, ","); originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")"; metaObject.setValue("delegate.boundSql.sql", originalSql); } return invocation.proceed(); } }
Example 3
Source File: TransportOrderModel.java From openAGV with Apache License 2.0 | 5 votes |
private TransportOrderModel(String vehicleName, String finalPosition, String finalLocation, String finalOperation, List<String> pointPaths, List<LocationOperation> locationOperationList) { this.id = IdUtil.objectId(); this.vehicleName = vehicleName; this.finalPosition = finalPosition; this.finalLocation = finalLocation; this.finalOperation = finalOperation; this.pointPaths = pointPaths; if (null != pointPaths) { this.pointPathStr = CollectionUtil.join(pointPaths.iterator(), ","); } this.locationOperationList = locationOperationList; }
Example 4
Source File: PermissionCheckServiceServiceImpl.java From WebStack-Guns with MIT License | 5 votes |
@Override public boolean check(Object[] permissions) { ShiroUser user = ShiroKit.getUser(); if (null == user) { return false; } ArrayList<Object> objects = CollectionUtil.newArrayList(permissions); String join = CollectionUtil.join(objects, ","); if (ShiroKit.hasAnyRoles(join)) { return true; } return false; }
Example 5
Source File: AuthServiceImpl.java From Guns with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean check(String[] roleNames) { LoginUser user = LoginContextHolder.getContext().getUser(); if (null == user) { return false; } ArrayList<String> objects = CollectionUtil.newArrayList(roleNames); String join = CollectionUtil.join(objects, ","); if (LoginContextHolder.getContext().hasAnyRoles(join)) { return true; } return false; }