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

修改若尔盖

parent bc254467
......@@ -140,27 +140,27 @@
<profiles.server.port>18222</profiles.server.port>
<profiles.platform.type>cloud</profiles.platform.type>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://172.15.28.121:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.12:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.redis.uri>172.15.28.120</profiles.redis.uri>
<profiles.redis.uri>192.168.0.12</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.database>6</profiles.redis.database>
<profiles.rabbitmq.host>172.15.28.115</profiles.rabbitmq.host>
<profiles.rabbitmq.host>192.168.0.124</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.exchange>amp.direct</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>http://172.15.28.116:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.smsSendUrl>http://192.168.0.14:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.log.level>INFO</profiles.log.level>
<profiles.nacos.server-addr>172.15.28.120:8848</profiles.nacos.server-addr>
<profiles.nacos.server-addr>192.168.0.124:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<package.environment>yibin</package.environment>
......
......@@ -2,7 +2,6 @@ package com.mortals.xhx.common.utils;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -105,10 +104,10 @@ public class ControllerScanUtil {
Method[] methods = cls.getDeclaredMethods();
if (methods != null && methods.length > 0) {
for (Method method : methods) {
boolean unAuth = method.isAnnotationPresent(UnAuth.class);
/* boolean unAuth = method.isAnnotationPresent(UnAuth.class);
if (unAuth) {
continue;
}
}*/
boolean mExits = method.isAnnotationPresent(RequestMapping.class);
if (mExits) {
......@@ -140,10 +139,10 @@ public class ControllerScanUtil {
Method[] superMethods = cls.getSuperclass().getDeclaredMethods();
if (superMethods != null && superMethods.length > 0) {
for (Method method : superMethods) {
boolean unAuth = method.isAnnotationPresent(UnAuth.class);
/* boolean unAuth = method.isAnnotationPresent(UnAuth.class);
if (unAuth) {
continue;
}
}*/
boolean mExits = method.isAnnotationPresent(RequestMapping.class);
if (mExits) {
RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
......
......@@ -2,7 +2,6 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.module.site.web.SiteController;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -28,14 +27,19 @@ public class ScanTest {
public static final String[] ULR_VIEW = {"view", "info", "list", "get", "find", "export", "download",
"index", "bill"};
public static final String[] WHITE_URL = {"login", "test", "file", "securitycode"};
public static void main(String[] args) {
List<Class<?>> classList = getAllClassByPackageName(SiteController.class.getPackage());
List<Class<?>> classList = getAllClassByPackageName("com.mortals.xhx");
//System.out.println(classList); //获取到了所有的类
getAnnotationInfo(classList);
}
public static void getAnnotationInfo(List<Class<?>> clsList) {
public static List<ResourceEntity> getAnnotationInfo(List<Class<?>> clsList) {
List<ResourceEntity> resourceArrayList = new ArrayList<>();
if (clsList != null && clsList.size() > 0) {
for (Class<?> cls : clsList) {
......@@ -43,33 +47,59 @@ public class ScanTest {
if (!exits) {
continue;
}
//白名单地址的 也不需要
ResourceEntity resourceViewEntity = new ResourceEntity();
resourceViewEntity.initAttrValue();
ResourceEntity resourceEditEntity = new ResourceEntity();
resourceEditEntity.initAttrValue();
resourceEditEntity.setSourceType(1);
Method substringMethod = null;
String result = "";
try {
String packName = cls.getPackage().getName();
if (StrUtil.contains(packName, "system")) {
//系统管理-xx管理-
substringMethod = cls.getMethod("getModuleDesc");
result = (String) substringMethod.invoke(cls.newInstance());
resourceViewEntity.setName("系统管理-" + result + "管理-查看");
resourceEditEntity.setName("系统管理-" + result + "管理-维护");
} else {
substringMethod = cls.getMethod("getModuleDesc");
result = (String) substringMethod.invoke(cls.newInstance());
resourceViewEntity.setName(result + "-查看");
resourceEditEntity.setName(result + "-维护");
}
} catch (Exception e) {
}
if (ObjectUtils.isEmpty(result)) {
resourceViewEntity.setName(result + "-查看");
resourceEditEntity.setName(result + "-维护");
}
System.out.println(result);
// String qualifiedName = ClassUtils.getQualifiedName(cls);
// System.out.println("qualifiedName:"+qualifiedName);
RequestMapping requestMappingCls = cls.getAnnotation(RequestMapping.class);
String prefix = "";
if (requestMappingCls != null) {
prefix = "/" + requestMappingCls.value()[0];
boolean b = false;
for (String s : WHITE_URL) {
if (StrUtil.contains(requestMappingCls.value()[0].toLowerCase(), s)) {
b = true;
break;
}
}
if (b) {
continue;
}
}
if (ObjectUtils.isEmpty(result)) {
if (requestMappingCls != null) {
result = StrUtil.removeSuffix(StrUtil.removePrefix(requestMappingCls.value()[0].toUpperCase(), "/"), "/") + "接口模块";
}
resourceViewEntity.setName(result + "-查看");
resourceEditEntity.setName(result + "-维护");
}
Set<String> urlSet = new HashSet<>();
//获取类中的所有的方法
......@@ -87,7 +117,6 @@ public class ScanTest {
String url = prefix + "/" + requestMapping.value()[0];
url = url.replaceAll("/+", "/");
urlSet.add(url);
// System.out.println("/" + prefix + "/" + requestMapping.value()[0]);
}
boolean mExits1 = method.isAnnotationPresent(GetMapping.class);
......@@ -96,7 +125,6 @@ public class ScanTest {
String url = prefix + "/" + getMapping.value()[0];
url = url.replaceAll("/+", "/");
urlSet.add(url);
// System.out.println("/" + prefix + "/" + getMapping.value()[0]);
}
boolean mExits2 = method.isAnnotationPresent(PostMapping.class);
......@@ -105,7 +133,6 @@ public class ScanTest {
String url = prefix + "/" + postMapping.value()[0];
url = url.replaceAll("/+", "/");
urlSet.add(url);
// System.out.println("/" + prefix + "/" + postMapping.value()[0]);
}
}
}
......@@ -114,19 +141,16 @@ public class ScanTest {
Method[] superMethods = cls.getSuperclass().getDeclaredMethods();
if (superMethods != null && superMethods.length > 0) {
for (Method method : superMethods) {
boolean unAuth = method.isAnnotationPresent(UnAuth.class);
if (unAuth) {
continue;
}
boolean mExits = method.isAnnotationPresent(RequestMapping.class);
if (mExits) {
RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
String url = prefix + "/" + requestMapping.value()[0];
url = url.replaceAll("/+", "/");
urlSet.add(url);
// System.out.println("super /" + prefix + "/" + requestMapping.value()[0]);
}
boolean mExits1 = method.isAnnotationPresent(GetMapping.class);
......@@ -135,7 +159,6 @@ public class ScanTest {
String url = prefix + "/" + getMapping.value()[0];
url = url.replaceAll("/+", "/");
urlSet.add(url);
//System.out.println("super /" + prefix + "/" + getMapping.value()[0]);
}
boolean mExits2 = method.isAnnotationPresent(PostMapping.class);
......@@ -144,7 +167,6 @@ public class ScanTest {
String url = prefix + "/" + postMapping.value()[0];
url = url.replaceAll("/+", "/");
urlSet.add(url);
// System.out.println("super /" + prefix + "/" + postMapping.value()[0]);
}
}
}
......@@ -154,32 +176,35 @@ public class ScanTest {
Set<String> UrlEditSet = new HashSet<>();
for (String url : urlSet) {
String str = StrUtil.subAfter(url, "/", true);
boolean bool=false;
boolean bool = false;
for (String checkStr : ULR_VIEW) {
boolean contains = StrUtil.contains(str.toLowerCase(), checkStr);
if (contains) {
UrlViewSet.add(url);
bool=true;
bool = true;
break;
}
}
if(!bool){
if (!bool) {
UrlEditSet.add(url);
}
}
resourceViewEntity.setUrl(UrlViewSet.stream().collect(Collectors.joining(",")));
System.out.println(JSONObject.toJSONString(resourceViewEntity));
resourceArrayList.add(resourceViewEntity);
resourceEditEntity.setUrl(UrlEditSet.stream().collect(Collectors.joining(",")));
System.out.println(JSONObject.toJSONString(resourceEditEntity));
resourceArrayList.add(resourceEditEntity);
}
}
}
return resourceArrayList;
}
public static List<Class<?>> getAllClassByPackageName(Package pkg) {
// String packageName = pkg.getName();
String packageName = "com.mortals.xhx";
public static List<Class<?>> getAllClassByPackageName(String packageName) {
// 获取当前包下以及子包下所以的类
List<Class<?>> returnClassList = getClasses(packageName);
return returnClassList;
......
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