package com.vci.web.controller; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.util.LangBaseUtil; import com.vci.web.service.impl.WebInitServiceImpl; import com.vci.web.util.OsScanAnnotationTool; import com.vci.web.util.WebUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; /** * 扫描表的控制器 * @author weidy * @date 2021/8/21 */ @RequestMapping("/scanAnnotationController") @RestController public class WebScanAnnotationController { /** * 扫描的工具 */ @Autowired private OsScanAnnotationTool scanAnnotationTool; /** * 初始化服务 */ @Autowired private WebInitServiceImpl initService; /** * 使用包名扫描注解 * @param packName 包名 * @return 执行结果 */ @PostMapping(value = "/scanAnnotation") public synchronized BaseResult scanAnnotation(String packName){ try { initService.clearAllCache(); initService.initServerCache(); List packageList = WebUtil.str2List(packName); List entityList = new ArrayList(); List unScanEntityList = new ArrayList(); scanAnnotationTool.doScanAnnotation2OSServer(packageList, entityList,unScanEntityList); initService.clearAllCache(); initService.initServerCache(); }catch (Throwable e){ return BaseResult.fail(LangBaseUtil.getErrorMsg(e)); } return BaseResult.success(); } }