Former-commit-id: 2defdd8ea98e70df13b0c6ebd251b74ed86a7d64
master
wangbing 5 years ago
parent 0ee5c36cb8
commit ff278a6d78

@ -1,9 +1,5 @@
package xyz.wbsite.dbtool.javafx.ctrl; package xyz.wbsite.dbtool.javafx.ctrl;
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell;
import xyz.wbsite.dbtool.javafx.po.Api;
import xyz.wbsite.dbtool.javafx.tool.Dialog;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
@ -15,6 +11,12 @@ import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback; import javafx.util.Callback;
import javafx.util.converter.DefaultStringConverter; import javafx.util.converter.DefaultStringConverter;
import xyz.wbsite.dbtool.javafx.po.Api;
import xyz.wbsite.dbtool.javafx.po.ApiMethod;
import xyz.wbsite.dbtool.javafx.tool.ApiClassReader;
import xyz.wbsite.dbtool.javafx.tool.Dialog;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -39,8 +41,6 @@ public class OptionApiController {
@FXML @FXML
private CheckBox All; private CheckBox All;
@FXML @FXML
private CheckBox api;
@FXML
private CheckBox create; private CheckBox create;
@FXML @FXML
private CheckBox delete; private CheckBox delete;
@ -99,14 +99,6 @@ public class OptionApiController {
return create; return create;
} }
public CheckBox getApi() {
return api;
}
public void setApi(CheckBox api) {
this.api = api;
}
public void setCreate(CheckBox create) { public void setCreate(CheckBox create) {
this.create = create; this.create = create;
} }
@ -196,115 +188,84 @@ public class OptionApiController {
} }
private static File find(File file, String name) {
if (file == null) {
return null;
} else if (file.equals(name)) {
return file;
}
if (file.listFiles() != null) {
for (File f : file.listFiles()) {
return find(f, name);
}
}
return null;
}
public void load() { public void load() {
File moduleFile = new File(modulePath.getText()); File moduleFile = new File(modulePath.getText());
data.clear(); data.clear();
if (moduleFile.exists()) { if (moduleFile.exists()) {
File apiPath = find(moduleFile, "api"); List<File> apiPath = Tool.find(moduleFile, "api");
if (apiPath.size() == 0) {
return;
}
for (File file : apiPath.listFiles()) { Dialog.showProgress("扫描API...");
for (File file : apiPath.get(0).listFiles()) {
String module = file.getName(); String module = file.getName();
for (File tar : file.listFiles()) { for (File tar : file.listFiles()) {
String target = tar.getName().replaceAll("Api", ""); try {
String target = tar.getName().replaceAll("Api", "").replaceAll(".java", "");
ApiClassReader apiClassReader = new ApiClassReader(tar);
for (ApiMethod apiMethod : apiClassReader.getMethodList()) {
Api api = new Api(); Api api = new Api();
api.setModule(module); api.setModule(module);
api.setTarget(target); api.setTarget(target);
api.setRequest(apiMethod.getRequest());
} api.setResponse(apiMethod.getResponse());
} api.setMethod(apiMethod.getMethod());
File reqs = new File(moduleFile, "req"); List<File> reqFiles = Tool.find(moduleFile, apiMethod.getRequest() + ".java");
if (reqFiles.size() == 0) {
if (!reqs.exists()) { api.setError(api.getError() + "未找到请求");
return; } else if (reqFiles.size() > 1) {
} api.setError(api.getError() + "找到多个请求");
} else {
Dialog.showProgress("扫描API..."); api.setRequestFile(reqFiles.get(0));
for (File req : reqs.listFiles()) {
Api api = new Api();
api.setReq(req);
api.setTargetRequest(req.getName().replace(".java", ""));
//查找依赖ent //查找依赖ent
List<String> entities = findEntities(req); List<String> entities = findEntities(reqFiles.get(0));
for (String entity : entities) { for (String entity : entities) {
api.getDepEnt().add(entity); api.getDepEnt().add(entity);
} }
//查找依赖req //查找依赖req
List<String> reqss = findReq(req); List<String> reqss = findReq(reqFiles.get(0));
for (String string : reqss) { for (String string : reqss) {
api.getDepReq().add(string); api.getDepReq().add(string);
} }
}
//找response List<File> rspfiles = Tool.find(moduleFile, apiMethod.getResponse() + ".java");
File rsp = new File(moduleFile.getAbsolutePath() + File.separator + "rsp" + File.separator + req.getName().replace("Request", "Response")); if (rspfiles.size() == 0) {
if (rsp.exists()) { api.setError(api.getError() + "未找到响应");
api.setRsp(rsp); } else if (rspfiles.size() > 1) {
api.setTargetResponse(rsp.getName().replace(".java", "")); api.setError(api.getError() + "找到多个响应");
} else {
api.setResponseFile(rspfiles.get(0));
//查找依赖ent //查找依赖ent
List<String> entities_ = findEntities(rsp); List<String> entities = findEntities(rspfiles.get(0));
for (String entity : entities_) { for (String entity : entities) {
api.getDepEnt().add(entity); api.getDepEnt().add(entity);
} }
//查找依赖req //查找依赖req
List<String> reqss_ = findReq(rsp); List<String> reqss = findReq(rspfiles.get(0));
for (String string : reqss_) { for (String string : reqss) {
api.getDepReq().add(string); api.getDepReq().add(string);
} }
} }
// api.setMethod(module + "." + Tool.camelToPoint(req.getName().replaceAll("Request\\.java", "")));
if (api.getTargetRequest().startsWith("Api")) {
api.setCheck(true); api.setCheck(true);
} else { data.add(api);
api.setCheck(false);
}
if (api.getRsp() == null || !api.getRsp().exists()) {
api.setError("响应不存在");
api.setCheck(false);
}
for (String s : api.getDepReq()) {
File en = new File(moduleFile.getAbsolutePath() + File.separator + "req" + File.separator + s + ".java");
if (!en.exists()) {
api.setError("依赖的" + s + "(Request)不存在、");
api.setCheck(false);
} }
} catch (IOException e) {
e.printStackTrace();
} }
for (String s : api.getDepEnt()) {
File en = new File(moduleFile.getAbsolutePath() + File.separator + "ent" + File.separator + s + ".java");
if (!en.exists()) {
api.setError("依赖的" + s + "(Entity)不存在、");
api.setCheck(false);
} }
} }
data.add(api);
initData(); initData();
}
Dialog.stopPopup(); Dialog.stopPopup();
} }
} }
@ -340,37 +301,6 @@ public class OptionApiController {
return strings; return strings;
} }
public List<String> findEnums(File file) {
ArrayList<String> strings = new ArrayList<>();
InputStreamReader read = null;//考虑到编码格式
try {
read = new InputStreamReader(new FileInputStream(file), "UTF-8");
BufferedReader bufferedReader = new BufferedReader(read);
String line = null;
while ((line = bufferedReader.readLine()) != null) {
//指定字符串判断处
if (line.contains(".enums.")) {
Pattern compile = Pattern.compile(".*\\.enums\\.(.*);");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
String group = matcher.group(1);
strings.add(group);
// System.out.println(group);
}
}
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return strings;
}
public List<String> findReq(File file) { public List<String> findReq(File file) {
ArrayList<String> strings = new ArrayList<>(); ArrayList<String> strings = new ArrayList<>();
InputStreamReader read = null;//考虑到编码格式 InputStreamReader read = null;//考虑到编码格式
@ -428,7 +358,6 @@ public class OptionApiController {
return strings; return strings;
} }
public void initData() { public void initData() {
apis.setEditable(true); apis.setEditable(true);
apis.setSortPolicy(new Callback<TableView, Boolean>() { apis.setSortPolicy(new Callback<TableView, Boolean>() {
@ -448,11 +377,6 @@ public class OptionApiController {
@Override @Override
public ObservableValue<Boolean> call(Integer param) { public ObservableValue<Boolean> call(Integer param) {
super.call(param); super.call(param);
// if (data.get(param).isCheck()) {
// checkBoxTableCell.setInvalid(true);
// } else {
// checkBoxTableCell.setInvalid(false);
// }
if (data.get(param).isCheck()) { if (data.get(param).isCheck()) {
return new SimpleBooleanProperty(true); return new SimpleBooleanProperty(true);
} else { } else {
@ -472,19 +396,10 @@ public class OptionApiController {
return checkBoxTableCell; return checkBoxTableCell;
} }
}); });
columns.get(1).setCellValueFactory(new PropertyValueFactory("error")); columns.get(1).setCellValueFactory(new PropertyValueFactory("target"));
columns.get(1).setCellFactory(new Callback<TableColumn, TableCell>() { columns.get(1).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override @Override
public TableCell call(TableColumn param) { public TableCell call(TableColumn param) {
// param.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent>() {
// @Override
// public void handle(TableColumn.CellEditEvent event) {
// int row = event.getTablePosition().getRow();
// Api api = data.get(row);
// api.setReqName((String) event.getNewValue());
// }
// });
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) { TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
@Override @Override
public void updateItem(Object item, boolean empty) { public void updateItem(Object item, boolean empty) {
@ -496,19 +411,10 @@ public class OptionApiController {
return textFieldTableCell; return textFieldTableCell;
} }
}); });
columns.get(2).setCellValueFactory(new PropertyValueFactory("method"));
columns.get(2).setCellValueFactory(new PropertyValueFactory("targetRequest"));
columns.get(2).setCellFactory(new Callback<TableColumn, TableCell>() { columns.get(2).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override @Override
public TableCell call(TableColumn param) { public TableCell call(TableColumn param) {
// param.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent>() {
// @Override
// public void handle(TableColumn.CellEditEvent event) {
// int row = event.getTablePosition().getRow();
// Api api = data.get(row);
// api.setTargetRequest((String) event.getNewValue());
// }
// });
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) { TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
@Override @Override
public void updateItem(Object item, boolean empty) { public void updateItem(Object item, boolean empty) {
@ -519,18 +425,10 @@ public class OptionApiController {
return textFieldTableCell; return textFieldTableCell;
} }
}); });
columns.get(3).setCellValueFactory(new PropertyValueFactory("targetResponse")); columns.get(3).setCellValueFactory(new PropertyValueFactory("error"));
columns.get(3).setCellFactory(new Callback<TableColumn, TableCell>() { columns.get(3).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override @Override
public TableCell call(TableColumn param) { public TableCell call(TableColumn param) {
// param.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent>() {
// @Override
// public void handle(TableColumn.CellEditEvent event) {
// int row = event.getTablePosition().getRow();
// Api api = data.get(row);
// api.setTargetResponse((String) event.getNewValue());
// }
// });
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) { TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
@Override @Override
public void updateItem(Object item, boolean empty) { public void updateItem(Object item, boolean empty) {
@ -541,8 +439,7 @@ public class OptionApiController {
return textFieldTableCell; return textFieldTableCell;
} }
}); });
columns.get(4).setCellValueFactory(new PropertyValueFactory("request"));
columns.get(4).setCellValueFactory(new PropertyValueFactory("method"));
columns.get(4).setCellFactory(new Callback<TableColumn, TableCell>() { columns.get(4).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override @Override
public TableCell call(TableColumn param) { public TableCell call(TableColumn param) {
@ -556,6 +453,20 @@ public class OptionApiController {
return textFieldTableCell; return textFieldTableCell;
} }
}); });
columns.get(5).setCellValueFactory(new PropertyValueFactory("response"));
columns.get(5).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn param) {
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
@Override
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
}
};
textFieldTableCell.setEditable(false);
return textFieldTableCell;
}
});
ObservableList<Api> ObservableList = FXCollections.observableArrayList(); ObservableList<Api> ObservableList = FXCollections.observableArrayList();
ObservableList.addAll(data); ObservableList.addAll(data);
apis.setItems(ObservableList); apis.setItems(ObservableList);

@ -278,11 +278,7 @@ public class ProjectManager {
@Override @Override
public void run() { public void run() {
boolean mkdirs = api.mkdirs(); boolean mkdirs = api.mkdirs();
File reqList = new File(module, "req"); ApiCallable apiCallable = new ApiCallable(module,api, apis);
File rspList = new File(module, "rsp");
File entList = new File(module, "ent");
File enumsList = new File(module, "enums");
ApiCallable apiCallable = new ApiCallable(api, reqList, rspList, entList, enumsList, apis);
Future submit = service.submit(apiCallable); Future submit = service.submit(apiCallable);
try { try {
Boolean b = (Boolean) submit.get(); Boolean b = (Boolean) submit.get();

@ -1,12 +1,11 @@
package xyz.wbsite.dbtool.javafx.manger.callable; package xyz.wbsite.dbtool.javafx.manger.callable;
import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager; import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory; import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper; import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper;
import xyz.wbsite.dbtool.javafx.po.Api; import xyz.wbsite.dbtool.javafx.po.Api;
import xyz.wbsite.dbtool.javafx.tool.JavaClassReader; import xyz.wbsite.dbtool.javafx.tool.JavaClassReader;
import xyz.wbsite.dbtool.javafx.tool.JavaEnumReader;
import xyz.wbsite.dbtool.javafx.tool.Tool; import xyz.wbsite.dbtool.javafx.tool.Tool;
import java.io.File; import java.io.File;
@ -16,55 +15,45 @@ import java.util.concurrent.Callable;
public class ApiCallable implements Callable { public class ApiCallable implements Callable {
private File api; private File module;
private File req; private File apiFile;
private File rsp;
private File ent;
private List<Api> apiList; private List<Api> apiList;
private Tool tool = new Tool(); private Tool tool = new Tool();
private FreeMarkerManager freeMarkerManager; private FreeMarkerManager freeMarkerManager;
public ApiCallable(File api, File req, File rsp, File ent, File enums, List<Api> apiList) { public ApiCallable(File module, File apiFile, List<Api> apiList) {
this.api = api; this.module = module;
this.req = req; this.apiFile = apiFile;
this.rsp = rsp;
this.ent = ent;
this.apiList = apiList; this.apiList = apiList;
this.freeMarkerManager = ManagerFactory.getFreeMarkerManager(); this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
} }
private AbstractDBmapper dBmapper;
public Boolean call() throws Exception { public Boolean call() throws Exception {
if (!api.exists()) { if (!apiFile.exists()) {
api.mkdir(); apiFile.mkdir();
} else { } else {
Tool.clear(api); Tool.clear(apiFile);
} }
dBmapper = ProjectManager.dBmapper; AbstractDBmapper dBmapper = ProjectManager.dBmapper;
File domain; File domain;
File testdomain; File testdomain;
File request;
File response;
File entity;
File enumeration;
StringBuffer sbmain = new StringBuffer(""); StringBuffer sbmain = new StringBuffer("");
sbmain.append(this.api.getPath() + File.separator); sbmain.append(this.apiFile.getPath() + File.separator);
sbmain.append("src" + File.separator); sbmain.append("src" + File.separator);
sbmain.append("main" + File.separator); sbmain.append("main" + File.separator);
sbmain.append("java" + File.separator); sbmain.append("java" + File.separator);
StringBuffer sbtest = new StringBuffer(""); StringBuffer sbtest = new StringBuffer("");
sbtest.append(this.api.getPath() + File.separator); sbtest.append(this.apiFile.getPath() + File.separator);
sbtest.append("src" + File.separator); sbtest.append("src" + File.separator);
sbtest.append("test" + File.separator); sbtest.append("test" + File.separator);
sbtest.append("java" + File.separator); sbtest.append("java" + File.separator);
JavaClassReader javaClass = new JavaClassReader(apiList.get(0).getReq()); JavaClassReader javaClass = new JavaClassReader(apiList.get(0).getRequestFile());
String[] split = javaClass.getDomainName().split("\\."); String[] split = javaClass.getDomainName().split("\\.");
for (String s1 : split) { for (String s1 : split) {
@ -76,37 +65,26 @@ public class ApiCallable implements Callable {
domain.mkdirs(); domain.mkdirs();
testdomain = new File(sbtest.toString()); testdomain = new File(sbtest.toString());
testdomain.mkdirs(); testdomain.mkdirs();
request = new File(domain, "request");
for (Api api : apiList) {
if (api.isCheck()) {
File module = new File(domain, api.getModule());
module.mkdirs();
File request = new File(module, "req");
request.mkdirs(); request.mkdirs();
response = new File(domain, "response"); File response = new File(module, "rsp");
response.mkdirs(); response.mkdirs();
entity = new File(domain, "entity"); File entity = new File(module, "ent");
entity.mkdirs(); entity.mkdirs();
enumeration = new File(domain, "enums");
enumeration.mkdirs();
{
System.out.println("生成模块:Pom");
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("api", api.getName());
File file = new File(api, "pom.xml");
freeMarkerManager.outputTemp(file, "Java_api/pom.xml", ctx);
}
Set<String> managerList = new HashSet<>();
List<Method> methodList = new ArrayList<>();
for (Api api : apiList) {
if (api.isCheck()) {
try { try {
//region 生成request //region 生成request
JavaClassReader javaClassReader = new JavaClassReader(api.getReq()); JavaClassReader javaClassReader = new JavaClassReader(api.getRequestFile());
for (int i = 0; i < javaClassReader.getImportList().size(); i++) { for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
String s = javaClassReader.getImportList().get(i); String s = javaClassReader.getImportList().get(i);
if (s.contains(".api.entity.")) { if (s.contains(".module.entity.")) {
javaClassReader.getImportList().set(i, s.replaceAll("\\.api\\.entity\\.", ".entity.")); javaClassReader.getImportList().set(i, s);
} }
} }
@ -116,15 +94,14 @@ public class ApiCallable implements Callable {
method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName())); method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName()));
method.setMethod(Tool.getRequestAction(javaClassReader.getClassName())); method.setMethod(Tool.getRequestAction(javaClassReader.getClassName()));
method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager"); method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager");
methodList.add(method);
managerList.add(method.getManager());
{ {
HashMap<String, Object> ctx = new HashMap<String, Object>(); HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;"); ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
ctx.put("domain", javaClassReader.getDomainName()); ctx.put("domain", javaClassReader.getDomainName());
ctx.put("module", javaClassReader.getModuleName()); ctx.put("module", javaClassReader.getModuleName());
ctx.put("target", api.getTarget());
ctx.put("method", api.getMethod());
ctx.put("importList", javaClassReader.getImportList()); ctx.put("importList", javaClassReader.getImportList());
ctx.put("annotation", javaClassReader.getAnnotationList()); ctx.put("annotation", javaClassReader.getAnnotationList());
ctx.put("className", javaClassReader.getClassName().replaceAll("Request", "")); ctx.put("className", javaClassReader.getClassName().replaceAll("Request", ""));
@ -132,9 +109,9 @@ public class ApiCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList()); ctx.put("hasList", javaClassReader.isHasList());
ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag()); ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
File file = new File(request.getAbsolutePath(), api.getReq().getName()); File file = new File(request.getAbsolutePath(), api.getRequestFile().getName());
freeMarkerManager.outputTemp(file, "Java_api/module/request/request.java", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/req/request.java", ctx);
System.out.println("生成文件" + file.getName() + "成功"); System.out.println("生成文件" + file.getName() + "成功");
} }
//endregion //endregion
@ -145,11 +122,11 @@ public class ApiCallable implements Callable {
try { try {
//region 生成response //region 生成response
JavaClassReader javaClassReader = new JavaClassReader(api.getRsp()); JavaClassReader javaClassReader = new JavaClassReader(api.getResponseFile());
for (int i = 0; i < javaClassReader.getImportList().size(); i++) { for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
String import_ = javaClassReader.getImportList().get(i); String import_ = javaClassReader.getImportList().get(i);
if (import_.contains(".api.entity.")) { if (import_.contains(".module.entity.")) {
javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity.")); javaClassReader.getImportList().set(i, import_);
} }
} }
@ -165,132 +142,141 @@ public class ApiCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList()); ctx.put("hasList", javaClassReader.isHasList());
ctx.put("Tclass", javaClassReader.getTclass()); ctx.put("Tclass", javaClassReader.getTclass());
File file = new File(response.getAbsolutePath(), api.getRsp().getName().replaceAll("Request", "Response")); File file = new File(response.getAbsolutePath(), api.getResponseFile().getName().replaceAll("Request", "Response"));
freeMarkerManager.outputTemp(file, "Java_api/module/response/response.java", ctx);
System.out.println("生成文件" + api.getRsp().getName() + "成功");
}
//endregion
} catch (IOException e) {
e.printStackTrace();
}
for (String s : api.getDepReq()) {
try {
File f = new File(req.getAbsolutePath(), s + ".java");
if (!f.exists()) {
System.err.println("文件" + f.getAbsolutePath() + "不存在");
continue;
}
JavaClassReader javaClassReader = new JavaClassReader(f);
for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
String import_ = javaClassReader.getImportList().get(i);
if (import_.contains(".api.entity.")) {
javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity."));
}
}
Method method = new Method(); freeMarkerManager.outputTemp(file, "Java_api/module/rsp/response.java", ctx);
method.setStringMethod(api.getMethod()); System.out.println("生成文件" + api.getResponseFile().getName() + "成功");
method.setRequest(javaClassReader.getClassName());
method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName()));
method.setMethod(Tool.getRequestAction(javaClassReader.getClassName()));
method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager");
{
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
ctx.put("domain", javaClassReader.getDomainName());
ctx.put("module", javaClassReader.getModuleName());
ctx.put("importList", javaClassReader.getImportList());
ctx.put("annotation", javaClassReader.getAnnotationList());
ctx.put("className", javaClassReader.getClassName().replaceAll("Request", ""));
ctx.put("body", javaClassReader.getBody());
ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList());
ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
File file = new File(request.getAbsolutePath(), f.getName());
freeMarkerManager.outputTemp(file, "Java_api/module/request/request.java", ctx);
System.out.println("生成文件" + file.getName() + "成功");
} }
//endregion //endregion
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { // for (String s : api.getDepReq()) {
File f = new File(rsp.getAbsolutePath(), s.replaceAll("Request", "Response.java")); // try {
if (!f.exists()) { // File f = new File(apiFile.getAbsolutePath(), s + ".java");
System.err.println("文件" + f.getAbsolutePath() + "不存在"); // if (!f.exists()) {
} // System.err.println("文件" + f.getAbsolutePath() + "不存在");
JavaClassReader javaClassReader = new JavaClassReader(f); // continue;
for (int i = 0; i < javaClassReader.getImportList().size(); i++) { // }
String import_ = javaClassReader.getImportList().get(i); // JavaClassReader javaClassReader = new JavaClassReader(f);
if (import_.contains(".api.entity.")) { // for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity.")); // String import_ = javaClassReader.getImportList().get(i);
} // if (import_.contains(".module.entity.")) {
} // javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity."));
// }
{ // }
HashMap<String, Object> ctx = new HashMap<String, Object>(); //
ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;"); // Method method = new Method();
ctx.put("domain", javaClassReader.getDomainName()); // method.setStringMethod(api.getMethod());
ctx.put("module", javaClassReader.getModuleName()); // method.setRequest(javaClassReader.getClassName());
ctx.put("importList", javaClassReader.getImportList()); // method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName()));
ctx.put("annotation", javaClassReader.getAnnotationList()); // method.setMethod(Tool.getRequestAction(javaClassReader.getClassName()));
ctx.put("className", javaClassReader.getClassName().replaceAll("Response", "")); // method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager");
ctx.put("body", javaClassReader.getBody()); //
ctx.put("tool", tool); // {
ctx.put("hasList", javaClassReader.isHasList()); // HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("Tclass", javaClassReader.getTclass()); // ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
File file = new File(response.getAbsolutePath(), f.getName()); // ctx.put("domain", javaClassReader.getDomainName());
// ctx.put("module", javaClassReader.getModuleName());
freeMarkerManager.outputTemp(file, "Java_api/module/response/response.java", ctx); // ctx.put("importList", javaClassReader.getImportList());
System.out.println("生成文件" + api.getRsp().getName() + "成功"); // ctx.put("annotation", javaClassReader.getAnnotationList());
} // ctx.put("className", javaClassReader.getClassName().replaceAll("Request", ""));
//endregion // ctx.put("body", javaClassReader.getBody());
} catch (IOException e) { // ctx.put("tool", tool);
e.printStackTrace(); // ctx.put("hasList", javaClassReader.isHasList());
// ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
// File file = new File(request.getAbsolutePath(), f.getName());
//
// freeMarkerManager.outputTemp(file, "Java_api/module/req/request.java", ctx);
// System.out.println("生成文件" + file.getName() + "成功");
// }
// //endregion
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// try {
// File f = new File(rsp.getAbsolutePath(), s.replaceAll("Request", "Response.java"));
// if (!f.exists()) {
// System.err.println("文件" + f.getAbsolutePath() + "不存在");
// }
// JavaClassReader javaClassReader = new JavaClassReader(f);
// for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
// String import_ = javaClassReader.getImportList().get(i);
// if (import_.contains(".module.entity.")) {
// javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity."));
// }
// }
//
// {
// HashMap<String, Object> ctx = new HashMap<String, Object>();
// ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
// ctx.put("domain", javaClassReader.getDomainName());
// ctx.put("module", javaClassReader.getModuleName());
// ctx.put("importList", javaClassReader.getImportList());
// ctx.put("annotation", javaClassReader.getAnnotationList());
// ctx.put("className", javaClassReader.getClassName().replaceAll("Response", ""));
// ctx.put("body", javaClassReader.getBody());
// ctx.put("tool", tool);
// ctx.put("hasList", javaClassReader.isHasList());
// ctx.put("Tclass", javaClassReader.getTclass());
// File file = new File(response.getAbsolutePath(), f.getName());
//
// freeMarkerManager.outputTemp(file, "Java_api/module/rsp/response.java", ctx);
// System.out.println("生成文件" + api.getResponseFile().getName() + "成功");
// }
// //endregion
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// for (String s : api.getDepEnt()) {
//
// try {
// File f = new File(ent.getAbsolutePath(), s + ".java");
// if (!f.exists()) {
// System.out.println("文件" + f.getAbsolutePath() + "不存在");
// continue;
// }
// JavaClassReader javaClassReader = new JavaClassReader(f);
// for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
// String import_ = javaClassReader.getImportList().get(i);
// if (import_.contains(".module.entity.")) {
// javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity."));
// }
// }
//
// {
// HashMap<String, Object> ctx = new HashMap<String, Object>();
// ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
// ctx.put("domain", javaClassReader.getDomainName());
// ctx.put("module", javaClassReader.getModuleName());
// ctx.put("importList", javaClassReader.getImportList());
// ctx.put("annotation", javaClassReader.getAnnotationList());
// ctx.put("className", javaClassReader.getClassName().replaceAll("Entity", ""));
// ctx.put("body", javaClassReader.getBody());
// ctx.put("tool", tool);
// File file = new File(entity.getAbsolutePath(), f.getName());
// freeMarkerManager.outputTemp(file, "Java_api/module/ent/entity.java", ctx);
// System.out.println("生成文件" + file.getName() + "成功");
// }
// //endregion
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
} }
} }
for (String s : api.getDepEnt()) {
try {
File f = new File(ent.getAbsolutePath(), s + ".java");
if (!f.exists()) {
System.out.println("文件" + f.getAbsolutePath() + "不存在");
continue;
}
JavaClassReader javaClassReader = new JavaClassReader(f);
for (int i = 0; i < javaClassReader.getImportList().size(); i++) {
String import_ = javaClassReader.getImportList().get(i);
if (import_.contains(".api.entity.")) {
javaClassReader.getImportList().set(i, import_.replaceAll("\\.api\\.entity\\.", ".entity."));
}
}
{ {
System.out.println("生成模块:Pom");
HashMap<String, Object> ctx = new HashMap<String, Object>(); HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;"); ctx.put("module", apiFile.getName());
ctx.put("domain", javaClassReader.getDomainName()); File file = new File(apiFile, "pom.xml");
ctx.put("module", javaClassReader.getModuleName()); freeMarkerManager.outputTemp(file, "Java_api/pom.xml", ctx);
ctx.put("importList", javaClassReader.getImportList());
ctx.put("annotation", javaClassReader.getAnnotationList());
ctx.put("className", javaClassReader.getClassName().replaceAll("Entity", ""));
ctx.put("body", javaClassReader.getBody());
ctx.put("tool", tool);
File file = new File(entity.getAbsolutePath(), f.getName());
freeMarkerManager.outputTemp(file, "Java_api/module/entity/entity.java", ctx);
System.out.println("生成文件" + file.getName() + "成功");
}
//endregion
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
{ {
@ -387,8 +373,6 @@ public class ApiCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("domain", javaClass.getDomainName()); ctx.put("domain", javaClass.getDomainName());
ctx.put("module", javaClass.getModuleName()); ctx.put("module", javaClass.getModuleName());
ctx.put("managerList", managerList);
ctx.put("methodList", methodList);
ctx.put("apiList", apiList); ctx.put("apiList", apiList);
freeMarkerManager.outputTemp(new File(testdomain.getAbsolutePath(), "ApiTest.java"), "Java_api/ApiTest.java", ctx); freeMarkerManager.outputTemp(new File(testdomain.getAbsolutePath(), "ApiTest.java"), "Java_api/ApiTest.java", ctx);
} }

@ -10,28 +10,20 @@ public class Api {
private boolean check; private boolean check;
//目标请求对象 //目标请求对象
private String targetRequest; private String request;
//目标请求响应 //目标请求响应
private String targetResponse; private String response;
private String module; private String module;
private String target; private String target;
private String method; private String method;
private File req; private File requestFile;
private File rsp; private File responseFile;
private Set<String> depReq = new HashSet<>(); private Set<String> depReq = new HashSet<>();
private Set<String> depEnt = new HashSet<>(); private Set<String> depEnt = new HashSet<>();
private String error; private String error = "";
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public boolean isCheck() { public boolean isCheck() {
return check; return check;
@ -41,20 +33,36 @@ public class Api {
this.check = check; this.check = check;
} }
public String getTargetRequest() { public String getRequest() {
return targetRequest; return request;
}
public void setRequest(String request) {
this.request = request;
} }
public void setTargetRequest(String targetRequest) { public String getResponse() {
this.targetRequest = targetRequest; return response;
}
public void setResponse(String response) {
this.response = response;
}
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
} }
public String getTargetResponse() { public String getTarget() {
return targetResponse; return target;
} }
public void setTargetResponse(String targetResponse) { public void setTarget(String target) {
this.targetResponse = targetResponse; this.target = target;
} }
public String getMethod() { public String getMethod() {
@ -65,20 +73,20 @@ public class Api {
this.method = method; this.method = method;
} }
public File getReq() { public File getRequestFile() {
return req; return requestFile;
} }
public void setReq(File req) { public void setRequestFile(File requestFile) {
this.req = req; this.requestFile = requestFile;
} }
public File getRsp() { public File getResponseFile() {
return rsp; return responseFile;
} }
public void setRsp(File rsp) { public void setResponseFile(File responseFile) {
this.rsp = rsp; this.responseFile = responseFile;
} }
public Set<String> getDepReq() { public Set<String> getDepReq() {
@ -97,19 +105,11 @@ public class Api {
this.depEnt = depEnt; this.depEnt = depEnt;
} }
public String getModule() { public String getError() {
return module; return error;
}
public void setModule(String module) {
this.module = module;
}
public String getTarget() {
return target;
} }
public void setTarget(String target) { public void setError(String error) {
this.target = target; this.error = error;
} }
} }

@ -0,0 +1,31 @@
package xyz.wbsite.dbtool.javafx.po;
public class ApiMethod {
private String request;
private String response;
private String method;
public String getRequest() {
return request;
}
public void setRequest(String request) {
this.request = request;
}
public String getResponse() {
return response;
}
public void setResponse(String response) {
this.response = response;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
}

@ -0,0 +1,63 @@
package xyz.wbsite.dbtool.javafx.tool;
import xyz.wbsite.dbtool.javafx.po.ApiMethod;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ApiClassReader {
private File javaClass;
private List<ApiMethod> methodList;
public ApiClassReader(File javaClass) throws IOException {
this.javaClass = javaClass;
methodList = new ArrayList<>();
read();
}
private void read() throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
String line = null;
Pattern compile = Pattern.compile("\\s+public (.*Response)\\s+(.*)\\((.*Request) request\\) \\{");
while ((line = bufferedReader.readLine()) != null) {
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
ApiMethod apiMethod = new ApiMethod();
apiMethod.setResponse(matcher.group(1));
apiMethod.setMethod(matcher.group(2));
apiMethod.setRequest(matcher.group(3));
methodList.add(apiMethod);
}
}
bufferedReader.close();
}
public File getJavaClass() {
return javaClass;
}
public void setJavaClass(File javaClass) {
this.javaClass = javaClass;
}
public List<ApiMethod> getMethodList() {
return methodList;
}
public void setMethodList(List<ApiMethod> methodList) {
this.methodList = methodList;
}
public static void main(String[] args) throws IOException {
ApiClassReader javaClassReader = new ApiClassReader(new File("D:\\wangbing\\Project\\dbtool\\target\\project\\EXAMPLE-WEB\\src\\main\\java\\com\\example\\action\\api\\system\\DictApi.java"));
System.out.println();
}
}

@ -444,12 +444,6 @@ public class Dialog {
check(controller, controller.getAll().isSelected(), ""); check(controller, controller.getAll().isSelected(), "");
} }
}); });
controller.getApi().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
check(controller, controller.getApi().isSelected(), ".api.");
}
});
controller.getCreate().setOnAction(new EventHandler<ActionEvent>() { controller.getCreate().setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
@ -701,24 +695,11 @@ public class Dialog {
controller.initData(); controller.initData();
} }
private static boolean hasChild(File file, String child) {
if (file == null || child == null || "".equals(child) || file.listFiles() == null) {
return false;
}
for (File f : file.listFiles()) {
if (f.getName().equals(child)) {
return true;
}
}
return false;
}
private static File findAction(File file) { private static File findAction(File file) {
if (file == null) { if (file == null) {
return null; return null;
} else if (hasChild(file, "action") && hasChild(file, "module")) { } else if (Tool.hasChild(file, "action") && Tool.hasChild(file, "module")) {
return file; return file;
} }

@ -58,9 +58,6 @@ public class JavaClassReader {
} }
if (line.startsWith("import")) { if (line.startsWith("import")) {
if (!line.contains("frame")) { if (!line.contains("frame")) {
if (line.contains(".ent.")) {
line = line.replaceAll("\\.ent\\.", ".entity.");
}
importList.add(line); importList.add(line);
} }

@ -2,6 +2,7 @@ package xyz.wbsite.dbtool.javafx.tool;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -346,6 +347,43 @@ public class Tool {
} }
} }
public static List<File> find(File file, String name) {
List<File> fileList = new ArrayList<>();
if (file != null) {
if (file.getName().equals("target") ||
file.getName().equals("classes") ||
file.getName().equals(".idea")) {
return fileList;
}
if (file.getName().equals(name)) {
fileList.add(file);
}
if (file.listFiles() != null) {
for (File f : file.listFiles()) {
fileList.addAll(find(f, name));
}
}
}
return fileList;
}
public static boolean hasChild(File file, String child) {
if (file == null || child == null || "".equals(child) || file.listFiles() == null) {
return false;
}
for (File f : file.listFiles()) {
if (f.getName().equals(child)) {
return true;
}
}
return false;
}
public static void exchange(List list, int i, int j) { public static void exchange(List list, int i, int j) {
Object o1 = list.get(i); Object o1 = list.get(i);
Object o2 = list.get(j); Object o2 = list.get(j);

@ -1,34 +0,0 @@
package xyz.wbsite.dbtool.web.frame.base;
public class FileUploadResponse extends BaseResponse {
private Long id;
private String url;
private String downloadUrl;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
}

@ -24,9 +24,11 @@
<Label text="生成路径" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"/> <Label text="生成路径" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"/>
<TextField GridPane.columnIndex="1" fx:id="modulePath" promptText="...\**\module\"/> <TextField GridPane.columnIndex="1" fx:id="modulePath" promptText="...\**\module\"/>
<TextField GridPane.columnIndex="1" fx:id="apiPath" GridPane.rowIndex="1"/> <TextField GridPane.columnIndex="1" fx:id="apiPath" GridPane.rowIndex="1"/>
<Button mnemonicParsing="false" fx:id="selectModulePath" text="选择路径" GridPane.columnIndex="2" GridPane.halignment="CENTER" <Button mnemonicParsing="false" fx:id="selectModulePath" text="选择路径" GridPane.columnIndex="2"
GridPane.halignment="CENTER"
GridPane.valignment="CENTER"/> GridPane.valignment="CENTER"/>
<Button mnemonicParsing="false" fx:id="selectApiPath" text="选择路径" GridPane.columnIndex="2" GridPane.halignment="CENTER" <Button mnemonicParsing="false" fx:id="selectApiPath" text="选择路径" GridPane.columnIndex="2"
GridPane.halignment="CENTER"
GridPane.rowIndex="1" GridPane.valignment="CENTER"/> GridPane.rowIndex="1" GridPane.valignment="CENTER"/>
</children> </children>
<opaqueInsets> <opaqueInsets>
@ -43,11 +45,12 @@
<center> <center>
<TableView fx:id="apis" prefHeight="270.0" prefWidth="700.0" BorderPane.alignment="CENTER"> <TableView fx:id="apis" prefHeight="270.0" prefWidth="700.0" BorderPane.alignment="CENTER">
<columns> <columns>
<TableColumn prefWidth="60.0" text="选择"/> <TableColumn prefWidth="30.0" text="选择"/>
<TableColumn prefWidth="140.0" text="错误"/> <TableColumn prefWidth="80.0" text="对象"/>
<TableColumn prefWidth="150.0" text="request"/> <TableColumn prefWidth="80.0" text="方法"/>
<TableColumn prefWidth="150.0" text="response"/> <TableColumn prefWidth="80.0" text="信息"/>
<TableColumn prefWidth="200.0" text="method"/> <TableColumn prefWidth="150.0" text="请求"/>
<TableColumn prefWidth="150.0" text="响应"/>
</columns> </columns>
</TableView> </TableView>
@ -57,8 +60,6 @@
<items> <items>
<CheckBox mnemonicParsing="false" fx:id="All" text="All" selected="false"> <CheckBox mnemonicParsing="false" fx:id="All" text="All" selected="false">
</CheckBox> </CheckBox>
<CheckBox mnemonicParsing="false" fx:id="api" text="api" selected="true">
</CheckBox>
<CheckBox mnemonicParsing="false" fx:id="create" text="create" selected="false"> <CheckBox mnemonicParsing="false" fx:id="create" text="create" selected="false">
</CheckBox> </CheckBox>
<CheckBox mnemonicParsing="false" fx:id="delete" text="delete" selected="false"> <CheckBox mnemonicParsing="false" fx:id="delete" text="delete" selected="false">

@ -50,9 +50,9 @@ public class ApiTest {
<#list apiList as item> <#list apiList as item>
@Test @Test
public void test${item.targetRequest}() { public void test${item.request}() {
${item.targetRequest} request = new ${item.targetRequest}(); ${item.request} request = new ${item.request}();
${item.targetResponse} response = apiClient.execute(request); ${item.response} response = apiClient.execute(request);
Assert.assertTrue(!response.hasError()); Assert.assertTrue(!response.hasError());
} }
</#list> </#list>

@ -1,4 +1,4 @@
package ${domain}.entity; package ${domain}.${module}.ent;
<#list importList as i> <#list importList as i>
${i} ${i}

@ -1,11 +1,11 @@
package ${domain}.request; package ${domain}.${module}.req;
<#list importList as i> <#list importList as i>
<#if !i?contains("javax.validation") && !i?contains("org.hibernate.validator")> <#if !i?contains("javax.validation") && !i?contains("org.hibernate.validator")>
${i} ${i}
</#if> </#if>
</#list> </#list>
import ${domain}.response.${className}Response; import ${domain}.${module}.rsp.${className}Response;
import ${domain}.ApiRequest; import ${domain}.ApiRequest;
<#if findOrSearchflag=='1'> <#if findOrSearchflag=='1'>
import ${domain}.ApiFindRequest; import ${domain}.ApiFindRequest;
@ -27,8 +27,8 @@ ${i}
} }
public String apiMethod() { public String path() {
return "${module}.${tool.camelToPoint(className)}"; return "${module}/${target}/${method}";
} }
public Class<${className}Response> responseClass() { public Class<${className}Response> responseClass() {

@ -1,4 +1,4 @@
package ${domain}.response; package ${domain}.${module}.rsp;
<#list importList as i> <#list importList as i>
${i} ${i}

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.wb</groupId> <groupId>com.wb</groupId>
<artifactId>${api}</artifactId> <artifactId>${module}</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>

@ -16,7 +16,7 @@ web.welcome.page=/index.htm
# 需要验证授权, 既访问时组装Token # 需要验证授权, 既访问时组装Token
web.url.auth.included=/** web.url.auth.included=/**
# 不需要验证授权, 或该请求有自己的验证机制 # 不需要验证授权, 或该请求有自己的验证机制
web.url.auth.excluded=/favicon.ico,/static/**,/api,/login.htm web.url.auth.excluded=/favicon.ico,/static/**,/module,/login.htm
# 日志配置 # 日志配置
logging.path=D:// logging.path=D://
logging.levels=DEBUG logging.levels=DEBUG

@ -39,7 +39,7 @@ public class Authorizations implements Filter {
String path = httpServletRequest.getServletPath(); String path = httpServletRequest.getServletPath();
//以下Api无需授权Api自己会处理 //以下Api无需授权Api自己会处理
if ("/api".equals(path)) { if ("/module".equals(path)) {
chain.doFilter(request, response); chain.doFilter(request, response);
return; return;
} }

@ -172,7 +172,7 @@
<!-- servlet --> <!-- servlet -->
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>servlet-module</artifactId>
<version>3.0-alpha-1</version> <version>3.0-alpha-1</version>
</dependency> </dependency>
@ -228,7 +228,7 @@
<!-- 日志依赖 --> <!-- 日志依赖 -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-module</artifactId>
<version>${r"${slf4j.version}"}</version> <version>${r"${slf4j.version}"}</version>
</dependency> </dependency>
<dependency> <dependency>

Loading…
Cancel
Save

Powered by TurnKey Linux.