Commit ba4f7702 authored by 赵啸非's avatar 赵啸非

添加资源扫描接口

parent 3e2c8992
...@@ -93,7 +93,7 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re ...@@ -93,7 +93,7 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
public Rest<String> refreshResourceUrl(String packageName, Context context) { public Rest<String> refreshResourceUrl(String packageName, Context context) {
List<Class<?>> classList = ControllerScanUtil.getAllClassByPackageName(packageName); List<Class<?>> classList = ControllerScanUtil.getAllClassByPackageName(packageName);
//System.out.println(classList); //获取到了所有的类 //System.out.println(classList); //获取到了所有的类
List<ResourceEntity> newResourcelist = ControllerScanUtil.getAnnotationInfo(classList); List<ResourceEntity> newResourcelist = ControllerScanUtil.getAnnotationInfo(classList).stream().filter(f->!ObjectUtils.isEmpty(f.getUrl())).collect(Collectors.toList());
Map<String, List<ResourceEntity>> localResourceMap = this.find(new ResourceQuery()).stream().collect(Collectors.groupingBy(x -> x.getName())); Map<String, List<ResourceEntity>> localResourceMap = this.find(new ResourceQuery()).stream().collect(Collectors.groupingBy(x -> x.getName()));
Map<String, List<ResourceEntity>> newResourceMap = newResourcelist.stream().collect(Collectors.groupingBy(x -> x.getName())); Map<String, List<ResourceEntity>> newResourceMap = newResourcelist.stream().collect(Collectors.groupingBy(x -> x.getName()));
......
...@@ -3,6 +3,7 @@ package com.mortals.xhx.busiz.web; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.busiz.web;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
...@@ -167,5 +168,15 @@ public class DeviceSendMsgController { ...@@ -167,5 +168,15 @@ public class DeviceSendMsgController {
return JSON.toJSONString(rsp); return JSON.toJSONString(rsp);
} }
public static void main(String[] args) {
String input = "/example/path/to/file";
// 去掉开头和结尾的 \
String result = StrUtil.removeSuffix(StrUtil.removePrefix(input, "/"), "/");
System.out.println("处理前: " + input);
System.out.println("处理后: " + result);
}
} }
...@@ -73,7 +73,7 @@ public class ControllerScanUtil { ...@@ -73,7 +73,7 @@ public class ControllerScanUtil {
if (ObjectUtils.isEmpty(result)) { if (ObjectUtils.isEmpty(result)) {
if (requestMappingCls != null) { if (requestMappingCls != null) {
result = requestMappingCls.value()[0].toUpperCase() + "接口模块"; result = StrUtil.removeSuffix(StrUtil.removePrefix(requestMappingCls.value()[0].toUpperCase(), "/"), "/") + "接口模块";
} }
resourceViewEntity.setName(result + "-查看"); resourceViewEntity.setName(result + "-查看");
resourceEditEntity.setName(result + "-维护"); resourceEditEntity.setName(result + "-维护");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment