| | |
| | | |
| | | select * from lf.sys_user; |
| | | select * from lf.sys_role; |
| | | select * from lf.sys_meta where dircode like '01%' or dircode like '02%' or dircode like '030000%' |
| | | or dircode like '030001%' or dircode like '040100%' or dircode like '040101%' or dircode like '040102%'; |
| | | select * from lf.sys_download where guid = '5f0d5b61ca8cd79a07502f308c2f4dcc'; |
| | | |
| | | |
| | | select code "key",name "value" from lf.sys_dir where pid = 1 |
| | | |
| | | select (select string_agg(code, ',') from lf.sys_dir where name = a.name) "key", name "value" from lf.sys_dir a |
| | | where name in ('测量(ESV)', '勘察(EGE)', '地灾(EGD)', '洞库(EGD)') group by name order by name |
| | | |
| | | |
| | | |
| | |
| | | import java.io.File; |
| | | import java.net.URLDecoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 资料馆 |
| | |
| | | @ApiOperation(value = "分页查询元数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "depcode", value = "单位编码", dataType = "String", paramType = "query", example = "00"), |
| | | @ApiImplicitParam(name = "dirs", value = "目录ID", dataType = "String", paramType = "query", example = "00,01"), |
| | | @ApiImplicitParam(name = "dirs", value = "目录编码", dataType = "String", paramType = "query", example = "00,01"), |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | dirs = DataLibService.copeCodes(dirs, "dircode"); |
| | | |
| | | int count = metaService.selectMetasForCount(depcode, dirs, name); |
| | | if (count == 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | if (sb.length() > 0 && sb.lastIndexOf(join) == sb.length() - 1) { |
| | | sb.deleteCharAt(sb.length() - 1); |
| | | if (sb.length() > 0 && sb.lastIndexOf(join) == sb.length() - join.length()) { |
| | | // 删除从索引 start 开始到 end 之间的字符,即 前包括 后不包括。 |
| | | sb.delete(sb.length() - join.length(), sb.length()); |
| | | } |
| | | |
| | | return sb.toString(); |
| | |
| | | |
| | | return rows > 0 ? downloadEntity.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 处理编码 |
| | | */ |
| | | public static String copeCodes(String codes, String field) { |
| | | if (StringHelper.isEmpty(codes) || StringHelper.isSqlInjection(codes)) { |
| | | return null; |
| | | } |
| | | |
| | | List<String> list = codesAsList(codes); |
| | | removeDuplicate(list); |
| | | setRightLike(list, field); |
| | | |
| | | return StringHelper.join(list, " or "); |
| | | } |
| | | |
| | | /** |
| | | * 单位编码转集合 |
| | | */ |
| | | private static List<String> codesAsList(String codes) { |
| | | List<String> list = Arrays.asList(codes.split(",")); |
| | | Set set = new HashSet(list); |
| | | |
| | | List<String> newList = new ArrayList<>(set); |
| | | Collections.sort(newList); |
| | | |
| | | return newList; |
| | | } |
| | | |
| | | /** |
| | | * 去除重复 |
| | | */ |
| | | private static void removeDuplicate(List<String> list) { |
| | | int i = 0; |
| | | while (i < list.size()) { |
| | | int j = findStr(list, i); |
| | | if (j > -1) { |
| | | list.remove(j); |
| | | continue; |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查找字符串 |
| | | */ |
| | | private static int findStr(List<String> list, int i) { |
| | | String source = list.get(i); |
| | | for (int j = i + 1, c = list.size(); j < c; j++) { |
| | | if (list.get(j).startsWith(source)) { |
| | | return j; |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | /** |
| | | * 设置 右like |
| | | */ |
| | | private static void setRightLike(List<String> list, String field) { |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | | String str = String.format("%s like '%s%%'", field, list.get(i)); |
| | | list.set(i, str); |
| | | } |
| | | } |
| | | } |