新增了扫描url的工具方法
This commit is contained in:
parent
93eab6b8a8
commit
326bcfbf9e
@ -25,13 +25,12 @@ import java.util.List;
|
|||||||
import static com.yutou.nas.Datas.AppData.defaultMusicPath;
|
import static com.yutou.nas.Datas.AppData.defaultMusicPath;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/nas/music/")
|
|
||||||
public class MusicController {
|
public class MusicController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
MusicToolsServiceImpl musicTools;
|
MusicToolsServiceImpl musicTools;
|
||||||
|
|
||||||
@RequestMapping("all.do")
|
@RequestMapping("/nas/music/all.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getAllMusicList() {
|
public String getAllMusicList() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -42,7 +41,7 @@ public class MusicController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("list.do")
|
@RequestMapping("/nas/music/list.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getMusicListOfPath(@RequestBody JSONObject body) {
|
public String getMusicListOfPath(@RequestBody JSONObject body) {
|
||||||
String path = body.getString("path");
|
String path = body.getString("path");
|
||||||
@ -65,7 +64,7 @@ public class MusicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("getAlbum.do")
|
@RequestMapping("/nas/music/getAlbum.do")
|
||||||
public String getAlbum(@RequestBody JSONObject body) {
|
public String getAlbum(@RequestBody JSONObject body) {
|
||||||
String album = body.getString("album");
|
String album = body.getString("album");
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -79,7 +78,7 @@ public class MusicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("getArtist.do")
|
@RequestMapping("/nas/music/getArtist.do")
|
||||||
public String getArtist(@RequestBody JSONObject body) {
|
public String getArtist(@RequestBody JSONObject body) {
|
||||||
String artist = body.getString("artist");
|
String artist = body.getString("artist");
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -92,7 +91,7 @@ public class MusicController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("reload.do")
|
@RequestMapping("/nas/music/reload.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String reload() {
|
public String reload() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -102,7 +101,7 @@ public class MusicController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("find/file.do")
|
@RequestMapping("/nas/music/find/file.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String findFile(@RequestBody JSONObject body) {
|
public String findFile(@RequestBody JSONObject body) {
|
||||||
String path = body.getString("path");
|
String path = body.getString("path");
|
||||||
@ -120,7 +119,7 @@ public class MusicController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("getlocalhost.do")
|
@RequestMapping("/nas/music/getlocalhost.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getLocalHost() {
|
public String getLocalHost() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -133,7 +132,7 @@ public class MusicController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "web/image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
@RequestMapping(value = "/nas/music/web/image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public byte[] getImage(String fileName, String type) {
|
public byte[] getImage(String fileName, String type) {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -146,7 +145,7 @@ public class MusicController {
|
|||||||
return getImage(json);
|
return getImage(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
@RequestMapping(value = "/nas/music/image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public byte[] getImage(@RequestBody JSONObject body) {
|
public byte[] getImage(@RequestBody JSONObject body) {
|
||||||
String fileName = body.getString("fileName");
|
String fileName = body.getString("fileName");
|
||||||
@ -172,7 +171,7 @@ public class MusicController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("random.do")
|
@RequestMapping("/nas/music/random.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String random() {
|
public String random() {
|
||||||
List<MusicData> list = musicTools.getMusicList();
|
List<MusicData> list = musicTools.getMusicList();
|
||||||
@ -192,7 +191,7 @@ public class MusicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("play.do")
|
@RequestMapping("/nas/music/play.do")
|
||||||
public ResponseEntity<FileSystemResource> play(String filePath, String random) {
|
public ResponseEntity<FileSystemResource> play(String filePath, String random) {
|
||||||
String _filePath;
|
String _filePath;
|
||||||
boolean _random;
|
boolean _random;
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* 收藏夹相关
|
* 收藏夹相关
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/nas/music/favorite/")
|
|
||||||
public class MusicFavoritesController {
|
public class MusicFavoritesController {
|
||||||
@Resource
|
@Resource
|
||||||
MusicFavoritesDao favoritesDao;
|
MusicFavoritesDao favoritesDao;
|
||||||
@ -30,7 +29,7 @@ public class MusicFavoritesController {
|
|||||||
@Resource
|
@Resource
|
||||||
MusicDataDao musicDataDao;
|
MusicDataDao musicDataDao;
|
||||||
|
|
||||||
@RequestMapping("dir/add.do")
|
@RequestMapping("/nas/music/favorite/dir/add.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String addFavoriteDir(@RequestBody JSONObject body) {
|
public String addFavoriteDir(@RequestBody JSONObject body) {
|
||||||
String favorite = body.getString("favorite");
|
String favorite = body.getString("favorite");
|
||||||
@ -50,7 +49,7 @@ public class MusicFavoritesController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("dir/list.do")
|
@RequestMapping("/nas/music/favorite/dir/list.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getAllFavoriteDir() {
|
public String getAllFavoriteDir() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -70,7 +69,7 @@ public class MusicFavoritesController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("dir/rename.do")
|
@RequestMapping("/nas/music/favorite/dir/rename.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String renameFavoriteDir(@RequestBody JSONObject body) {
|
public String renameFavoriteDir(@RequestBody JSONObject body) {
|
||||||
int id = body.getInteger("id");
|
int id = body.getInteger("id");
|
||||||
@ -89,7 +88,7 @@ public class MusicFavoritesController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("add.do")
|
@RequestMapping("/nas/music/favorite/add.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String addFavorite(@RequestBody JSONObject body) {
|
public String addFavorite(@RequestBody JSONObject body) {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
@ -116,7 +115,7 @@ public class MusicFavoritesController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("remove.do")
|
@RequestMapping("/nas/music/favorite/remove.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String removeFavorite(@RequestBody JSONObject body) {
|
public String removeFavorite(@RequestBody JSONObject body) {
|
||||||
JSONArray md5s = body.getJSONArray("data");
|
JSONArray md5s = body.getJSONArray("data");
|
||||||
@ -133,7 +132,7 @@ public class MusicFavoritesController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("get.do")
|
@RequestMapping("/nas/music/favorite/get.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getFavorite(@RequestBody JSONObject body) {
|
public String getFavorite(@RequestBody JSONObject body) {
|
||||||
int fid = body.getInteger("fid");
|
int fid = body.getInteger("fid");
|
||||||
|
@ -14,15 +14,14 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/qq/bot")
|
|
||||||
public class QQBot {
|
public class QQBot {
|
||||||
@RequestMapping("test.do")
|
@RequestMapping("/qq/bot/test.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String test(){
|
public String test(){
|
||||||
return "123";
|
return "123";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("send.do")
|
@RequestMapping("/qq/bot/send.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String send(String msg,String imgUrl){
|
public String send(String msg,String imgUrl){
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json=new JSONObject();
|
||||||
@ -55,7 +54,7 @@ public class QQBot {
|
|||||||
}
|
}
|
||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
@RequestMapping("sendAndImg.do")
|
@RequestMapping("/qq/bot/sendAndImg.do")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String botMsg(String msg,@RequestParam("file") MultipartFile file){
|
public String botMsg(String msg,@RequestParam("file") MultipartFile file){
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json=new JSONObject();
|
||||||
|
@ -18,7 +18,6 @@ import javax.annotation.Resource;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("anim/")
|
|
||||||
public class AnimationController {
|
public class AnimationController {
|
||||||
@Resource
|
@Resource
|
||||||
BangumiListDao listDao;
|
BangumiListDao listDao;
|
||||||
@ -26,7 +25,7 @@ public class AnimationController {
|
|||||||
BangumiItemDao itemDao;
|
BangumiItemDao itemDao;
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "rss/data.do", method = RequestMethod.GET)
|
@RequestMapping(value = "/anim/rss/data.do", method = RequestMethod.GET)
|
||||||
public String getAnimList(String key,String type,String team, int page) {
|
public String getAnimList(String key,String type,String team, int page) {
|
||||||
boolean isNull = key.length() == 0;
|
boolean isNull = key.length() == 0;
|
||||||
if(!StringUtils.isEmpty(type)&&type.length()>2)
|
if(!StringUtils.isEmpty(type)&&type.length()>2)
|
||||||
@ -50,7 +49,7 @@ public class AnimationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "type/add.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/anim/type/add.do", method = RequestMethod.POST)
|
||||||
public String addRssType(String title) {
|
public String addRssType(String title) {
|
||||||
BangumiList bangumiList = new BangumiList();
|
BangumiList bangumiList = new BangumiList();
|
||||||
bangumiList.setTitle(title);
|
bangumiList.setTitle(title);
|
||||||
@ -63,7 +62,7 @@ public class AnimationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "type/list.do", method = RequestMethod.GET)
|
@RequestMapping(value = "/anim/type/list.do", method = RequestMethod.GET)
|
||||||
public String getRssTypeList() {
|
public String getRssTypeList() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
@ -72,7 +71,7 @@ public class AnimationController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "type/del.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/anim/type/del.do", method = RequestMethod.POST)
|
||||||
public String delType(int id){
|
public String delType(int id){
|
||||||
BangumiItemExample example=new BangumiItemExample();
|
BangumiItemExample example=new BangumiItemExample();
|
||||||
example.createCriteria().andBidEqualTo(id+"");
|
example.createCriteria().andBidEqualTo(id+"");
|
||||||
@ -85,7 +84,7 @@ public class AnimationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "rss/add.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/anim/rss/add.do", method = RequestMethod.POST)
|
||||||
public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) {
|
public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) {
|
||||||
BangumiItem item = new BangumiItem();
|
BangumiItem item = new BangumiItem();
|
||||||
item.setTitle(title);
|
item.setTitle(title);
|
||||||
@ -101,7 +100,7 @@ public class AnimationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "rss/list.do", method = RequestMethod.GET)
|
@RequestMapping(value = "/anim/rss/list.do", method = RequestMethod.GET)
|
||||||
public String getAnimationRssList(String type) {
|
public String getAnimationRssList(String type) {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
BangumiItemExample example=new BangumiItemExample();
|
BangumiItemExample example=new BangumiItemExample();
|
||||||
@ -112,7 +111,7 @@ public class AnimationController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "rss/del.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/anim/rss/del.do", method = RequestMethod.POST)
|
||||||
public String delAnimation(int id){
|
public String delAnimation(int id){
|
||||||
int i=itemDao.deleteByPrimaryKey(id);
|
int i=itemDao.deleteByPrimaryKey(id);
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json=new JSONObject();
|
||||||
@ -121,7 +120,7 @@ public class AnimationController {
|
|||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
}
|
}
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "client/get.do", method = RequestMethod.GET)
|
@RequestMapping(value = "/anim/client/get.do", method = RequestMethod.GET)
|
||||||
public String clientApi(){
|
public String clientApi(){
|
||||||
AnimationData animationData=new AnimationData();
|
AnimationData animationData=new AnimationData();
|
||||||
List<BangumiItem> list=itemDao.selectByExample(new BangumiItemExample());
|
List<BangumiItem> list=itemDao.selectByExample(new BangumiItemExample());
|
||||||
|
15
src/main/java/com/yutou/nas/other/TestMain.java
Normal file
15
src/main/java/com/yutou/nas/other/TestMain.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.yutou.nas.other;
|
||||||
|
|
||||||
|
import com.yutou.nas.utils.AppTools;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TestMain {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<String> urls=AppTools.getUrls("com.yutou.nas",null);
|
||||||
|
|
||||||
|
for (String url : urls) {
|
||||||
|
System.out.println(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,10 +3,19 @@ package com.yutou.nas.other;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.yutou.nas.NasApplication;
|
import com.yutou.nas.NasApplication;
|
||||||
|
import com.yutou.nas.utils.AppTools;
|
||||||
import com.yutou.nas.utils.DepotManager;
|
import com.yutou.nas.utils.DepotManager;
|
||||||
import com.yutou.nas.utils.RedisTools;
|
import com.yutou.nas.utils.RedisTools;
|
||||||
import com.yutou.nas.utils.Tools;
|
import com.yutou.nas.utils.Tools;
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||||
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||||
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
|
import org.springframework.core.type.classreading.MetadataReader;
|
||||||
|
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||||
|
import org.springframework.core.type.filter.TypeFilter;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@ -16,7 +25,9 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.util.Enumeration;
|
import java.io.IOException;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class tools {
|
public class tools {
|
||||||
@ -124,5 +135,16 @@ public class tools {
|
|||||||
DepotManager.scan();
|
DepotManager.scan();
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/public/test.do")
|
||||||
|
public String test(){
|
||||||
|
List<Class> list= AppTools.scanClass("com.yutou.nas",Controller.class);
|
||||||
|
System.out.println("list size = "+list.size());
|
||||||
|
for (Class aClass : list) {
|
||||||
|
System.out.println(aClass.getName());
|
||||||
|
System.out.println(aClass.getAnnotation(RequestMapping.class));
|
||||||
|
}
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
package com.yutou.nas.utils;
|
package com.yutou.nas.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||||
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
|
import org.springframework.core.type.filter.TypeFilter;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.yutou.nas.utils.RedisTools.processOut;
|
import static com.yutou.nas.utils.RedisTools.processOut;
|
||||||
|
|
||||||
@ -39,4 +49,54 @@ public class AppTools {
|
|||||||
public static boolean isRuntimeSystemOfWindow() {
|
public static boolean isRuntimeSystemOfWindow() {
|
||||||
return System.getProperty("os.name").contains("Windows");
|
return System.getProperty("os.name").contains("Windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Class> scanClass(String classPath, Class<? extends Annotation> annotation) {
|
||||||
|
List<Class> classList = new ArrayList<>();
|
||||||
|
if (ObjectUtils.isEmpty(classPath)) {
|
||||||
|
return classList;
|
||||||
|
}
|
||||||
|
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
|
||||||
|
TypeFilter includeFilter = (metadataReader, metadataReaderFactory) -> true;
|
||||||
|
provider.addIncludeFilter(includeFilter);
|
||||||
|
Set<BeanDefinition> beanDefinitionSet = new HashSet<>();
|
||||||
|
// 指定扫描的包名
|
||||||
|
Set<BeanDefinition> candidateComponents = provider.findCandidateComponents(classPath);
|
||||||
|
beanDefinitionSet.addAll(candidateComponents);
|
||||||
|
|
||||||
|
beanDefinitionSet.forEach(beanDefinition -> {
|
||||||
|
try {
|
||||||
|
Class clazz = Class.forName(beanDefinition.getBeanClassName());
|
||||||
|
|
||||||
|
if (!ObjectUtils.isEmpty(annotation)) {
|
||||||
|
if (!ObjectUtils.isEmpty(AnnotationUtils.getAnnotation(clazz, annotation))) {
|
||||||
|
classList.add(clazz);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
classList.add(clazz);
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// System.out.println(definition.getBeanClassName());
|
||||||
|
});
|
||||||
|
return classList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getUrls(String packageName,String className){
|
||||||
|
List<Class> list= AppTools.scanClass(packageName, Controller.class);
|
||||||
|
List<String> urls=new ArrayList<>();
|
||||||
|
for (Class aClass : list) {
|
||||||
|
if(className!=null&&!aClass.getSimpleName().equals(className)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Method[] methods= aClass.getDeclaredMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
RequestMapping ls=method.getAnnotation(RequestMapping.class);
|
||||||
|
if(ls!=null) {
|
||||||
|
urls.add(ls.value()[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user