diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java index 8d984e72..5d139afa 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java @@ -450,6 +450,12 @@ public class JavaFxApplication extends Application { currentProject.setMultiDB(newValue); } }); + detailProjectController.getSysMD().selectedProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + currentProject.setSysMD(newValue); + } + }); } {//初始化表面板 @@ -605,6 +611,7 @@ public class JavaFxApplication extends Application { detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage()); detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor()); detailProjectController.getMultiDB().setSelected(currentProject.getMultiDB()); + detailProjectController.getSysMD().setSelected(currentProject.getSysMD()); if (gridPane != null) { detail.getChildren().clear(); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java index 2ba9ea0d..fa7318b7 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java @@ -14,6 +14,16 @@ public class DetailProjectController { private TextField projectAuthor; @FXML private CheckBox multiDB; + @FXML + private CheckBox sysMD; + + public CheckBox getSysMD() { + return sysMD; + } + + public void setSysMD(CheckBox sysMD) { + this.sysMD = sysMD; + } public CheckBox getMultiDB() { return multiDB; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java index 8fc4f691..6bee96a7 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java @@ -64,6 +64,11 @@ public class XmlManager { project.setMultiDB(getBoolean(multiDB.item(0).getTextContent())); } + NodeList sysMD = dbElement.getElementsByTagName("sysMD"); + if (sysMD.getLength() == 1) { + project.setSysMD(getBoolean(sysMD.item(0).getTextContent())); + } + NodeList modules = dbElement.getElementsByTagName("module"); if (modules.getLength() > 0) { @@ -171,10 +176,13 @@ public class XmlManager { projectAuthor.setTextContent(project.getProjectAuthor()); Element multiDB = doc.createElement("multiDB"); multiDB.setTextContent(String.valueOf(project.getMultiDB())); + Element sysMD = doc.createElement("sysMD"); + sysMD.setTextContent(String.valueOf(project.getSysMD())); rootProject.appendChild(projectName); rootProject.appendChild(projectBasePackage); rootProject.appendChild(projectAuthor); rootProject.appendChild(multiDB); + rootProject.appendChild(sysMD); Element modules = doc.createElement("modules"); rootProject.appendChild(modules); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index bc716a7b..baac62e6 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -11,6 +11,7 @@ import xyz.wbsite.dbtool.javafx.po.Project; import xyz.wbsite.dbtool.javafx.po.Table; import xyz.wbsite.dbtool.javafx.tool.Tool; import xyz.wbsite.dbtool.web.frame.utils.FileUtil; +import xyz.wbsite.dbtool.web.frame.utils.ResourceUtil; import java.io.File; import java.io.IOException; @@ -100,7 +101,7 @@ public class SpringBootCallable implements Callable { generateResponse(Tool.createPath(moduleDir.getAbsolutePath(), "rsp"), module, dataBase, option); } - {// 生成System模块 + if (project.getSysMD()) {//生成系统模块 Module module = new Module(); module.setModuleName("system"); module.setProjectAuthor(project.getProjectAuthor()); @@ -158,7 +159,6 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "pom.xml"), option + "/pom.ftl", ctx); } - /** * 生成Controller类 * @@ -179,13 +179,6 @@ public class SpringBootCallable implements Callable { { File ajax = Tool.createPath(root.getAbsolutePath(), "ajax"); - File system = Tool.createPath(ajax.getAbsolutePath(), "system"); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "AuthAjax.java"), option + "/java/action/ajax/system/AuthAjax.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictAjax.java"), option + "/java/action/ajax/system/DictAjax.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictItemAjax.java"), option + "/java/action/ajax/system/DictItemAjax.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "FileAjax.java"), option + "/java/action/ajax/system/FileAjax.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ResourceAjax.java"), option + "/java/action/ajax/system/ResourceAjax.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "TokensAjax.java"), option + "/java/action/ajax/system/TokensAjax.java", ctx); for (Module module : project.getModules()) { File m = Tool.createPath(ajax.getAbsolutePath(), module.getModuleName()); @@ -201,21 +194,21 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(m.getAbsolutePath(), table.getCName() + "Ajax.java"), option + "/java/action/ajax/Ajax.java", ctxss); } } + + if (project.getSysMD()) {//生成系统模块 + File system = Tool.createPath(ajax.getAbsolutePath(), "system"); + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/action/ajax/system/")) { + freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), name), option + "/java/action/ajax/system/" + name, ctx); + } + } } { File api = Tool.createPath(root.getAbsolutePath(), "api"); - File system = Tool.createPath(api.getAbsolutePath(), "system"); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "AuthApi.java"), option + "/java/action/api/system/AuthApi.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictApi.java"), option + "/java/action/api/system/DictApi.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictItemApi.java"), option + "/java/action/api/system/DictItemApi.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "FileApi.java"), option + "/java/action/api/system/FileApi.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ResourceApi.java"), option + "/java/action/api/system/ResourceApi.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "TokensApi.java"), option + "/java/action/api/system/TokensApi.java", ctx); for (Module module : project.getModules()) { File m = Tool.createPath(api.getAbsolutePath(), module.getModuleName()); - m.mkdirs(); for (Table table : module.getTables()) { HashMap ctxss = new HashMap(); @@ -227,11 +220,17 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(m.getAbsolutePath(), table.getCName() + "Api.java"), option + "/java/action/api/Api.java", ctxss); } } + + if (project.getSysMD()) {//生成系统模块 + File system = Tool.createPath(api.getAbsolutePath(), "system"); + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/action/api/system/")) { + freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), name), option + "/java/action/api/system/" + name, ctx); + } + } } freeMarkerManager.outputTemp(Tool.createFile(screen.getAbsolutePath(), "Index.java"), option + "/java/action/screen/Index.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "GlobalController.java"), option + "/java/action/GlobalController.java", ctx); - -// freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "AjaxController.java"), option + "/java/action/AjaxController.java", ctx); } public void generateConfig(File root, Project project, DataBase dataBase, String option) { @@ -250,11 +249,13 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ActionConfig.java"), option + "/java/config/ActionConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "FreeMarkerConfig.java"), option + "/java/config/FreeMarkerConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "SecurityConfig.java"), option + "/java/config/SecurityConfig.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "SQLiteConfig.java"), option + "/java/config/SQLiteConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "TaskConfig.java"), option + "/java/config/TaskConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ThreadPoolConfig.java"), option + "/java/config/ThreadPoolConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "WebMvcConfig.java"), option + "/java/config/WebMvcConfig.java", ctx); - if (project.getMultiDB()){ + if (dataBase.name().equals(DataBase.SQLite)) { + freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "SQLiteConfig.java"), option + "/java/config/SQLiteConfig.java", ctx); + } + if (project.getMultiDB()) { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "MapperMainConfig.java"), option + "/java/config/MapperMainConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "MapperTwoConfig.java"), option + "/java/config/MapperTwoConfig.java", ctx); } @@ -465,94 +466,29 @@ public class SpringBootCallable implements Callable { ctx.put("date", new Date()); ctx.put("dataBase", dataBase.toString()); - freeMarkerManager.outputTemp(Tool.createFile(ent.getAbsolutePath(), "Dict.java"), option + "/java/module/system/ent/Dict.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(ent.getAbsolutePath(), "DictItem.java"), option + "/java/module/system/ent/DictItem.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(ent.getAbsolutePath(), "File.java"), option + "/java/module/system/ent/File.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(ent.getAbsolutePath(), "Resource.java"), option + "/java/module/system/ent/Resource.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(ent.getAbsolutePath(), "Tokens.java"), option + "/java/module/system/ent/Tokens.java", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "DictItemManager.java"), option + "/java/module/system/mgr/DictItemManager.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "DictItemManagerImpl.java"), option + "/java/module/system/mgr/DictItemManagerImpl.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "DictManager.java"), option + "/java/module/system/mgr/DictManager.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "DictManagerImpl.java"), option + "/java/module/system/mgr/DictManagerImpl.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "FileManager.java"), option + "/java/module/system/mgr/FileManager.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "FileManagerImpl.java"), option + "/java/module/system/mgr/FileManagerImpl.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "ResourceManager.java"), option + "/java/module/system/mgr/ResourceManager.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "ResourceManagerImpl.java"), option + "/java/module/system/mgr/ResourceManagerImpl.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "TokensManager.java"), option + "/java/module/system/mgr/TokensManager.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), "TokensManagerImpl.java"), option + "/java/module/system/mgr/TokensManagerImpl.java", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "DictItemMapper.java"), option + "/java/module/system/mpr/DictItemMapper.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "DictItemMapper.xml"), option + "/java/module/system/mpr/DictItemMapper_" + dataBase.toString() + ".xml", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "DictMapper.java"), option + "/java/module/system/mpr/DictMapper.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "DictMapper.xml"), option + "/java/module/system/mpr/DictMapper_" + dataBase.toString() + ".xml", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "FileMapper.java"), option + "/java/module/system/mpr/FileMapper.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "FileMapper.xml"), option + "/java/module/system/mpr/FileMapper_" + dataBase.toString() + ".xml", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "ResourceMapper.java"), option + "/java/module/system/mpr/ResourceMapper.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "ResourceMapper.xml"), option + "/java/module/system/mpr/ResourceMapper_" + dataBase.toString() + ".xml", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "TokensMapper.java"), option + "/java/module/system/mpr/TokensMapper.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), "ResourceMapper.xml"), option + "/java/module/system/mpr/ResourceMapper_" + dataBase.toString() + ".xml", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "AuthLoginRequest.java"), option + "/java/module/system/req/AuthLoginRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictCreateRequest.java"), option + "/java/module/system/req/DictCreateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictDeleteRequest.java"), option + "/java/module/system/req/DictDeleteRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictFindRequest.java"), option + "/java/module/system/req/DictFindRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictGetRequest.java"), option + "/java/module/system/req/DictGetRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictItemCreateRequest.java"), option + "/java/module/system/req/DictItemCreateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictItemDeleteRequest.java"), option + "/java/module/system/req/DictItemDeleteRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictItemFindRequest.java"), option + "/java/module/system/req/DictItemFindRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictItemGetRequest.java"), option + "/java/module/system/req/DictItemGetRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictItemUpdateRequest.java"), option + "/java/module/system/req/DictItemUpdateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictLoadRequest.java"), option + "/java/module/system/req/DictLoadRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "DictUpdateRequest.java"), option + "/java/module/system/req/DictUpdateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "FileCreateRequest.java"), option + "/java/module/system/req/FileCreateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "FileDeleteRequest.java"), option + "/java/module/system/req/FileDeleteRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "FileDownloadRequest.java"), option + "/java/module/system/req/FileDownloadRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "FileFindRequest.java"), option + "/java/module/system/req/FileFindRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "FileGetRequest.java"), option + "/java/module/system/req/FileGetRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "FileUploadRequest.java"), option + "/java/module/system/req/FileUploadRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "ResourceCreateRequest.java"), option + "/java/module/system/req/ResourceCreateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "ResourceDeleteRequest.java"), option + "/java/module/system/req/ResourceDeleteRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "ResourceFindRequest.java"), option + "/java/module/system/req/ResourceFindRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "ResourceGetRequest.java"), option + "/java/module/system/req/ResourceGetRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "ResourceUpdateRequest.java"), option + "/java/module/system/req/ResourceUpdateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "TokensCreateRequest.java"), option + "/java/module/system/req/TokensCreateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "TokensDeleteRequest.java"), option + "/java/module/system/req/TokensDeleteRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "TokensFindRequest.java"), option + "/java/module/system/req/TokensFindRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "TokensGetRequest.java"), option + "/java/module/system/req/TokensGetRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), "TokensUpdateRequest.java"), option + "/java/module/system/req/TokensUpdateRequest.java", ctx); - - - - - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "AuthLoginResponse.java"), option + "/java/module/system/rsp/AuthLoginResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictCreateResponse.java"), option + "/java/module/system/rsp/DictCreateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictDeleteResponse.java"), option + "/java/module/system/rsp/DictDeleteResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictFindResponse.java"), option + "/java/module/system/rsp/DictFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictGetResponse.java"), option + "/java/module/system/rsp/DictGetResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictItemCreateResponse.java"), option + "/java/module/system/rsp/DictItemCreateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictItemDeleteResponse.java"), option + "/java/module/system/rsp/DictItemDeleteResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictItemFindResponse.java"), option + "/java/module/system/rsp/DictItemFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictItemGetResponse.java"), option + "/java/module/system/rsp/DictItemGetResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictItemUpdateResponse.java"), option + "/java/module/system/rsp/DictItemUpdateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictLoadResponse.java"), option + "/java/module/system/rsp/DictLoadResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "DictUpdateResponse.java"), option + "/java/module/system/rsp/DictUpdateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "FileCreateResponse.java"), option + "/java/module/system/rsp/FileCreateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "FileDeleteResponse.java"), option + "/java/module/system/rsp/FileDeleteResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "FileDownloadResponse.java"), option + "/java/module/system/rsp/FileDownloadResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "FileFindResponse.java"), option + "/java/module/system/rsp/FileFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "FileGetResponse.java"), option + "/java/module/system/rsp/FileGetResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "FileUploadResponse.java"), option + "/java/module/system/rsp/FileUploadResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "ResourceCreateResponse.java"), option + "/java/module/system/rsp/ResourceCreateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "ResourceDeleteResponse.java"), option + "/java/module/system/rsp/ResourceDeleteResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "ResourceFindResponse.java"), option + "/java/module/system/rsp/ResourceFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "ResourceGetResponse.java"), option + "/java/module/system/rsp/ResourceGetResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "ResourceUpdateResponse.java"), option + "/java/module/system/rsp/ResourceUpdateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "TokensCreateResponse.java"), option + "/java/module/system/rsp/TokensCreateResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "TokensDeleteResponse.java"), option + "/java/module/system/rsp/TokensDeleteResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "TokensFindResponse.java"), option + "/java/module/system/rsp/TokensFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "TokensGetResponse.java"), option + "/java/module/system/rsp/TokensGetResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), "TokensUpdateResponse.java"), option + "/java/module/system/rsp/TokensUpdateResponse.java", ctx); + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/module/system/ent/")) { + freeMarkerManager.outputTemp(Tool.createFile(ent.getAbsolutePath(), name), option + "/java/module/system/ent/" + name, ctx); + } + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/module/system/mgr/")) { + freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), name), option + "/java/module/system/mgr/" + name, ctx); + } + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/module/system/mpr/")) { + if (name.endsWith(".java")) { + freeMarkerManager.outputTemp(Tool.createFile(mpr.getAbsolutePath(), name), option + "/java/module/system/mpr/" + name, ctx); + } else if (name.contains(dataBase.toString())) { + freeMarkerManager.outputTemp(Tool.createFile(mgr.getAbsolutePath(), name.replaceAll("_" + dataBase.toString(), "")), option + "/java/module/system/mpr/" + name, ctx); + } + } + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/module/system/req/")) { + freeMarkerManager.outputTemp(Tool.createFile(req.getAbsolutePath(), name), option + "/java/module/system/req/" + name, ctx); + } + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/module/system/rsp/")) { + freeMarkerManager.outputTemp(Tool.createFile(rsp.getAbsolutePath(), name), option + "/java/module/system/rsp/" + name, ctx); + } } /** @@ -583,84 +519,41 @@ public class SpringBootCallable implements Callable { File validation = Tool.createPath(root.getAbsolutePath(), "validation"); //auth - freeMarkerManager.outputTemp(Tool.createFile(auth.getAbsolutePath(), "LocalData.java"), option + "/java/frame/auth/LocalData.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(auth.getAbsolutePath(), "Verification.java"), option + "/java/frame/auth/Verification.java", ctx); + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/auth/")) { + freeMarkerManager.outputTemp(Tool.createFile(auth.getAbsolutePath(), name), option + "/java/frame/auth/" + name, ctx); + } //base - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseEntity.java"), option + "/java/frame/base/BaseEntity.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseFindRequest.java"), option + "/java/frame/base/BaseFindRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseFindResponse.java"), option + "/java/frame/base/BaseFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseRequest.java"), option + "/java/frame/base/BaseRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseResponse.java"), option + "/java/frame/base/BaseResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseSearchRequest.java"), option + "/java/frame/base/BaseSearchRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseUpdateRequest.java"), option + "/java/frame/base/BaseUpdateRequest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "Control.java"), option + "/java/frame/base/Control.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "Error.java"), option + "/java/frame/base/Error.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "ErrorType.java"), option + "/java/frame/base/ErrorType.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "Screen.java"), option + "/java/frame/base/Screen.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "SortType.java"), option + "/java/frame/base/SortType.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "Token.java"), option + "/java/frame/base/Token.java", ctx); + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/base/")) { + freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), name), option + "/java/frame/base/" + name, ctx); + } //excel - freeMarkerManager.outputTemp(Tool.createFile(excel.getAbsolutePath(), "WCell.java"), option + "/java/frame/excel/WCell.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excel.getAbsolutePath(), "WColumn.java"), option + "/java/frame/excel/WColumn.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excel.getAbsolutePath(), "WRow.java"), option + "/java/frame/excel/WRow.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excel.getAbsolutePath(), "WSheet.java"), option + "/java/frame/excel/WSheet.java", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), "ColumnDescription.java"), option + "/java/frame/excel/annotation/ColumnDescription.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), "ColumnName.java"), option + "/java/frame/excel/annotation/ColumnName.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), "Converter.java"), option + "/java/frame/excel/annotation/Converter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), "Ignore.java"), option + "/java/frame/excel/annotation/Ignore.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), "ParentFirst.java"), option + "/java/frame/excel/annotation/ParentFirst.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), "SheetName.java"), option + "/java/frame/excel/annotation/SheetName.java", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "BooleanConverter.java"), option + "/java/frame/excel/converter/BooleanConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "ByteConverter.java"), option + "/java/frame/excel/converter/ByteConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "CharacterConverter.java"), option + "/java/frame/excel/converter/CharacterConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "Converter.java"), option + "/java/frame/excel/converter/Converter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "DateConverter.java"), option + "/java/frame/excel/converter/DateConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "DoubleConverter.java"), option + "/java/frame/excel/converter/DoubleConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "FloatConverter.java"), option + "/java/frame/excel/converter/FloatConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "IntegerConverter.java"), option + "/java/frame/excel/converter/IntegerConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "LongConverter.java"), option + "/java/frame/excel/converter/LongConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "ShortConverter.java"), option + "/java/frame/excel/converter/ShortConverter.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), "StringConverter.java"), option + "/java/frame/excel/converter/StringConverter.java", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(exception.getAbsolutePath(), "ReadErrorException.java"), option + "/java/frame/excel/exception/ReadErrorException.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(exception.getAbsolutePath(), "TemplateNotMatchException.java"), option + "/java/frame/excel/exception/TemplateNotMatchException.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(exception.getAbsolutePath(), "ValueConverterException.java"), option + "/java/frame/excel/exception/ValueConverterException.java", ctx); - - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "BaseCellStyle.java"), option + "/java/frame/excel/style/BaseCellStyle.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "BaseFont.java"), option + "/java/frame/excel/style/BaseFont.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "DataCellStyle.java"), option + "/java/frame/excel/style/DataCellStyle.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "ErrorCellStyle.java"), option + "/java/frame/excel/style/ErrorCellStyle.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "HeadCellStyle.java"), option + "/java/frame/excel/style/HeadCellStyle.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "NormalFont.java"), option + "/java/frame/excel/style/NormalFont.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), "RedFont.java"), option + "/java/frame/excel/style/RedFont.java", ctx); - - //uitls - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "Base64Util.java"), option + "/java/frame/utils/Base64Util.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "AESUtil.java"), option + "/java/frame/utils/AESUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ClassUtil.java"), option + "/java/frame/utils/ClassUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "CookieUtil.java"), option + "/java/frame/utils/CookieUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "FileUtil.java"), option + "/java/frame/utils/FileUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "LogUtil.java"), option + "/java/frame/utils/LogUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "MapperUtil.java"), option + "/java/frame/utils/MapperUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "MD5Util.java"), option + "/java/frame/utils/MD5Util.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ProcessUtil.java"), option + "/java/frame/utils/ProcessUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ResourceUtil.java"), option + "/java/frame/utils/ResourceUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ResponseUtil.java"), option + "/java/frame/utils/ResponseUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "RSAUtil.java"), option + "/java/frame/utils/RSAUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "StringUtil.java"), option + "/java/frame/utils/StringUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ValidationUtil.java"), option + "/java/frame/utils/ValidationUtil.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "WebUtils.java"), option + "/java/frame/utils/WebUtils.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "IDgenerator.java"), option + "/java/frame/utils/IDgenerator.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "Message.java"), option + "/java/frame/utils/Message.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "UrlUtil.java"), option + "/java/frame/utils/UrlUtil.java", ctx); + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/excel/")) { + freeMarkerManager.outputTemp(Tool.createFile(excel.getAbsolutePath(), name), option + "/java/frame/excel/" + name, ctx); + } + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/excel/annotation/")) { + freeMarkerManager.outputTemp(Tool.createFile(excelannotation.getAbsolutePath(), name), option + "/java/frame/excel/annotation/" + name, ctx); + } + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/excel/converter/")) { + freeMarkerManager.outputTemp(Tool.createFile(excelconverter.getAbsolutePath(), name), option + "/java/frame/excel/converter/" + name, ctx); + } + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/excel/exception/")) { + freeMarkerManager.outputTemp(Tool.createFile(exception.getAbsolutePath(), name), option + "/java/frame/excel/exception/" + name, ctx); + } + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/excel/style/")) { + freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), name), option + "/java/frame/excel/style/" + name, ctx); + } + + //utils + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/utils/")) { + freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), name), option + "/java/frame/utils/" + name, ctx); + } //validation - freeMarkerManager.outputTemp(Tool.createFile(validation.getAbsolutePath(), "Dict.java"), option + "/java/frame/validation/Dict.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(validation.getAbsolutePath(), "DictValidator.java"), option + "/java/frame/validation/DictValidator.java", ctx); + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/validation/")) { + freeMarkerManager.outputTemp(Tool.createFile(validation.getAbsolutePath(), name), option + "/java/frame/validation/" + name, ctx); + } } /** @@ -722,17 +615,12 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(tableDir.getAbsolutePath(), "ALL_TABLE.sql"), option + "/resources/dbtool/tableAll.ftl", ctx); } - { + if (project.getSysMD()) {//生成系统模块 File system = Tool.createPath(dbtool.getAbsolutePath(), "system_table"); - File file = new File(system.getAbsolutePath(), "ALL_TABLE.sql"); - if (file.exists()){ - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ALL_TABLE_.sql"), option + "/resources/dbtool/system/ALL_TABLE_" + dataBase.toString() + ".sql", ctx); - }else { - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ALL_TABLE.sql"), option + "/resources/dbtool/system/ALL_TABLE_" + dataBase.toString() + ".sql", ctx); + + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/resources/dbtool/system/")) { + freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), name), option + "/resources/dbtool/system/" + name, ctx); } - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DICT.sql"), option + "/resources/dbtool/system/DICT_" + dataBase.toString() + ".sql", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DICT_ITEM.sql"), option + "/resources/dbtool/system/DICT_ITEM_" + dataBase.toString() + ".sql", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "FILE.sql"), option + "/resources/dbtool/system/FILE_" + dataBase.toString() + ".sql", ctx); } if (DataBase.Oracle.name().equals(dataBase.name())) { @@ -846,32 +734,18 @@ public class SpringBootCallable implements Callable { public void generateTemplates(File root, Project project, DataBase dataBase, String option) { {//生成 File templates = Tool.createPath(root.getAbsolutePath(), "templates"); - templates.mkdirs(); - File control = Tool.createPath(templates.getAbsolutePath(), "control"); File layout = Tool.createPath(templates.getAbsolutePath(), "layout"); File screen = Tool.createPath(templates.getAbsolutePath(), "screen"); - File system = Tool.createPath(screen.getAbsolutePath(), "system"); Tool.outputResource(option + "/resources/templates/control/nav.ftl", Tool.createFile(control.getAbsolutePath(), "nav.ftl")); -// Tool.outputResource(option + "/resources/templates/control/header.ftl", Tool.createFile(control.getAbsolutePath(), "header.ftl")); -// Tool.outputResource(option + "/resources/templates/control/footer.ftl", Tool.createFile(control.getAbsolutePath(), "footer.ftl")); Tool.outputResource(option + "/resources/templates/control/macro.ftl", Tool.createFile(control.getAbsolutePath(), "macro.ftl")); -// Tool.outputResource(option + "/resources/templates/control/mint-ui-extend.ftl", Tool.createFile(control.getAbsolutePath(), "mint-ui-extend.ftl")); Tool.outputResource(option + "/resources/templates/layout/default.ftl", Tool.createFile(layout.getAbsolutePath(), "default.ftl")); - Tool.outputResource(option + "/resources/templates/layout/index.ftl", Tool.createFile(layout.getAbsolutePath(), "index.ftl")); -// Tool.outputResource(option + "/resources/templates/layout/app.ftl", Tool.createFile(layout.getAbsolutePath(), "app.ftl")); Tool.outputResource(option + "/resources/templates/screen/home.ftl", Tool.createFile(screen.getAbsolutePath(), "home.ftl")); Tool.outputResource(option + "/resources/templates/screen/login.ftl", Tool.createFile(screen.getAbsolutePath(), "login.ftl")); Tool.outputResource(option + "/resources/templates/403.ftl", Tool.createFile(templates.getAbsolutePath(), "403.ftl")); Tool.outputResource(option + "/resources/templates/404.ftl", Tool.createFile(templates.getAbsolutePath(), "404.ftl")); Tool.outputResource(option + "/resources/templates/500.ftl", Tool.createFile(templates.getAbsolutePath(), "500.ftl")); - Tool.outputResource(option + "/resources/templates/screen/module/system/dict.ftl", Tool.createFile(system.getAbsolutePath(), "dict.ftl")); - Tool.outputResource(option + "/resources/templates/screen/module/system/dictItem.ftl", Tool.createFile(system.getAbsolutePath(), "dictItem.ftl")); - Tool.outputResource(option + "/resources/templates/screen/module/system/file.ftl", Tool.createFile(system.getAbsolutePath(), "file.ftl")); - Tool.outputResource(option + "/resources/templates/screen/module/system/resource.ftl", Tool.createFile(system.getAbsolutePath(), "resource.ftl")); - Tool.outputResource(option + "/resources/templates/screen/module/system/tokens.ftl", Tool.createFile(system.getAbsolutePath(), "tokens.ftl")); - { HashMap ctx = new HashMap(); ctx.put("basePackage", project.getProjectBasePackage()); @@ -879,6 +753,7 @@ public class SpringBootCallable implements Callable { ctx.put("author", project.getProjectAuthor()); ctx.put("date", new Date()); ctx.put("modules", project.getModules()); + ctx.put("sysMD", project.getSysMD()); freeMarkerManager.outputTemp(Tool.createFile(screen.getAbsolutePath(), "index.ftl"), option + "/resources/templates/screen/index.ftl", ctx); } @@ -902,6 +777,13 @@ public class SpringBootCallable implements Callable { } } } + + if (project.getSysMD()) {//生成系统模块 + File system = Tool.createPath(screen.getAbsolutePath(), "system"); + for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/resources/templates/screen/module/system/")) { + Tool.outputResource(option + "/resources/templates/screen/module/system/" + name, Tool.createFile(system.getAbsolutePath(), name)); + } + } } } @@ -931,21 +813,6 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(file, option + "/test/UtilTest.java", ctx); } - { - HashMap ctx = new HashMap(); - ctx.put("tool", Tool.class); - ctx.put("basePackage", project.getProjectBasePackage()); - ctx.put("moduleName", project.getProjectName()); - ctx.put("author", project.getProjectAuthor()); - ctx.put("date", new Date()); - File system = Tool.createPath(root.getAbsolutePath(), "system"); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictItemTest.java"), option + "/test/system/DictItemTest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictTest.java"), option + "/test/system/DictTest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "FileTest.java"), option + "/test/system/FileTest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ResourceTest.java"), option + "/test/system/ResourceTest.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "TokensTest.java"), option + "/test/system/TokensTest.java", ctx); - } - for (Module md : project.getModules()) { File module = Tool.createPath(root.getAbsolutePath(), md.getModuleName()); @@ -965,5 +832,18 @@ public class SpringBootCallable implements Callable { } } + if (project.getSysMD()) {//生成系统模块 + HashMap ctx = new HashMap(); + ctx.put("tool", Tool.class); + ctx.put("basePackage", project.getProjectBasePackage()); + ctx.put("moduleName", project.getProjectName()); + ctx.put("author", project.getProjectAuthor()); + ctx.put("date", new Date()); + File system = Tool.createPath(root.getAbsolutePath(), "system"); + + for (String apiFile : ResourceUtil.getResourceFiles("/modules/SpringBoot/test/system/")) { + freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), apiFile), option + "/test/system/" + apiFile, ctx); + } + } } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java index a6abfa73..5bcd1ddc 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java @@ -24,6 +24,7 @@ public class Project extends TreeItem{ private String projectBasePackage; private String projectAuthor; private boolean multiDB; + private boolean sysMD; /** * 对象 @@ -76,4 +77,12 @@ public class Project extends TreeItem{ public void setMultiDB(boolean multiDB) { this.multiDB = multiDB; } + + public boolean getSysMD() { + return sysMD; + } + + public void setSysMD(boolean sysMD) { + this.sysMD = sysMD; + } } diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ResourceUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ResourceUtil.java index 87c08c56..c35183ab 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ResourceUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ResourceUtil.java @@ -8,9 +8,58 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class ResourceUtil extends ResourceUtils { + /** + * 获取资源目录下所有文件名 如: /modules/dir/ + * + * @param resourcePath 路径 + * @return + */ + public static List getResourceFiles(String resourcePath) { + List result = new ArrayList<>(); + File applicationHome = getApplicationHome(); + if (applicationHome.getAbsolutePath().endsWith(".jar")) { + try { + Pattern pattern = Pattern.compile(".*" + resourcePath + "(.+\\..+)"); + JarFile jarFile = new JarFile(applicationHome); + Enumeration entries = jarFile.entries(); + while (entries.hasMoreElements()) { + JarEntry jarEntry = entries.nextElement(); + String name = jarEntry.getName(); + + if (name.matches(".*" + resourcePath + "(.+\\..+)")) { + Matcher matcher = pattern.matcher(name); + if (matcher.find()) result.add(matcher.group(1)); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } else { + try { + ClassPathResource cpr = new ClassPathResource(resourcePath); + File in = cpr.getFile(); + for (File file : in.listFiles()) { + result.add(file.getName()); + } + return result; + } catch (IOException e) { + e.printStackTrace(); + } + } + + return result; + } + /** * 获取当前运行jar文件 * diff --git a/src/main/resources/fxml/projectdetail.fxml b/src/main/resources/fxml/projectdetail.fxml index f07224b9..41f68c27 100644 --- a/src/main/resources/fxml/projectdetail.fxml +++ b/src/main/resources/fxml/projectdetail.fxml @@ -52,6 +52,7 @@ GridPane.halignment="CENTER" GridPane.valignment="CENTER"> + diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/AuthAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/AuthAjax.java index f6b80ffa..484276b8 100644 --- a/src/main/resources/modules/SpringBoot/java/action/ajax/system/AuthAjax.java +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/AuthAjax.java @@ -1,22 +1,133 @@ package ${basePackage}.action.ajax.system; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.utils.CookieUtil; +import ${basePackage}.frame.utils.MD5Util; +import ${basePackage}.frame.utils.RequestUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.User; +import ${basePackage}.module.system.mgr.TokensManager; +import ${basePackage}.module.system.mgr.UserManager; import ${basePackage}.module.system.req.AuthLoginRequest; +import ${basePackage}.module.system.req.TokensCreateRequest; +import ${basePackage}.module.system.req.UserFindRequest; import ${basePackage}.module.system.rsp.AuthLoginResponse; +import ${basePackage}.module.system.rsp.TokensCreateResponse; +import ${basePackage}.module.system.rsp.UserFindResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Calendar; +import java.util.Date; +import java.util.UUID; public class AuthAjax { + @Value("${r'${web.url.auth.admin}'}") + private String admin; + @Value("${r'${web.url.auth.pwd}'}") + private String pwd; + @Autowired + private TokensManager tokensManager; + @Autowired + private UserManager userManager; public AuthLoginResponse login(AuthLoginRequest request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { AuthLoginResponse response = new AuthLoginResponse(); - // todo 设置cookie - Cookie token = new Cookie("token", ""); - token.setDomain(httpServletRequest.getServerName()); - token.setPath("/"); - httpServletResponse.addCookie(token); + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + if (request.getUsername().equals(admin)) {//超级管理员登录 + String generatePwd = MD5Util.generatePwd(request.getPassword()); + if (!generatePwd.equals(pwd)) { + response.addError(ErrorType.BUSINESS_ERROR, "登录密码错误"); + } else { + Date current = new Date(); + Calendar instance = Calendar.getInstance(); + instance.setTime(current); + instance.add(Calendar.HOUR_OF_DAY, 1);//默认一个小时内有效 + + TokensCreateRequest tokensCreateRequest = new TokensCreateRequest(); + tokensCreateRequest.setToken(UUID.randomUUID().toString()); + tokensCreateRequest.setUserId(0L); + tokensCreateRequest.setUserName("超级管理员"); + tokensCreateRequest.setLoginTime(current); + tokensCreateRequest.setValidTime(instance.getTime()); + tokensCreateRequest.setValid(true); + tokensCreateRequest.setDeptId(null); + tokensCreateRequest.setDeptCode(null); + tokensCreateRequest.setDeptName(null); + tokensCreateRequest.setTerminalType("WEB"); + tokensCreateRequest.setTerminalIp(RequestUtil.getIp(httpServletRequest)); + tokensCreateRequest.setTerminalInfo(RequestUtil.getUserAgent(httpServletRequest)); + TokensCreateResponse tokensCreateResponse = tokensManager.create(tokensCreateRequest, LocalData.getSysToken()); + + if (tokensCreateResponse.hasError()) { + response.addErrors(tokensCreateResponse.getErrors()); + return response; + } + Cookie cookie = CookieUtil.newCookie("token", tokensCreateRequest.getToken())); + cookie.setPath("/"); + httpServletResponse.addCookie(cookie); + } + } else {//管理员登录 + UserFindRequest userFindRequest = new UserFindRequest(); + userFindRequest.setUserName(request.getUsername()); + UserFindResponse userFindResponse = userManager.find(userFindRequest, LocalData.getSysToken()); + + if (userFindResponse.hasError()) { + response.addErrors(userFindResponse.getErrors()); + return response; + } else if (userFindResponse.getResult().size() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "用户名或密码错误!"); + return response; + } else if (userFindResponse.getResult().size() > 1) { + response.addError(ErrorType.BUSINESS_ERROR, "用户信息异常!"); + return response; + } + + User user = userFindResponse.getResult().get(0); + + String generatePwd = MD5Util.generatePwd(request.getPassword()); + if (!generatePwd.equals(user.getUserPwd())) { + response.addError(ErrorType.BUSINESS_ERROR, "用户名或密码错误!"); + return response; + } + + Date current = new Date(); + Calendar instance = Calendar.getInstance(); + instance.setTime(current); + instance.add(Calendar.HOUR_OF_DAY, 1);//默认一个小时内有效 + + TokensCreateRequest tokensCreateRequest = new TokensCreateRequest(); + tokensCreateRequest.setToken(UUID.randomUUID().toString()); + tokensCreateRequest.setUserId(user.getId()); + tokensCreateRequest.setUserName(user.getUserName()); + tokensCreateRequest.setLoginTime(current); + tokensCreateRequest.setValidTime(instance.getTime()); + tokensCreateRequest.setValid(true); + tokensCreateRequest.setDeptId(user.getDeptId()); + tokensCreateRequest.setDeptCode(user.getDeptCode()); + tokensCreateRequest.setDeptName(user.getDeptName()); + tokensCreateRequest.setTerminalType("WEB"); + tokensCreateRequest.setTerminalIp(RequestUtil.getIp(httpServletRequest)); + tokensCreateRequest.setTerminalInfo(RequestUtil.getUserAgent(httpServletRequest)); + TokensCreateResponse tokensCreateResponse = tokensManager.create(tokensCreateRequest, LocalData.getSysToken()); + + if (tokensCreateResponse.hasError()) { + response.addErrors(tokensCreateResponse.getErrors()); + return response; + } + Cookie cookie = CookieUtil.newCookie("token", tokensCreateRequest.getToken())); + cookie.setPath("/"); + httpServletResponse.addCookie(cookie); + } return response; } diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/DeptAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/DeptAjax.java new file mode 100644 index 00000000..92c03a62 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/DeptAjax.java @@ -0,0 +1,90 @@ +package ${basePackage}.action.ajax.system; + +import com.fasterxml.jackson.core.TreeNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; +import ${basePackage}.frame.excel.WSheet; +import ${basePackage}.frame.utils.LogUtil; +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.base.BaseResponse; +import ${basePackage}.frame.utils.ResponseUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.frame.excel.exception.ReadErrorException; +import ${basePackage}.frame.excel.exception.TemplateNotMatchException; +import ${basePackage}.module.system.ent.Dept; +import ${basePackage}.module.system.mgr.DeptManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; + +import java.io.IOException; +import java.util.List; + +public class DeptAjax{ + + @Autowired + private DeptManager deptManager; + + public DeptCreateResponse create(DeptCreateRequest request) { + return deptManager.create(request, LocalData.getToken()); + } + + public DeptDeleteResponse delete(DeptDeleteRequest request) { + return deptManager.delete(request, LocalData.getToken()); + } + + public DeptUpdateResponse update(DeptUpdateRequest request) { + return deptManager.update(request, LocalData.getToken()); + } + + public DeptFindResponse find(DeptFindRequest request) { + return deptManager.find(request, LocalData.getToken()); + } + + public DeptGetResponse get(DeptGetRequest request) { + return deptManager.get(request, LocalData.getToken()); + } + + public Object template(){ + return ResponseUtil.apply(new WSheet<>(Dept.class)); + } + + public Object exports(TreeNode jsonParam) { + DeptFindRequest request = MapperUtil.toJava(jsonParam, DeptFindRequest.class); + DeptFindResponse response = deptManager.find(request, LocalData.getToken()); + if (response.hasError()) { + return response; + } else if (response.getTotalCount() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); + return response; + } + return ResponseUtil.apply(new WSheet<>(response.getResult())); + } + + public Object imports(MultipartFile file) { + BaseResponse baseResponse = new BaseResponse(); + try { + WSheet sheet = new WSheet<>(file.getBytes(), Dept.class, new WSheet.Validator() { + @Override + public List validate(Dept o) { + DeptCreateRequest request = MapperUtil.map(o, DeptCreateRequest.class); + return ValidationUtil.validate(request); + } + }); + + if (sheet.hasError()) { + return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx"); + } else { + return baseResponse; + } + } catch (IOException e) { + e.printStackTrace(); + LogUtil.dumpException(e); + baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错"); + } catch (TemplateNotMatchException | ReadErrorException e) { + baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage()); + } + return baseResponse; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleAjax.java new file mode 100644 index 00000000..24fbb677 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleAjax.java @@ -0,0 +1,90 @@ +package ${basePackage}.action.ajax.system; + +import com.fasterxml.jackson.core.TreeNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; +import ${basePackage}.frame.excel.WSheet; +import ${basePackage}.frame.utils.LogUtil; +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.base.BaseResponse; +import ${basePackage}.frame.utils.ResponseUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.frame.excel.exception.ReadErrorException; +import ${basePackage}.frame.excel.exception.TemplateNotMatchException; +import ${basePackage}.module.system.ent.Role; +import ${basePackage}.module.system.mgr.RoleManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; + +import java.io.IOException; +import java.util.List; + +public class RoleAjax{ + + @Autowired + private RoleManager roleManager; + + public RoleCreateResponse create(RoleCreateRequest request) { + return roleManager.create(request, LocalData.getToken()); + } + + public RoleDeleteResponse delete(RoleDeleteRequest request) { + return roleManager.delete(request, LocalData.getToken()); + } + + public RoleUpdateResponse update(RoleUpdateRequest request) { + return roleManager.update(request, LocalData.getToken()); + } + + public RoleFindResponse find(RoleFindRequest request) { + return roleManager.find(request, LocalData.getToken()); + } + + public RoleGetResponse get(RoleGetRequest request) { + return roleManager.get(request, LocalData.getToken()); + } + + public Object template(){ + return ResponseUtil.apply(new WSheet<>(Role.class)); + } + + public Object exports(TreeNode jsonParam) { + RoleFindRequest request = MapperUtil.toJava(jsonParam, RoleFindRequest.class); + RoleFindResponse response = roleManager.find(request, LocalData.getToken()); + if (response.hasError()) { + return response; + } else if (response.getTotalCount() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); + return response; + } + return ResponseUtil.apply(new WSheet<>(response.getResult())); + } + + public Object imports(MultipartFile file) { + BaseResponse baseResponse = new BaseResponse(); + try { + WSheet sheet = new WSheet<>(file.getBytes(), Role.class, new WSheet.Validator() { + @Override + public List validate(Role o) { + RoleCreateRequest request = MapperUtil.map(o, RoleCreateRequest.class); + return ValidationUtil.validate(request); + } + }); + + if (sheet.hasError()) { + return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx"); + } else { + return baseResponse; + } + } catch (IOException e) { + e.printStackTrace(); + LogUtil.dumpException(e); + baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错"); + } catch (TemplateNotMatchException | ReadErrorException e) { + baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage()); + } + return baseResponse; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleResourceAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleResourceAjax.java new file mode 100644 index 00000000..741049fa --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/RoleResourceAjax.java @@ -0,0 +1,48 @@ +package ${basePackage}.action.ajax.system; + +import com.fasterxml.jackson.core.TreeNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; +import ${basePackage}.frame.excel.WSheet; +import ${basePackage}.frame.utils.LogUtil; +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.base.BaseResponse; +import ${basePackage}.frame.utils.ResponseUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.frame.excel.exception.ReadErrorException; +import ${basePackage}.frame.excel.exception.TemplateNotMatchException; +import ${basePackage}.module.system.ent.RoleResource; +import ${basePackage}.module.system.mgr.RoleResourceManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; + +import java.io.IOException; +import java.util.List; + +public class RoleResourceAjax{ + + @Autowired + private RoleResourceManager roleResourceManager; + + public RoleResourceCreateResponse create(RoleResourceCreateRequest request) { + return roleResourceManager.create(request, LocalData.getToken()); + } + + public RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request) { + return roleResourceManager.delete(request, LocalData.getToken()); + } + + public RoleResourceUpdateResponse update(RoleResourceUpdateRequest request) { + return roleResourceManager.update(request, LocalData.getToken()); + } + + public RoleResourceFindResponse find(RoleResourceFindRequest request) { + return roleResourceManager.find(request, LocalData.getToken()); + } + + public RoleResourceGetResponse get(RoleResourceGetRequest request) { + return roleResourceManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/UserAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/UserAjax.java new file mode 100644 index 00000000..812b1b3e --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/UserAjax.java @@ -0,0 +1,90 @@ +package ${basePackage}.action.ajax.system; + +import com.fasterxml.jackson.core.TreeNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; +import ${basePackage}.frame.excel.WSheet; +import ${basePackage}.frame.utils.LogUtil; +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.base.BaseResponse; +import ${basePackage}.frame.utils.ResponseUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.frame.excel.exception.ReadErrorException; +import ${basePackage}.frame.excel.exception.TemplateNotMatchException; +import ${basePackage}.module.system.ent.User; +import ${basePackage}.module.system.mgr.UserManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; + +import java.io.IOException; +import java.util.List; + +public class UserAjax{ + + @Autowired + private UserManager userManager; + + public UserCreateResponse create(UserCreateRequest request) { + return userManager.create(request, LocalData.getToken()); + } + + public UserDeleteResponse delete(UserDeleteRequest request) { + return userManager.delete(request, LocalData.getToken()); + } + + public UserUpdateResponse update(UserUpdateRequest request) { + return userManager.update(request, LocalData.getToken()); + } + + public UserFindResponse find(UserFindRequest request) { + return userManager.find(request, LocalData.getToken()); + } + + public UserGetResponse get(UserGetRequest request) { + return userManager.get(request, LocalData.getToken()); + } + + public Object template(){ + return ResponseUtil.apply(new WSheet<>(User.class)); + } + + public Object exports(TreeNode jsonParam) { + UserFindRequest request = MapperUtil.toJava(jsonParam, UserFindRequest.class); + UserFindResponse response = userManager.find(request, LocalData.getToken()); + if (response.hasError()) { + return response; + } else if (response.getTotalCount() == 0) { + response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); + return response; + } + return ResponseUtil.apply(new WSheet<>(response.getResult())); + } + + public Object imports(MultipartFile file) { + BaseResponse baseResponse = new BaseResponse(); + try { + WSheet sheet = new WSheet<>(file.getBytes(), User.class, new WSheet.Validator() { + @Override + public List validate(User o) { + UserCreateRequest request = MapperUtil.map(o, UserCreateRequest.class); + return ValidationUtil.validate(request); + } + }); + + if (sheet.hasError()) { + return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx"); + } else { + return baseResponse; + } + } catch (IOException e) { + e.printStackTrace(); + LogUtil.dumpException(e); + baseResponse.addError(ErrorType.BUSINESS_ERROR, "上传文件出错"); + } catch (TemplateNotMatchException | ReadErrorException e) { + baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage()); + } + return baseResponse; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/system/UserRoleAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/system/UserRoleAjax.java new file mode 100644 index 00000000..632c4d29 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/system/UserRoleAjax.java @@ -0,0 +1,48 @@ +package ${basePackage}.action.ajax.system; + +import com.fasterxml.jackson.core.TreeNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.multipart.MultipartFile; +import ${basePackage}.frame.excel.WSheet; +import ${basePackage}.frame.utils.LogUtil; +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.base.BaseResponse; +import ${basePackage}.frame.utils.ResponseUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.frame.excel.exception.ReadErrorException; +import ${basePackage}.frame.excel.exception.TemplateNotMatchException; +import ${basePackage}.module.system.ent.UserRole; +import ${basePackage}.module.system.mgr.UserRoleManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; + +import java.io.IOException; +import java.util.List; + +public class UserRoleAjax{ + + @Autowired + private UserRoleManager userRoleManager; + + public UserRoleCreateResponse create(UserRoleCreateRequest request) { + return userRoleManager.create(request, LocalData.getToken()); + } + + public UserRoleDeleteResponse delete(UserRoleDeleteRequest request) { + return userRoleManager.delete(request, LocalData.getToken()); + } + + public UserRoleUpdateResponse update(UserRoleUpdateRequest request) { + return userRoleManager.update(request, LocalData.getToken()); + } + + public UserRoleFindResponse find(UserRoleFindRequest request) { + return userRoleManager.find(request, LocalData.getToken()); + } + + public UserRoleGetResponse get(UserRoleGetRequest request) { + return userRoleManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/api/system/DeptApi.java b/src/main/resources/modules/SpringBoot/java/action/api/system/DeptApi.java new file mode 100644 index 00000000..ad915601 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/api/system/DeptApi.java @@ -0,0 +1,33 @@ +package ${basePackage}.action.api.system; + +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.module.system.mgr.DeptManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import org.springframework.beans.factory.annotation.Autowired; + +public class DeptApi{ + + @Autowired + private DeptManager deptManager; + + public DeptCreateResponse create(DeptCreateRequest request) { + return deptManager.create(request, LocalData.getToken()); + } + + public DeptDeleteResponse delete(DeptDeleteRequest request) { + return deptManager.delete(request, LocalData.getToken()); + } + + public DeptUpdateResponse update(DeptUpdateRequest request) { + return deptManager.update(request, LocalData.getToken()); + } + + public DeptFindResponse find(DeptFindRequest request) { + return deptManager.find(request, LocalData.getToken()); + } + + public DeptGetResponse get(DeptGetRequest request) { + return deptManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/api/system/RoleApi.java b/src/main/resources/modules/SpringBoot/java/action/api/system/RoleApi.java new file mode 100644 index 00000000..48c18ee0 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/api/system/RoleApi.java @@ -0,0 +1,33 @@ +package ${basePackage}.action.api.system; + +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.module.system.mgr.RoleManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import org.springframework.beans.factory.annotation.Autowired; + +public class RoleApi{ + + @Autowired + private RoleManager roleManager; + + public RoleCreateResponse create(RoleCreateRequest request) { + return roleManager.create(request, LocalData.getToken()); + } + + public RoleDeleteResponse delete(RoleDeleteRequest request) { + return roleManager.delete(request, LocalData.getToken()); + } + + public RoleUpdateResponse update(RoleUpdateRequest request) { + return roleManager.update(request, LocalData.getToken()); + } + + public RoleFindResponse find(RoleFindRequest request) { + return roleManager.find(request, LocalData.getToken()); + } + + public RoleGetResponse get(RoleGetRequest request) { + return roleManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/api/system/RoleResourceApi.java b/src/main/resources/modules/SpringBoot/java/action/api/system/RoleResourceApi.java new file mode 100644 index 00000000..11ec4c9b --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/api/system/RoleResourceApi.java @@ -0,0 +1,33 @@ +package ${basePackage}.action.api.system; + +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.module.system.mgr.RoleResourceManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import org.springframework.beans.factory.annotation.Autowired; + +public class RoleResourceApi{ + + @Autowired + private RoleResourceManager roleResourceManager; + + public RoleResourceCreateResponse create(RoleResourceCreateRequest request) { + return roleResourceManager.create(request, LocalData.getToken()); + } + + public RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request) { + return roleResourceManager.delete(request, LocalData.getToken()); + } + + public RoleResourceUpdateResponse update(RoleResourceUpdateRequest request) { + return roleResourceManager.update(request, LocalData.getToken()); + } + + public RoleResourceFindResponse find(RoleResourceFindRequest request) { + return roleResourceManager.find(request, LocalData.getToken()); + } + + public RoleResourceGetResponse get(RoleResourceGetRequest request) { + return roleResourceManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/api/system/UserApi.java b/src/main/resources/modules/SpringBoot/java/action/api/system/UserApi.java new file mode 100644 index 00000000..85bfaee0 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/api/system/UserApi.java @@ -0,0 +1,33 @@ +package ${basePackage}.action.api.system; + +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.module.system.mgr.UserManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import org.springframework.beans.factory.annotation.Autowired; + +public class UserApi{ + + @Autowired + private UserManager userManager; + + public UserCreateResponse create(UserCreateRequest request) { + return userManager.create(request, LocalData.getToken()); + } + + public UserDeleteResponse delete(UserDeleteRequest request) { + return userManager.delete(request, LocalData.getToken()); + } + + public UserUpdateResponse update(UserUpdateRequest request) { + return userManager.update(request, LocalData.getToken()); + } + + public UserFindResponse find(UserFindRequest request) { + return userManager.find(request, LocalData.getToken()); + } + + public UserGetResponse get(UserGetRequest request) { + return userManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/action/api/system/UserRoleApi.java b/src/main/resources/modules/SpringBoot/java/action/api/system/UserRoleApi.java new file mode 100644 index 00000000..18ba5173 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/api/system/UserRoleApi.java @@ -0,0 +1,33 @@ +package ${basePackage}.action.api.system; + +import ${basePackage}.frame.auth.LocalData; +import ${basePackage}.module.system.mgr.UserRoleManager; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import org.springframework.beans.factory.annotation.Autowired; + +public class UserRoleApi{ + + @Autowired + private UserRoleManager userRoleManager; + + public UserRoleCreateResponse create(UserRoleCreateRequest request) { + return userRoleManager.create(request, LocalData.getToken()); + } + + public UserRoleDeleteResponse delete(UserRoleDeleteRequest request) { + return userRoleManager.delete(request, LocalData.getToken()); + } + + public UserRoleUpdateResponse update(UserRoleUpdateRequest request) { + return userRoleManager.update(request, LocalData.getToken()); + } + + public UserRoleFindResponse find(UserRoleFindRequest request) { + return userRoleManager.find(request, LocalData.getToken()); + } + + public UserRoleGetResponse get(UserRoleGetRequest request) { + return userRoleManager.get(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java b/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java index 6d108af5..6e73a080 100644 --- a/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java +++ b/src/main/resources/modules/SpringBoot/java/config/SecurityConfig.java @@ -63,7 +63,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { return super.authenticationManagerBean(); } - public static class TokenFilter implements Filter { @Override diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java index c1fe1005..e18ede9a 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/CookieUtil.java @@ -37,7 +37,8 @@ public class CookieUtil { /** * 生成一个默认的Cookie * - * @param cookies Cookies + * @param key 键 + * @param value 值 * @return passportID */ public static Cookie newCookie(String key, String value) { diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/RequestUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/RequestUtil.java new file mode 100644 index 00000000..eb45c6ac --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/RequestUtil.java @@ -0,0 +1,66 @@ +package ${basePackage}.frame.utils; + +import javax.servlet.http.HttpServletRequest; + +/** + * RequestUtil + * + * @author wangbing + * @version 0.0.1 + * @since 2017-01-01 + */ +public class RequestUtil { + + /** + * 获取请求放IP + * + * @param request + * @return + */ + public static String getIp(HttpServletRequest request) { + String ip = request.getHeader("X-Forwarded-For"); + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + + } else if (ip.length() > 15) { + String[] ips = ip.split(","); + for (int index = 0; index < ips.length; index++) { + String strIp = (String) ips[index]; + if (!("unknown".equalsIgnoreCase(strIp))) { + ip = strIp; + break; + } + } + } + return ip; + } + + /** + * 获取情况方客户端信息 + * + * @param request + * @return + */ + public static String getUserAgent(HttpServletRequest request) { + return request.getHeader("User-Agent"); + } + +} diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/ResourceUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/ResourceUtil.java index ee99f922..77680dc9 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/ResourceUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/ResourceUtil.java @@ -8,6 +8,13 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Resource资源文件工具 @@ -18,6 +25,48 @@ import java.io.InputStream; */ public class ResourceUtil extends ResourceUtils { + /** + * 获取资源目录下所有文件名 如: /modules/dir/ + * + * @param resourcePath 路径 + * @return + */ + public static List getResourceFiles(String resourcePath) { + List result = new ArrayList<>(); + File applicationHome = getApplicationHome(); + if (applicationHome.getAbsolutePath().endsWith(".jar")) { + try { + Pattern pattern = Pattern.compile(".*" + resourcePath + "(.+\\..+)"); + JarFile jarFile = new JarFile(applicationHome); + Enumeration entries = jarFile.entries(); + while (entries.hasMoreElements()) { + JarEntry jarEntry = entries.nextElement(); + String name = jarEntry.getName(); + + if (name.matches(".*" + resourcePath + "(.+\\..+)")) { + Matcher matcher = pattern.matcher(name); + if (matcher.find()) result.add(matcher.group(1)); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } else { + try { + ClassPathResource cpr = new ClassPathResource(resourcePath); + File in = cpr.getFile(); + for (File file : in.listFiles()) { + result.add(file.getName()); + } + return result; + } catch (IOException e) { + e.printStackTrace(); + } + } + + return result; + } + /** * 获取当前运行jar文件 * diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/ResponseUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/ResponseUtil.java index af2ee3c5..0ce3bbfe 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/ResponseUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/ResponseUtil.java @@ -10,7 +10,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; /** - * Base64Util + * ResponseUtil * * @author wangbing * @version 0.0.1 diff --git a/src/main/resources/modules/SpringBoot/java/frame/validation/Dict.java b/src/main/resources/modules/SpringBoot/java/frame/validation/Dict.java index 2f11df22..14f7ce44 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/validation/Dict.java +++ b/src/main/resources/modules/SpringBoot/java/frame/validation/Dict.java @@ -8,7 +8,7 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Constraint(validatedBy = DictValidator.class) public @interface Dict { - String message() default "字典项错误"; + String message() default "字典验证错误"; String name() default ""; diff --git a/src/main/resources/modules/SpringBoot/java/frame/validation/DictValidator.java b/src/main/resources/modules/SpringBoot/java/frame/validation/DictValidator.java index 3e0f1925..8adeb6a2 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/validation/DictValidator.java +++ b/src/main/resources/modules/SpringBoot/java/frame/validation/DictValidator.java @@ -1,5 +1,6 @@ package ${basePackage}.frame.validation; +import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl; import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.utils.StringUtil; import ${basePackage}.module.system.ent.DictItem; @@ -22,11 +23,22 @@ public class DictValidator implements ConstraintValidator { @Override public boolean isValid(String o, ConstraintValidatorContext constraintValidatorContext) { + String messagePrefix = ""; + if (constraintValidatorContext instanceof ConstraintValidatorContextImpl) { + ConstraintValidatorContextImpl validatorContext = (ConstraintValidatorContextImpl) constraintValidatorContext; + if (validatorContext.getConstraintViolationCreationContexts() != null + && validatorContext.getConstraintViolationCreationContexts().size() > 0 + && validatorContext.getConstraintViolationCreationContexts().get(0).getPath() != null) { + messagePrefix = "[" + validatorContext.getConstraintViolationCreationContexts().get(0).getPath().asString() + "]"; + } + } + if (StringUtil.isEmpty(o)) { return true; } else if (name == null) { constraintValidatorContext.disableDefaultConstraintViolation(); - constraintValidatorContext.buildConstraintViolationWithTemplate("字典名称为空").addConstraintViolation(); + + constraintValidatorContext.buildConstraintViolationWithTemplate(messagePrefix + "字典名称为空").addConstraintViolation(); return false; } else { // name 字典名称 @@ -37,7 +49,7 @@ public class DictValidator implements ConstraintValidator { if (dictLoadResponse.hasError()) { constraintValidatorContext.disableDefaultConstraintViolation(); - constraintValidatorContext.buildConstraintViolationWithTemplate("验证字典[" + name + "]值出现异常->" + dictLoadResponse.getErrors().get(0).getMessage()).addConstraintViolation(); + constraintValidatorContext.buildConstraintViolationWithTemplate(messagePrefix + "验证字典[" + name + "]值出现异常->" + dictLoadResponse.getErrors().get(0).getMessage()).addConstraintViolation(); return false; } @@ -53,7 +65,7 @@ public class DictValidator implements ConstraintValidator { return true; } else { constraintValidatorContext.disableDefaultConstraintViolation(); - constraintValidatorContext.buildConstraintViolationWithTemplate("非法的字典[" + name + "]值").addConstraintViolation(); + constraintValidatorContext.buildConstraintViolationWithTemplate(messagePrefix + "不存在于字典[" + name + "]中").addConstraintViolation(); return false; } } diff --git a/src/main/resources/modules/SpringBoot/java/module/req/createRequestClass.ftl b/src/main/resources/modules/SpringBoot/java/module/req/createRequestClass.ftl index 5178e5b4..d766e169 100644 --- a/src/main/resources/modules/SpringBoot/java/module/req/createRequestClass.ftl +++ b/src/main/resources/modules/SpringBoot/java/module/req/createRequestClass.ftl @@ -26,13 +26,13 @@ public class ${table.getCName()}CreateRequest extends BaseRequest { * ${field.fieldComment?default("")} */ <#if field.isMust && !field.fieldType?contains("String")> - @NotNull(message = "${field.fieldComment?default("")}不能为NULL") + @NotNull(message = "[${field.getFName()}]${field.fieldComment?default("")}不能为NULL") <#if field.isMust && field.fieldType?contains("String_")> - @NotEmpty(message = "${field.fieldComment?default("")}不能为空") + @NotEmpty(message = "[${field.getFName()}]${field.fieldComment?default("")}不能为空") <#if field.fieldType?contains("String_") && field.fieldType != 'String_super'> - @Length(min = 0, max = ${field.fieldLength}, message = "${field.fieldComment?default("")}长度不合法(0-${field.fieldLength})") + @Length(min = 0, max = ${field.fieldLength}, message = "[${field.getFName()}]${field.fieldComment?default("")}长度不合法(0-${field.fieldLength})") <#if field.fieldType?contains("Dict")> @Dict(name = "${field.getFieldName()}") diff --git a/src/main/resources/modules/SpringBoot/java/module/req/deleteRequestClass.ftl b/src/main/resources/modules/SpringBoot/java/module/req/deleteRequestClass.ftl index 6375614f..86d9056c 100644 --- a/src/main/resources/modules/SpringBoot/java/module/req/deleteRequestClass.ftl +++ b/src/main/resources/modules/SpringBoot/java/module/req/deleteRequestClass.ftl @@ -16,7 +16,7 @@ public class ${table.getCName()}DeleteRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/req/getRequestClass.ftl b/src/main/resources/modules/SpringBoot/java/module/req/getRequestClass.ftl index 23a67eaf..56463a24 100644 --- a/src/main/resources/modules/SpringBoot/java/module/req/getRequestClass.ftl +++ b/src/main/resources/modules/SpringBoot/java/module/req/getRequestClass.ftl @@ -15,7 +15,7 @@ public class ${table.getCName()}GetRequest extends BaseRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/req/updateRequestClass.ftl b/src/main/resources/modules/SpringBoot/java/module/req/updateRequestClass.ftl index 1abaca6f..e7d098ac 100644 --- a/src/main/resources/modules/SpringBoot/java/module/req/updateRequestClass.ftl +++ b/src/main/resources/modules/SpringBoot/java/module/req/updateRequestClass.ftl @@ -26,13 +26,13 @@ public class ${table.getCName()}UpdateRequest extends BaseUpdateRequest { * ${field.fieldComment?default("")} */ <#if field.isMust && !field.fieldType?contains("String")> - @NotNull(message = "${field.fieldComment?default("")}不能为NULL") + @NotNull(message = "[${field.getFName()}]${field.fieldComment?default("")}不能为NULL") <#if field.isMust && field.fieldType?contains("String_")> - @NotEmpty(message = "${field.fieldComment?default("")}不能为空") + @NotEmpty(message = "[${field.getFName()}]${field.fieldComment?default("")}不能为空") <#if field.fieldType?contains("String_") && field.fieldType != 'String_super'> - @Length(min = 0, max = ${field.fieldLength}, message = "${field.fieldComment?default("")}长度不合法(0-${field.fieldLength})") + @Length(min = 0, max = ${field.fieldLength}, message = "[${field.getFName()}]${field.fieldComment?default("")}长度不合法(0-${field.fieldLength})") <#if field.fieldType?contains("Dict")> @Dict(name = "${field.getFieldName()}") diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/Role.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/Role.java new file mode 100644 index 00000000..0da5675d --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/Role.java @@ -0,0 +1,60 @@ +package ${basePackage}.module.system.ent; + +import ${basePackage}.frame.excel.annotation.ColumnDescription; +import ${basePackage}.frame.excel.annotation.ColumnName; +import ${basePackage}.frame.excel.annotation.SheetName; +import ${basePackage}.frame.base.BaseEntity; + +/** + * ROLE - 角色 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +@SheetName("角色") +public class Role extends BaseEntity { + + /** + * ROLE_NAME - 角色名称 + */ + @ColumnName("角色名称") + @ColumnDescription("") + private String roleName; + /** + * ROLE_CODE - 角色代码 + */ + @ColumnName("角色代码") + @ColumnDescription("") + private String roleCode; + /** + * ROLE_COMMENT - 角色描述 + */ + @ColumnName("角色描述") + @ColumnDescription("") + private String roleComment; + + public String getRoleName() { + return this.roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getRoleCode() { + return this.roleCode; + } + + public void setRoleCode(String roleCode) { + this.roleCode = roleCode; + } + + public String getRoleComment() { + return this.roleComment; + } + + public void setRoleComment(String roleComment) { + this.roleComment = roleComment; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/RoleResource.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/RoleResource.java new file mode 100644 index 00000000..6c53bd0c --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/RoleResource.java @@ -0,0 +1,38 @@ +package ${basePackage}.module.system.ent; + +import ${basePackage}.frame.base.BaseEntity; + +/** + * ROLE_RESOURCE - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public class RoleResource extends BaseEntity { + + /** + * ROLE_ID - 角色主键 + */ + private Long roleId; + /** + * RESOURCE_ID - 资源主键 + */ + private Long resourceId; + + public Long getRoleId() { + return this.roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public Long getResourceId() { + return this.resourceId; + } + + public void setResourceId(Long resourceId) { + this.resourceId = resourceId; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/Tokens.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/Tokens.java index 261c737a..c5b63538 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/ent/Tokens.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/Tokens.java @@ -9,13 +9,19 @@ import ${basePackage}.frame.base.BaseEntity; /** * TOKENS - 通行证 * - * @author author + * @author wangbing * @version 0.0.1 - * @since 2019-12-19 + * @since 2019-12-20 */ @SheetName("通行证") public class Tokens extends BaseEntity { + /** + * TOKEN - 登录令牌 + */ + @ColumnName("登录令牌") + @ColumnDescription("") + private String token; /** * USER_ID - 用户主键 */ @@ -83,6 +89,14 @@ public class Tokens extends BaseEntity { @ColumnDescription("") private String terminalInfo; + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + public Long getUserId() { return this.userId; } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/User.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/User.java new file mode 100644 index 00000000..bead020e --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/User.java @@ -0,0 +1,130 @@ +package ${basePackage}.module.system.ent; + +import ${basePackage}.frame.excel.annotation.ColumnDescription; +import ${basePackage}.frame.excel.annotation.ColumnName; +import ${basePackage}.frame.excel.annotation.SheetName; +import ${basePackage}.frame.base.BaseEntity; + +/** + * USER - 用户 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +@SheetName("用户") +public class User extends BaseEntity { + + /** + * USER_NAME - 用户账户 + */ + @ColumnName("用户账户") + @ColumnDescription("") + private String userName; + /** + * USER_CODE - 用户代码 + */ + @ColumnName("用户代码") + @ColumnDescription("") + private String userCode; + /** + * USER_ALIAS - 用户别名 + */ + @ColumnName("用户别名") + @ColumnDescription("") + private String userAlias; + /** + * USER_PWD - 用户密码 + */ + @ColumnName("用户密码") + @ColumnDescription("") + private String userPwd; + /** + * USER_STATUS - 用户状态 + */ + @ColumnName("用户状态") + @ColumnDescription("") + private String userStatus; + /** + * DEPT_ID - 部门主键 + */ + @ColumnName("部门主键") + @ColumnDescription("") + private Long deptId; + /** + * DEPT_CODE - 部门代码 + */ + @ColumnName("部门代码") + @ColumnDescription("") + private String deptCode; + /** + * DEPT_NAME - 部门名称 + */ + @ColumnName("部门名称") + @ColumnDescription("") + private String deptName; + + public String getUserName() { + return this.userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserCode() { + return this.userCode; + } + + public void setUserCode(String userCode) { + this.userCode = userCode; + } + + public String getUserAlias() { + return this.userAlias; + } + + public void setUserAlias(String userAlias) { + this.userAlias = userAlias; + } + + public String getUserPwd() { + return this.userPwd; + } + + public void setUserPwd(String userPwd) { + this.userPwd = userPwd; + } + + public String getUserStatus() { + return this.userStatus; + } + + public void setUserStatus(String userStatus) { + this.userStatus = userStatus; + } + + public Long getDeptId() { + return this.deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public String getDeptCode() { + return this.deptCode; + } + + public void setDeptCode(String deptCode) { + this.deptCode = deptCode; + } + + public String getDeptName() { + return this.deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/ent/UserRole.java b/src/main/resources/modules/SpringBoot/java/module/system/ent/UserRole.java new file mode 100644 index 00000000..ba8db64e --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/ent/UserRole.java @@ -0,0 +1,38 @@ +package ${basePackage}.module.system.ent; + +import ${basePackage}.frame.base.BaseEntity; + +/** + * USER_ROLE - 用户角色授权 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public class UserRole extends BaseEntity { + + /** + * USER_ID - 用户主键 + */ + private Long userId; + /** + * ROLE_ID - 角色主键 + */ + private Long roleId; + + public Long getUserId() { + return this.userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Long getRoleId() { + return this.roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleManager.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleManager.java new file mode 100644 index 00000000..bca5be8f --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleManager.java @@ -0,0 +1,60 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import ${basePackage}.frame.base.Token; + +/** + * 角色 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public interface RoleManager { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleCreateResponse create(RoleCreateRequest request, Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleDeleteResponse delete(RoleDeleteRequest request, Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleUpdateResponse update(RoleUpdateRequest request, Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleFindResponse find(RoleFindRequest request, Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleGetResponse get(RoleGetRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleManagerImpl.java new file mode 100644 index 00000000..1558b3e9 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleManagerImpl.java @@ -0,0 +1,167 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.frame.utils.IDgenerator; +import ${basePackage}.frame.utils.Message; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.base.Token; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.Role; +import ${basePackage}.module.system.mpr.RoleMapper; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.github.pagehelper.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * ROLE - 角色 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +@Transactional +@Service +public class RoleManagerImpl implements RoleManager { + + @Autowired + private RoleMapper roleMapper; + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleCreateResponse create(RoleCreateRequest request, Token token) { + RoleCreateResponse response = new RoleCreateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long id = IDgenerator.nextId(); + Role entity = MapperUtil.map(request, Role.class); + entity.setId(id); + + long result = roleMapper.insert(entity, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE); + return response; + } + response.setId(id); + + return response; + } + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleDeleteResponse delete(RoleDeleteRequest request, Token token) { + RoleDeleteResponse response = new RoleDeleteResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = roleMapper.delete(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleUpdateResponse update(RoleUpdateRequest request, Token token) { + RoleUpdateResponse response = new RoleUpdateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = roleMapper.update(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public RoleFindResponse find(RoleFindRequest request, Token token) { + RoleFindResponse response = new RoleFindResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + PageHelper.startPage(request.getPageNumber(), request.getPageSize()); + if (StringUtil.isNotEmpty(request.getSortKey())) { + PageHelper.orderBy(request.getSortKey() + " " + request.getSortType()); + } + PageInfo pageInfo = new PageInfo<>(roleMapper.find(request, token)); + + response.setResult(pageInfo.getList()); + response.setTotalCount(pageInfo.getTotal()); + + return response; + } + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public RoleGetResponse get(RoleGetRequest request, Token token) { + RoleGetResponse response = new RoleGetResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + Role po = roleMapper.get(request, token); + + if (po != null) { + response.setRole(po); + } else { + response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE); + } + + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResourceManager.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResourceManager.java new file mode 100644 index 00000000..c5f4ac65 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResourceManager.java @@ -0,0 +1,60 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import ${basePackage}.frame.base.Token; + +/** + * 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public interface RoleResourceManager { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResourceCreateResponse create(RoleResourceCreateRequest request, Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request, Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResourceUpdateResponse update(RoleResourceUpdateRequest request, Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResourceFindResponse find(RoleResourceFindRequest request, Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + RoleResourceGetResponse get(RoleResourceGetRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResourceManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResourceManagerImpl.java new file mode 100644 index 00000000..64784ca6 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/RoleResourceManagerImpl.java @@ -0,0 +1,167 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.frame.utils.IDgenerator; +import ${basePackage}.frame.utils.Message; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.base.Token; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.RoleResource; +import ${basePackage}.module.system.mpr.RoleResourceMapper; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.github.pagehelper.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * ROLE_RESOURCE - 角色资源关系 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +@Transactional +@Service +public class RoleResourceManagerImpl implements RoleResourceManager { + + @Autowired + private RoleResourceMapper roleResourceMapper; + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleResourceCreateResponse create(RoleResourceCreateRequest request, Token token) { + RoleResourceCreateResponse response = new RoleResourceCreateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long id = IDgenerator.nextId(); + RoleResource entity = MapperUtil.map(request, RoleResource.class); + entity.setId(id); + + long result = roleResourceMapper.insert(entity, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE); + return response; + } + response.setId(id); + + return response; + } + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleResourceDeleteResponse delete(RoleResourceDeleteRequest request, Token token) { + RoleResourceDeleteResponse response = new RoleResourceDeleteResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = roleResourceMapper.delete(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public RoleResourceUpdateResponse update(RoleResourceUpdateRequest request, Token token) { + RoleResourceUpdateResponse response = new RoleResourceUpdateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = roleResourceMapper.update(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public RoleResourceFindResponse find(RoleResourceFindRequest request, Token token) { + RoleResourceFindResponse response = new RoleResourceFindResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + PageHelper.startPage(request.getPageNumber(), request.getPageSize()); + if (StringUtil.isNotEmpty(request.getSortKey())) { + PageHelper.orderBy(request.getSortKey() + " " + request.getSortType()); + } + PageInfo pageInfo = new PageInfo<>(roleResourceMapper.find(request, token)); + + response.setResult(pageInfo.getList()); + response.setTotalCount(pageInfo.getTotal()); + + return response; + } + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public RoleResourceGetResponse get(RoleResourceGetRequest request, Token token) { + RoleResourceGetResponse response = new RoleResourceGetResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + RoleResource po = roleResourceMapper.get(request, token); + + if (po != null) { + response.setRoleResource(po); + } else { + response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE); + } + + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserManager.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserManager.java new file mode 100644 index 00000000..dd5fdcd0 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserManager.java @@ -0,0 +1,60 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import ${basePackage}.frame.base.Token; + +/** + * 用户 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public interface UserManager { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserCreateResponse create(UserCreateRequest request, Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserDeleteResponse delete(UserDeleteRequest request, Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserUpdateResponse update(UserUpdateRequest request, Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserFindResponse find(UserFindRequest request, Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserGetResponse get(UserGetRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserManagerImpl.java new file mode 100644 index 00000000..a0f18fa7 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserManagerImpl.java @@ -0,0 +1,167 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.frame.utils.IDgenerator; +import ${basePackage}.frame.utils.Message; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.base.Token; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.User; +import ${basePackage}.module.system.mpr.UserMapper; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.github.pagehelper.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * USER - 用户 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +@Transactional +@Service +public class UserManagerImpl implements UserManager { + + @Autowired + private UserMapper userMapper; + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public UserCreateResponse create(UserCreateRequest request, Token token) { + UserCreateResponse response = new UserCreateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long id = IDgenerator.nextId(); + User entity = MapperUtil.map(request, User.class); + entity.setId(id); + + long result = userMapper.insert(entity, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE); + return response; + } + response.setId(id); + + return response; + } + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public UserDeleteResponse delete(UserDeleteRequest request, Token token) { + UserDeleteResponse response = new UserDeleteResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = userMapper.delete(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public UserUpdateResponse update(UserUpdateRequest request, Token token) { + UserUpdateResponse response = new UserUpdateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = userMapper.update(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public UserFindResponse find(UserFindRequest request, Token token) { + UserFindResponse response = new UserFindResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + PageHelper.startPage(request.getPageNumber(), request.getPageSize()); + if (StringUtil.isNotEmpty(request.getSortKey())) { + PageHelper.orderBy(request.getSortKey() + " " + request.getSortType()); + } + PageInfo pageInfo = new PageInfo<>(userMapper.find(request, token)); + + response.setResult(pageInfo.getList()); + response.setTotalCount(pageInfo.getTotal()); + + return response; + } + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public UserGetResponse get(UserGetRequest request, Token token) { + UserGetResponse response = new UserGetResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + User po = userMapper.get(request, token); + + if (po != null) { + response.setUser(po); + } else { + response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE); + } + + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserRoleManager.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserRoleManager.java new file mode 100644 index 00000000..6723967c --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserRoleManager.java @@ -0,0 +1,60 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import ${basePackage}.frame.base.Token; + +/** + * 用户角色授权 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public interface UserRoleManager { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserRoleCreateResponse create(UserRoleCreateRequest request, Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserRoleDeleteResponse delete(UserRoleDeleteRequest request, Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserRoleUpdateResponse update(UserRoleUpdateRequest request, Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserRoleFindResponse find(UserRoleFindRequest request, Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return + */ + UserRoleGetResponse get(UserRoleGetRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserRoleManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserRoleManagerImpl.java new file mode 100644 index 00000000..d38cc8a8 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mgr/UserRoleManagerImpl.java @@ -0,0 +1,167 @@ +package ${basePackage}.module.system.mgr; + +import ${basePackage}.frame.utils.IDgenerator; +import ${basePackage}.frame.utils.Message; +import ${basePackage}.frame.base.ErrorType; +import ${basePackage}.frame.base.Token; +import ${basePackage}.frame.utils.MapperUtil; +import ${basePackage}.frame.utils.ValidationUtil; +import ${basePackage}.module.system.ent.UserRole; +import ${basePackage}.module.system.mpr.UserRoleMapper; +import ${basePackage}.module.system.req.*; +import ${basePackage}.module.system.rsp.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.github.pagehelper.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * USER_ROLE - 用户角色授权 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +@Transactional +@Service +public class UserRoleManagerImpl implements UserRoleManager { + + @Autowired + private UserRoleMapper userRoleMapper; + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public UserRoleCreateResponse create(UserRoleCreateRequest request, Token token) { + UserRoleCreateResponse response = new UserRoleCreateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long id = IDgenerator.nextId(); + UserRole entity = MapperUtil.map(request, UserRole.class); + entity.setId(id); + + long result = userRoleMapper.insert(entity, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.CREATE_FAILURE); + return response; + } + response.setId(id); + + return response; + } + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public UserRoleDeleteResponse delete(UserRoleDeleteRequest request, Token token) { + UserRoleDeleteResponse response = new UserRoleDeleteResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = userRoleMapper.delete(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.DELETE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + public UserRoleUpdateResponse update(UserRoleUpdateRequest request, Token token) { + UserRoleUpdateResponse response = new UserRoleUpdateResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + long result = userRoleMapper.update(request, token); + if (1L != result) { + response.addError(ErrorType.BUSINESS_ERROR, Message.UPDATE_FAILURE); + return response; + } + response.setResult(result); + + return response; + } + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public UserRoleFindResponse find(UserRoleFindRequest request, Token token) { + UserRoleFindResponse response = new UserRoleFindResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + PageHelper.startPage(request.getPageNumber(), request.getPageSize()); + if (StringUtil.isNotEmpty(request.getSortKey())) { + PageHelper.orderBy(request.getSortKey() + " " + request.getSortType()); + } + PageInfo pageInfo = new PageInfo<>(userRoleMapper.find(request, token)); + + response.setResult(pageInfo.getList()); + response.setTotalCount(pageInfo.getTotal()); + + return response; + } + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 响应 + */ + @Transactional(readOnly = true) + public UserRoleGetResponse get(UserRoleGetRequest request, Token token) { + UserRoleGetResponse response = new UserRoleGetResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + UserRole po = userRoleMapper.get(request, token); + + if (po != null) { + response.setUserRole(po); + } else { + response.addError(ErrorType.BUSINESS_ERROR, Message.GET_FAILURE); + } + + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleMapper.java b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleMapper.java new file mode 100644 index 00000000..fcfdf8e4 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleMapper.java @@ -0,0 +1,74 @@ +package ${basePackage}.module.system.mpr; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +import ${basePackage}.module.system.ent.Role; +import ${basePackage}.module.system.req.*; +import ${basePackage}.frame.base.Token; + +/** + * ROLE - 角色 + * + * @author wangbing + * @date 2019-12-20 + */ +@Mapper +public interface RoleMapper { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insert(@Param("request") Role request, @Param("token") Token token); + + /** + * 批量插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insertBatch(@Param("list") List request, @Param("token") Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long delete(@Param("request") RoleDeleteRequest request, @Param("token") Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long update(@Param("request") RoleUpdateRequest request, @Param("token") Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + List find(@Param("request") RoleFindRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + Role get(@Param("request") RoleGetRequest request, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleMapper_MySQL.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleMapper_MySQL.xml new file mode 100644 index 00000000..7b1e7979 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleMapper_MySQL.xml @@ -0,0 +1,133 @@ + + + + + `SYS_ROLE` + + + `ID`,`ROLE_NAME`,`ROLE_CODE`,`ROLE_COMMENT`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + + + + + + + + + + + + + + + + + + + + + INSERT INTO + + ( + + ) + VALUES + ( + ${r"#"}{request.id}, + ${r"#"}{request.roleName,jdbcType=VARCHAR}, + ${r"#"}{request.roleCode,jdbcType=VARCHAR}, + ${r"#"}{request.roleComment,jdbcType=VARCHAR}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + INSERT INTO + + ( + + ) + VALUES + + ( + ${r"#"}{item.id}, + ${r"#"}{item.roleName,jdbcType=VARCHAR}, + ${r"#"}{item.roleCode,jdbcType=VARCHAR}, + ${r"#"}{item.roleComment,jdbcType=VARCHAR}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + + UPDATE + + SET `IS_DELETED` = 1 + WHERE `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + + + + UPDATE + + SET + `ROLE_NAME` = ${r"#"}{request.roleName,jdbcType=VARCHAR}, + `ROLE_CODE` = ${r"#"}{request.roleCode,jdbcType=VARCHAR}, + `ROLE_COMMENT` = ${r"#"}{request.roleComment,jdbcType=VARCHAR}, + `ROW_VERSION` = `ROW_VERSION` + 1, + `LAST_UPDATE_BY` = ${r"#"}{token.userId}, + `LAST_UPDATE_TIME` = sysdate() + WHERE + `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + AND `ROW_VERSION` = ${r"#"}{request.rowVersion} + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResourceMapper.java b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResourceMapper.java new file mode 100644 index 00000000..2a81f08c --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResourceMapper.java @@ -0,0 +1,74 @@ +package ${basePackage}.module.system.mpr; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +import ${basePackage}.module.system.ent.RoleResource; +import ${basePackage}.module.system.req.*; +import ${basePackage}.frame.base.Token; + +/** + * ROLE_RESOURCE - 角色资源关系 + * + * @author wangbing + * @date 2019-12-20 + */ +@Mapper +public interface RoleResourceMapper { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insert(@Param("request") RoleResource request, @Param("token") Token token); + + /** + * 批量插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insertBatch(@Param("list") List request, @Param("token") Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long delete(@Param("request") RoleResourceDeleteRequest request, @Param("token") Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long update(@Param("request") RoleResourceUpdateRequest request, @Param("token") Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + List find(@Param("request") RoleResourceFindRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + RoleResource get(@Param("request") RoleResourceGetRequest request, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResourceMapper_MySQL.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResourceMapper_MySQL.xml new file mode 100644 index 00000000..0b98fccc --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/RoleResourceMapper_MySQL.xml @@ -0,0 +1,126 @@ + + + + + `SYS_ROLE_RESOURCE` + + + `ID`,`ROLE_ID`,`RESOURCE_ID`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + + + + + + + + + + + + + + + + + + + + INSERT INTO + + ( + + ) + VALUES + ( + ${r"#"}{request.id}, + ${r"#"}{request.roleId,jdbcType=BIGINT}, + ${r"#"}{request.resourceId,jdbcType=BIGINT}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + INSERT INTO + + ( + + ) + VALUES + + ( + ${r"#"}{item.id}, + ${r"#"}{item.roleId,jdbcType=BIGINT}, + ${r"#"}{item.resourceId,jdbcType=BIGINT}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + + UPDATE + + SET `IS_DELETED` = 1 + WHERE `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + + + + UPDATE + + SET + `ROLE_ID` = ${r"#"}{request.roleId,jdbcType=BIGINT}, + `RESOURCE_ID` = ${r"#"}{request.resourceId,jdbcType=BIGINT}, + `ROW_VERSION` = `ROW_VERSION` + 1, + `LAST_UPDATE_BY` = ${r"#"}{token.userId}, + `LAST_UPDATE_TIME` = sysdate() + WHERE + `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + AND `ROW_VERSION` = ${r"#"}{request.rowVersion} + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/TokensMapper_MySQL.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/TokensMapper_MySQL.xml index afec4c54..63d53949 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/mpr/TokensMapper_MySQL.xml +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/TokensMapper_MySQL.xml @@ -7,11 +7,12 @@ `SYS_TOKENS` - `ID`,`USER_ID`,`USER_NAME`,`LOGIN_TIME`,`VALID_TIME`,`VALID`,`DEPT_ID`,`DEPT_CODE`,`DEPT_NAME`,`TERMINAL_TYPE`,`TERMINAL_IP`,`TERMINAL_INFO`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + `ID`,`TOKEN`,`USER_ID`,`USER_NAME`,`LOGIN_TIME`,`VALID_TIME`,`VALID`,`DEPT_ID`,`DEPT_CODE`,`DEPT_NAME`,`TERMINAL_TYPE`,`TERMINAL_IP`,`TERMINAL_INFO`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + @@ -38,6 +39,9 @@ WHERE `IS_DELETED` = 0 + + AND `TOKEN` = ${r"#"}{request.token} + AND `USER_ID` = ${r"#"}{request.userId} @@ -94,6 +98,7 @@ VALUES ( ${r"#"}{request.id}, + ${r"#"}{request.token,jdbcType=VARCHAR}, ${r"#"}{request.userId,jdbcType=BIGINT}, ${r"#"}{request.userName,jdbcType=VARCHAR}, ${r"#"}{request.loginTime,jdbcType=TIMESTAMP}, @@ -124,6 +129,7 @@ ( ${r"#"}{item.id}, + ${r"#"}{item.token,jdbcType=VARCHAR}, ${r"#"}{item.userId,jdbcType=BIGINT}, ${r"#"}{item.userName,jdbcType=VARCHAR}, ${r"#"}{item.loginTime,jdbcType=TIMESTAMP}, @@ -157,6 +163,7 @@ UPDATE SET + `TOKEN` = ${r"#"}{request.token,jdbcType=VARCHAR}, `USER_ID` = ${r"#"}{request.userId,jdbcType=BIGINT}, `USER_NAME` = ${r"#"}{request.userName,jdbcType=VARCHAR}, `LOGIN_TIME` = ${r"#"}{request.loginTime,jdbcType=TIMESTAMP}, diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserMapper.java b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserMapper.java new file mode 100644 index 00000000..057435ee --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserMapper.java @@ -0,0 +1,74 @@ +package ${basePackage}.module.system.mpr; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +import ${basePackage}.module.system.ent.User; +import ${basePackage}.module.system.req.*; +import ${basePackage}.frame.base.Token; + +/** + * USER - 用户 + * + * @author wangbing + * @date 2019-12-20 + */ +@Mapper +public interface UserMapper { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insert(@Param("request") User request, @Param("token") Token token); + + /** + * 批量插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insertBatch(@Param("list") List request, @Param("token") Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long delete(@Param("request") UserDeleteRequest request, @Param("token") Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long update(@Param("request") UserUpdateRequest request, @Param("token") Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + List find(@Param("request") UserFindRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + User get(@Param("request") UserGetRequest request, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserMapper_MySQL.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserMapper_MySQL.xml new file mode 100644 index 00000000..adcce906 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserMapper_MySQL.xml @@ -0,0 +1,165 @@ + + + + + `SYS_USER` + + + `ID`,`USER_NAME`,`USER_CODE`,`USER_ALIAS`,`USER_PWD`,`USER_STATUS`,`DEPT_ID`,`DEPT_CODE`,`DEPT_NAME`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO + + ( + + ) + VALUES + ( + ${r"#"}{request.id}, + ${r"#"}{request.userName,jdbcType=VARCHAR}, + ${r"#"}{request.userCode,jdbcType=VARCHAR}, + ${r"#"}{request.userAlias,jdbcType=VARCHAR}, + ${r"#"}{request.userPwd,jdbcType=VARCHAR}, + ${r"#"}{request.userStatus,jdbcType=VARCHAR}, + ${r"#"}{request.deptId,jdbcType=BIGINT}, + ${r"#"}{request.deptCode,jdbcType=VARCHAR}, + ${r"#"}{request.deptName,jdbcType=VARCHAR}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + INSERT INTO + + ( + + ) + VALUES + + ( + ${r"#"}{item.id}, + ${r"#"}{item.userName,jdbcType=VARCHAR}, + ${r"#"}{item.userCode,jdbcType=VARCHAR}, + ${r"#"}{item.userAlias,jdbcType=VARCHAR}, + ${r"#"}{item.userPwd,jdbcType=VARCHAR}, + ${r"#"}{item.userStatus,jdbcType=VARCHAR}, + ${r"#"}{item.deptId,jdbcType=BIGINT}, + ${r"#"}{item.deptCode,jdbcType=VARCHAR}, + ${r"#"}{item.deptName,jdbcType=VARCHAR}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + + UPDATE + + SET `IS_DELETED` = 1 + WHERE `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + + + + UPDATE + + SET + `USER_NAME` = ${r"#"}{request.userName,jdbcType=VARCHAR}, + `USER_CODE` = ${r"#"}{request.userCode,jdbcType=VARCHAR}, + `USER_ALIAS` = ${r"#"}{request.userAlias,jdbcType=VARCHAR}, + `USER_PWD` = ${r"#"}{request.userPwd,jdbcType=VARCHAR}, + `USER_STATUS` = ${r"#"}{request.userStatus,jdbcType=VARCHAR}, + `DEPT_ID` = ${r"#"}{request.deptId,jdbcType=BIGINT}, + `DEPT_CODE` = ${r"#"}{request.deptCode,jdbcType=VARCHAR}, + `DEPT_NAME` = ${r"#"}{request.deptName,jdbcType=VARCHAR}, + `ROW_VERSION` = `ROW_VERSION` + 1, + `LAST_UPDATE_BY` = ${r"#"}{token.userId}, + `LAST_UPDATE_TIME` = sysdate() + WHERE + `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + AND `ROW_VERSION` = ${r"#"}{request.rowVersion} + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserRoleMapper.java b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserRoleMapper.java new file mode 100644 index 00000000..61646015 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserRoleMapper.java @@ -0,0 +1,74 @@ +package ${basePackage}.module.system.mpr; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +import ${basePackage}.module.system.ent.UserRole; +import ${basePackage}.module.system.req.*; +import ${basePackage}.frame.base.Token; + +/** + * USER_ROLE - 用户角色授权 + * + * @author wangbing + * @date 2019-12-20 + */ +@Mapper +public interface UserRoleMapper { + + /** + * 插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insert(@Param("request") UserRole request, @Param("token") Token token); + + /** + * 批量插入 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long insertBatch(@Param("list") List request, @Param("token") Token token); + + /** + * 逻辑删除 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long delete(@Param("request") UserRoleDeleteRequest request, @Param("token") Token token); + + /** + * 更新 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回数量 + */ + long update(@Param("request") UserRoleUpdateRequest request, @Param("token") Token token); + + /** + * 查询 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + List find(@Param("request") UserRoleFindRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param request 请求对象 + * @param token 令牌 + * @return 返回对象 + */ + UserRole get(@Param("request") UserRoleGetRequest request, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserRoleMapper_MySQL.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserRoleMapper_MySQL.xml new file mode 100644 index 00000000..9371177b --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/UserRoleMapper_MySQL.xml @@ -0,0 +1,126 @@ + + + + + `SYS_USER_ROLE` + + + `ID`,`USER_ID`,`ROLE_ID`,`ROW_VERSION`,`IS_DELETED`,`CREATE_BY`,`CREATE_TIME`,`LAST_UPDATE_BY`,`LAST_UPDATE_TIME` + + + + + + + + + + + + + + + + + + + + INSERT INTO + + ( + + ) + VALUES + ( + ${r"#"}{request.id}, + ${r"#"}{request.userId,jdbcType=BIGINT}, + ${r"#"}{request.roleId,jdbcType=BIGINT}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + INSERT INTO + + ( + + ) + VALUES + + ( + ${r"#"}{item.id}, + ${r"#"}{item.userId,jdbcType=BIGINT}, + ${r"#"}{item.roleId,jdbcType=BIGINT}, + 0, + 0, + ${r"#"}{token.userId,jdbcType=NUMERIC}, + sysdate(), + NULL, + NULL + ) + + + + + UPDATE + + SET `IS_DELETED` = 1 + WHERE `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + + + + UPDATE + + SET + `USER_ID` = ${r"#"}{request.userId,jdbcType=BIGINT}, + `ROLE_ID` = ${r"#"}{request.roleId,jdbcType=BIGINT}, + `ROW_VERSION` = `ROW_VERSION` + 1, + `LAST_UPDATE_BY` = ${r"#"}{token.userId}, + `LAST_UPDATE_TIME` = sysdate() + WHERE + `IS_DELETED` = 0 + AND `ID` = ${r"#"}{request.id} + AND `ROW_VERSION` = ${r"#"}{request.rowVersion} + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/AuthLoginRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/AuthLoginRequest.java index fefce354..a2c62e71 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/AuthLoginRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/AuthLoginRequest.java @@ -2,6 +2,8 @@ package ${basePackage}.module.system.req; import ${basePackage}.frame.base.BaseRequest; +import javax.validation.constraints.NotBlank; + /** * AuthLoginRequest - 登录 * @@ -11,4 +13,25 @@ import ${basePackage}.frame.base.BaseRequest; */ public class AuthLoginRequest extends BaseRequest { + @NotBlank(message = "[username]用户名不能为空") + private String username; + + @NotBlank(message = "[password]用户密码不能为空") + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java index b975b4d3..2f20ae12 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictCreateRequest.java @@ -2,7 +2,7 @@ package ${basePackage}.module.system.req; import org.hibernate.validator.constraints.Length; import ${basePackage}.frame.base.BaseRequest; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** @@ -17,28 +17,28 @@ public class DictCreateRequest extends BaseRequest { /** * 字典名称 */ - @NotEmpty(message = "字典名称不能为空") + @NotBlank(message = "[dictName]字典名称不能为空") @Length(min = 1, max = 50, message = "字典名称长度不合法(1-50)") private String dictName; /** * 字典代码 */ - @NotEmpty(message = "字典描述不能为空") + @NotBlank(message = "[dictComment]字典描述不能为空") @Length(min = 1, max = 50, message = "字典描述长度不合法(1-50)") private String dictComment; /** * 字典版本 */ - @NotEmpty(message = "字典版本不能为空") + @NotBlank(message = "[version]字典版本不能为空") @Length(min = 1, max = 50, message = "字典版本长度不合法(1-50)") private String version; /** * 是否有效 */ - @NotNull(message = "是否有效不能为NULL") + @NotNull(message = "[valid]是否有效不能为NULL") private Boolean valid; public String getDictName() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictDeleteRequest.java index 8d3cccaf..55df6771 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictDeleteRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictDeleteRequest.java @@ -16,7 +16,7 @@ public class DictDeleteRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictGetRequest.java index 2201d69a..a01be571 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictGetRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictGetRequest.java @@ -16,7 +16,7 @@ public class DictGetRequest extends BaseRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemCreateRequest.java index 505969c4..bbac7a0c 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemCreateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemCreateRequest.java @@ -17,31 +17,31 @@ public class DictItemCreateRequest extends BaseRequest { /** * 字典名称 */ - @NotNull(message = "字典名称不能为空") + @NotNull(message = "[dictName]字典名称不能为空") private String dictName; /** * 字典键 */ - @Length(min = 1, max = 10, message = "字典键长度不合法(1-10)") + @Length(min = 1, max = 10, message = "[key]字典键长度不合法(1-10)") private String key; /** * 字典值 */ - @Length(min = 1, max = 100, message = "字典值长度不合法(1-100)") + @Length(min = 1, max = 100, message = "[value]字典值长度不合法(1-100)") private String value; /** * 排序 */ - @NotNull(message = "字典项排序值不能为空") + @NotNull(message = "[sort]字典项排序值不能为空") private Integer sort; /** * 是否有效 */ - @NotNull(message = "是否有效不能为空") + @NotNull(message = "[valid]是否有效不能为空") private Boolean valid; public String getDictName() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemDeleteRequest.java index 46985524..d7bec3ea 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemDeleteRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemDeleteRequest.java @@ -16,7 +16,7 @@ public class DictItemDeleteRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemGetRequest.java index 9a7ffb71..223abf71 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemGetRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemGetRequest.java @@ -16,7 +16,7 @@ public class DictItemGetRequest extends BaseRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemUpdateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemUpdateRequest.java index 28de3bee..2e4ac96c 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemUpdateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictItemUpdateRequest.java @@ -17,31 +17,31 @@ public class DictItemUpdateRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为NULL") + @NotNull(message = "[id]主键不能为NULL") private Long id; /** * 字典键 */ - @Length(min = 0, max = 10, message = "字典键长度不合法(0-10)") + @Length(min = 0, max = 10, message = "[key]字典键长度不合法(0-10)") private String key; /** * 字典值 */ - @Length(min = 0, max = 100, message = "字典值长度不合法(0-100)") + @Length(min = 0, max = 100, message = "[value]字典值长度不合法(0-100)") private String value; /** * 排序 */ - @NotNull(message = "字典项排序值不能为空") + @NotNull(message = "[sort]字典项排序值不能为空") private Integer sort; /** * 是否有效 */ - @NotNull(message = "是否有效不能为空") + @NotNull(message = "[valid]是否有效不能为空") private Boolean valid; public Long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictLoadRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictLoadRequest.java index 1ab756d2..15514e0d 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictLoadRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictLoadRequest.java @@ -14,7 +14,7 @@ import javax.validation.constraints.NotNull; */ public class DictLoadRequest extends BaseRequest { - @NotBlank(message = "字典名称不能为空") + @NotBlank(message = "[dictName]字典名称不能为空") private String dictName; public String getDictName() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/DictUpdateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/DictUpdateRequest.java index b693341e..5e12598b 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/DictUpdateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/DictUpdateRequest.java @@ -3,7 +3,7 @@ package ${basePackage}.module.system.req; import org.hibernate.validator.constraints.Length; import ${basePackage}.frame.base.BaseUpdateRequest; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** @@ -18,34 +18,34 @@ public class DictUpdateRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为NULL") + @NotNull(message = "[id]主键不能为NULL") private Long id; /** * 字典名称 */ - @NotEmpty(message = "字典名称不能为空") - @Length(min = 0, max = 50, message = "字典名称长度不合法(0-50)") + @NotBlank(message = "[dictName]字典名称不能为空") + @Length(min = 0, max = 50, message = "[dictName]字典名称长度不合法(0-50)") private String dictName; /** * 字典代码 */ - @NotEmpty(message = "字典描述不能为空") - @Length(min = 0, max = 50, message = "字典描述长度不合法(0-50)") + @NotBlank(message = "[dictComment]字典描述不能为空") + @Length(min = 0, max = 50, message = "[dictComment]字典描述长度不合法(0-50)") private String dictComment; /** * 字典版本 */ - @NotEmpty(message = "字典版本不能为空") - @Length(min = 0, max = 50, message = "字典版本长度不合法(0-50)") + @NotBlank(message = "[version]字典版本不能为空") + @Length(min = 0, max = 50, message = "[version]字典版本长度不合法(0-50)") private String version; /** * 是否有效 */ - @NotNull(message = "是否有效不能为NULL") + @NotNull(message = "[valid]是否有效不能为NULL") private Boolean valid; public Long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/FileCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/FileCreateRequest.java index b84b4825..210f1342 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/FileCreateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/FileCreateRequest.java @@ -3,7 +3,7 @@ package ${basePackage}.module.system.req; import ${basePackage}.frame.validation.Dict; import ${basePackage}.frame.base.BaseRequest; import javax.validation.constraints.NotNull; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import org.hibernate.validator.constraints.Length; /** @@ -18,7 +18,7 @@ public class FileCreateRequest extends BaseRequest { /** * 文件名称 */ - @NotEmpty(message = "文件名称不能为空") + @NotBlank(message = "[name]文件名称不能为空") @Length(min = 0, max = 255, message = "文件名称长度不合法(0-255)") private String name; @@ -31,19 +31,19 @@ public class FileCreateRequest extends BaseRequest { /** * 扩展属性1 */ - @Length(min = 0, max = 50, message = "扩展属性1长度不合法(0-50)") + @Length(min = 0, max = 50, message = "[attribute1]扩展属性1长度不合法(0-50)") private String attribute1; /** * 扩展属性2 */ - @Length(min = 0, max = 50, message = "扩展属性2长度不合法(0-50)") + @Length(min = 0, max = 50, message = "[attribute2]扩展属性2长度不合法(0-50)") private String attribute2; /** * 存放地址 */ - @Length(min = 0, max = 500, message = "存放地址长度不合法(0-500)") + @Length(min = 0, max = 500, message = "[location]存放地址长度不合法(0-500)") private String location; /** @@ -55,7 +55,7 @@ public class FileCreateRequest extends BaseRequest { /** * 下载地址 */ - @Length(min = 0, max = 500, message = "下载地址长度不合法(0-500)") + @Length(min = 0, max = 500, message = "[urlDownload]下载地址长度不合法(0-500)") private String urlDownload; public String getName() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/FileDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/FileDeleteRequest.java index 19b6d4a9..6c1adeee 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/FileDeleteRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/FileDeleteRequest.java @@ -15,7 +15,7 @@ public class FileDeleteRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/FileDownloadRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/FileDownloadRequest.java index 1c92e935..44f22660 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/FileDownloadRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/FileDownloadRequest.java @@ -16,7 +16,7 @@ public class FileDownloadRequest extends BaseRequest { /** * 文件ID */ - @NotNull(message = "文件ID不能为空") + @NotNull(message = "[fileId]文件主键不能为空") private Long fileId; public Long getFileId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/FileGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/FileGetRequest.java index 3d9c455c..5ff36031 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/FileGetRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/FileGetRequest.java @@ -16,7 +16,7 @@ public class FileGetRequest extends BaseRequest { /** * 文件ID */ - @NotNull(message = "文件ID不能为空") + @NotNull(message = "[id]文件主键不能为空") private Long id; public Long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/FileUploadRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/FileUploadRequest.java index 0c447b42..43c579db 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/FileUploadRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/FileUploadRequest.java @@ -2,7 +2,7 @@ package ${basePackage}.module.system.req; import ${basePackage}.frame.base.BaseRequest; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; /** @@ -17,8 +17,8 @@ public class FileUploadRequest extends BaseRequest { /** * 文件名称(包含.) */ - @NotEmpty(message = "文件名不能为空") - @Pattern(regexp = ".*\\.*$", message = "文件后缀错误") + @NotBlank(message = "[fileName]文件名不能为空") + @Pattern(regexp = ".*\\.*$", message = "[fileName]文件后缀错误") private String fileName; /** diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceCreateRequest.java index 94a6e9ad..257b2832 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceCreateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceCreateRequest.java @@ -2,7 +2,7 @@ package ${basePackage}.module.system.req; import ${basePackage}.frame.base.BaseRequest; import javax.validation.constraints.NotNull; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import org.hibernate.validator.constraints.Length; import ${basePackage}.frame.validation.Dict; @@ -18,27 +18,27 @@ public class ResourceCreateRequest extends BaseRequest { /** * 资源内容 */ - @NotEmpty(message = "资源内容不能为空") + @NotBlank(message = "[value]资源内容不能为空") @Length(min = 0, max = 100, message = "资源内容长度不合法(0-100)") private String value; /** * 资源描述 */ - @Length(min = 0, max = 255, message = "资源描述长度不合法(0-255)") + @Length(min = 0, max = 255, message = "[comment]资源描述长度不合法(0-255)") private String comment; /** * 资源类型 */ - @NotEmpty(message = "资源类型不能为NULL") + @NotBlank(message = "[resourceType]资源类型不能为NULL") @Dict(name = "RESOURCE_TYPE") private String resourceType; /** * 是否有效 */ - @NotNull(message = "是否有效不能为NULL") + @NotNull(message = "[valid]是否有效不能为NULL") private Boolean valid; public String getValue() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceDeleteRequest.java index 90aa32ab..c37e6cc4 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceDeleteRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceDeleteRequest.java @@ -15,7 +15,7 @@ public class ResourceDeleteRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceGetRequest.java index e4e82742..c6cbbe57 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceGetRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceGetRequest.java @@ -15,7 +15,7 @@ public class ResourceGetRequest extends BaseRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceUpdateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceUpdateRequest.java index 3d80e303..29199a50 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceUpdateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/ResourceUpdateRequest.java @@ -3,7 +3,7 @@ package ${basePackage}.module.system.req; import ${basePackage}.frame.base.BaseUpdateRequest; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.Length; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import ${basePackage}.frame.validation.Dict; /** @@ -18,33 +18,33 @@ public class ResourceUpdateRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为NULL") + @NotNull(message = "[id]主键不能为NULL") private Long id; /** * 资源内容 */ - @NotEmpty(message = "资源内容不能为空") + @NotBlank(message = "[value]资源内容不能为空") @Length(min = 0, max = 100, message = "资源内容长度不合法(0-100)") private String value; /** * 资源描述 */ - @Length(min = 0, max = 255, message = "资源描述长度不合法(0-255)") + @Length(min = 0, max = 255, message = "[comment]资源描述长度不合法(0-255)") private String comment; /** * 资源类型 */ - @NotNull(message = "资源类型不能为NULL") + @NotNull(message = "[resourceType]资源类型不能为NULL") @Dict(name = "RESOURCE_TYPE") private String resourceType; /** * 是否有效 */ - @NotNull(message = "是否有效不能为NULL") + @NotNull(message = "[valid]是否有效不能为NULL") private Boolean valid; public Long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensBuildRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensBuildRequest.java new file mode 100644 index 00000000..febe9c5f --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensBuildRequest.java @@ -0,0 +1,30 @@ +package ${basePackage}.module.system.req; + +import ${basePackage}.frame.base.BaseFindRequest; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * TokensRequest - 通行证查询 + * + * @author wangbing + * @version 0.0.1 + * @since 2019-12-20 + */ +public class TokensBuildRequest extends BaseFindRequest { + + /** + * 登录令牌 + */ + @NotBlank(message = "登录令牌不能为空") + private String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensCreateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensCreateRequest.java index 8c3f18cb..c82f0103 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensCreateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensCreateRequest.java @@ -10,41 +10,48 @@ import ${basePackage}.frame.validation.Dict; /** * TokensCreateRequest - 通行证新增 * - * @author author + * @author wangbing * @version 0.0.1 - * @since 2019-12-19 + * @since 2019-12-20 */ public class TokensCreateRequest extends BaseRequest { + /** + * 登录令牌 + */ + @NotEmpty(message = "[token]登录令牌不能为空") + @Length(min = 0, max = 50, message = "[token]登录令牌长度不合法(0-50)") + private String token; + /** * 用户主键 */ - @NotNull(message = "用户主键不能为NULL") + @NotNull(message = "[userId]用户主键不能为NULL") private Long userId; /** * 用户名称 */ - @NotEmpty(message = "用户名称不能为空") - @Length(min = 0, max = 50, message = "用户名称长度不合法(0-50)") + @NotEmpty(message = "[userName]用户名称不能为空") + @Length(min = 0, max = 50, message = "[userName]用户名称长度不合法(0-50)") private String userName; /** * 登录时间 */ - @NotNull(message = "登录时间不能为NULL") + @NotNull(message = "[loginTime]登录时间不能为NULL") private Date loginTime; /** * 有效时间 */ - @NotNull(message = "有效时间不能为NULL") + @NotNull(message = "[validTime]有效时间不能为NULL") private Date validTime; /** * 是否有效 */ - @NotNull(message = "是否有效不能为NULL") + @NotNull(message = "[valid]是否有效不能为NULL") private Boolean valid; /** @@ -55,13 +62,13 @@ public class TokensCreateRequest extends BaseRequest { /** * 部门代码 */ - @Length(min = 0, max = 50, message = "部门代码长度不合法(0-50)") + @Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)") private String deptCode; /** * 部门名称 */ - @Length(min = 0, max = 100, message = "部门名称长度不合法(0-100)") + @Length(min = 0, max = 100, message = "[deptName]部门名称长度不合法(0-100)") private String deptName; /** @@ -73,15 +80,23 @@ public class TokensCreateRequest extends BaseRequest { /** * 终端地址 */ - @Length(min = 0, max = 50, message = "终端地址长度不合法(0-50)") + @Length(min = 0, max = 50, message = "[terminalIp]终端地址长度不合法(0-50)") private String terminalIp; /** * 终端信息 */ - @Length(min = 0, max = 100, message = "终端信息长度不合法(0-100)") + @Length(min = 0, max = 500, message = "[terminalInfo]终端信息长度不合法(0-500)") private String terminalInfo; + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + public Long getUserId() { return this.userId; } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensDeleteRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensDeleteRequest.java index 48f01fcf..a4de8b08 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensDeleteRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensDeleteRequest.java @@ -15,7 +15,7 @@ public class TokensDeleteRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensFindRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensFindRequest.java index 7486e89e..8d1302ac 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensFindRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensFindRequest.java @@ -7,12 +7,17 @@ import ${basePackage}.frame.validation.Dict; /** * TokensRequest - 通行证查询 * - * @author author + * @author wangbing * @version 0.0.1 - * @since 2019-12-19 + * @since 2019-12-20 */ public class TokensFindRequest extends BaseFindRequest { + /** + * 登录令牌 + */ + private String token; + /** * 用户主键 */ @@ -69,6 +74,14 @@ public class TokensFindRequest extends BaseFindRequest { */ private String terminalInfo; + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + public Long getUserId() { return this.userId; } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensGetRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensGetRequest.java index 53ca09dc..0b816cb7 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensGetRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensGetRequest.java @@ -15,7 +15,7 @@ public class TokensGetRequest extends BaseRequest { /** * 主键 */ - @NotNull(message = "主键不能为空") + @NotNull(message = "[id]主键不能为空") private long id; public long getId() { diff --git a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensUpdateRequest.java b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensUpdateRequest.java index 2bd86caa..74a8981b 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/req/TokensUpdateRequest.java +++ b/src/main/resources/modules/SpringBoot/java/module/system/req/TokensUpdateRequest.java @@ -10,47 +10,54 @@ import ${basePackage}.frame.validation.Dict; /** * TokensUpdateRequest - 通行证更新 * - * @author author + * @author wangbing * @version 0.0.1 - * @since 2019-12-19 + * @since 2019-12-20 */ public class TokensUpdateRequest extends BaseUpdateRequest { /** * 主键 */ - @NotNull(message = "主键不能为NULL") + @NotNull(message = "[id]主键不能为NULL") private Long id; + /** + * 登录令牌 + */ + @NotEmpty(message = "[token]登录令牌不能为空") + @Length(min = 0, max = 50, message = "[token]登录令牌长度不合法(0-50)") + private String token; + /** * 用户主键 */ - @NotNull(message = "用户主键不能为NULL") + @NotNull(message = "[userId]用户主键不能为NULL") private Long userId; /** * 用户名称 */ - @NotEmpty(message = "用户名称不能为空") - @Length(min = 0, max = 50, message = "用户名称长度不合法(0-50)") + @NotEmpty(message = "[userName]用户名称不能为空") + @Length(min = 0, max = 50, message = "[userName]用户名称长度不合法(0-50)") private String userName; /** * 登录时间 */ - @NotNull(message = "登录时间不能为NULL") + @NotNull(message = "[loginTime]登录时间不能为NULL") private Date loginTime; /** * 有效时间 */ - @NotNull(message = "有效时间不能为NULL") + @NotNull(message = "[validTime]有效时间不能为NULL") private Date validTime; /** * 是否有效 */ - @NotNull(message = "是否有效不能为NULL") + @NotNull(message = "[valid]是否有效不能为NULL") private Boolean valid; /** @@ -61,13 +68,13 @@ public class TokensUpdateRequest extends BaseUpdateRequest { /** * 部门代码 */ - @Length(min = 0, max = 50, message = "部门代码长度不合法(0-50)") + @Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)") private String deptCode; /** * 部门名称 */ - @Length(min = 0, max = 100, message = "部门名称长度不合法(0-100)") + @Length(min = 0, max = 100, message = "[deptName]部门名称长度不合法(0-100)") private String deptName; /** @@ -79,13 +86,13 @@ public class TokensUpdateRequest extends BaseUpdateRequest { /** * 终端地址 */ - @Length(min = 0, max = 50, message = "终端地址长度不合法(0-50)") + @Length(min = 0, max = 50, message = "[terminalIp]终端地址长度不合法(0-50)") private String terminalIp; /** * 终端信息 */ - @Length(min = 0, max = 100, message = "终端信息长度不合法(0-100)") + @Length(min = 0, max = 500, message = "[terminalInfo]终端信息长度不合法(0-500)") private String terminalInfo; public Long getId() { @@ -96,6 +103,14 @@ public class TokensUpdateRequest extends BaseUpdateRequest { this.id = id; } + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + public Long getUserId() { return this.userId; } diff --git a/src/main/resources/modules/SpringBoot/java/module/system/rsp/TokensBuildResponse.java b/src/main/resources/modules/SpringBoot/java/module/system/rsp/TokensBuildResponse.java new file mode 100644 index 00000000..9a8f3584 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/system/rsp/TokensBuildResponse.java @@ -0,0 +1,27 @@ +package ${basePackage}.module.system.rsp; + +import ${basePackage}.frame.base.BaseResponse; +import ${basePackage}.frame.base.Token; + +/** + * TokensGetResponse - 通行证 + * + * @author author + * @version 0.0.1 + * @since 2019-12-19 + */ +public class TokensBuildResponse extends BaseResponse { + + /** + * 通行证 + */ + private Token token; + + public Token getToken() { + return token; + } + + public void setToken(Token token) { + this.token = token; + } +} diff --git a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl index b3ba5502..2e194ce3 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl @@ -128,4 +128,7 @@ web.login.page=/login.htm # 拦截验证 web.url.auth.included=/,/**/*.htm # 直接放行 -web.url.auth.excluded=/login.htm \ No newline at end of file +web.url.auth.excluded=/login.htm +# 超级管理员 +web.url.auth.admin=admin +web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5 \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/resources/application-prod.ftl b/src/main/resources/modules/SpringBoot/resources/application-prod.ftl index 396665ff..a9222f1f 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-prod.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-prod.ftl @@ -128,4 +128,7 @@ web.login.page=/login.htm # 拦截验证 web.url.auth.included=/,/**/*.htm # 直接放行 -web.url.auth.excluded=/login.htm \ No newline at end of file +web.url.auth.excluded=/login.htm +# 超级管理员 +web.url.auth.admin=admin +web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5 \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/system/ALL_TABLE_MySQL.sql b/src/main/resources/modules/SpringBoot/resources/dbtool/system/ALL_TABLE_MySQL.sql index 3d4ebb18..26b154e5 100644 --- a/src/main/resources/modules/SpringBoot/resources/dbtool/system/ALL_TABLE_MySQL.sql +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/system/ALL_TABLE_MySQL.sql @@ -68,8 +68,8 @@ PRIMARY KEY (`ID`) -- ---------------------------- -- Table structure for RESOURCE - 资源 -- Target : MySQL --- Author : author --- Date: : 2019-12-19 +-- Author : wangbing +-- Date: : 2019-12-20 -- ---------------------------- CREATE TABLE `SYS_RESOURCE` ( `ID` BIGINT(20) NOT NULL COMMENT '主键', @@ -77,6 +77,8 @@ CREATE TABLE `SYS_RESOURCE` ( `COMMENT` VARCHAR(250) COMMENT '资源描述', `RESOURCE_TYPE` VARCHAR(20) NOT NULL COMMENT '资源类型', `VALID` TINYINT(1) NOT NULL COMMENT '是否有效', + `NODE` TINYINT(1) NOT NULL COMMENT '是否节点', + `SUP_ID` BIGINT(20) COMMENT '上级主键', `ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本', `IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除', `CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户', @@ -85,15 +87,15 @@ CREATE TABLE `SYS_RESOURCE` ( `LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源'; - -- ---------------------------- -- Table structure for TOKENS - 通行证 -- Target : MySQL --- Author : author --- Date: : 2019-12-19 +-- Author : wangbing +-- Date: : 2019-12-20 -- ---------------------------- CREATE TABLE `SYS_TOKENS` ( `ID` BIGINT(20) NOT NULL COMMENT '主键', + `TOKEN` VARCHAR(50) NOT NULL COMMENT '登录令牌', `USER_ID` BIGINT(20) NOT NULL COMMENT '用户主键', `USER_NAME` VARCHAR(50) NOT NULL COMMENT '用户名称', `LOGIN_TIME` DATETIME NOT NULL COMMENT '登录时间', @@ -104,7 +106,7 @@ CREATE TABLE `SYS_TOKENS` ( `DEPT_NAME` VARCHAR(100) COMMENT '部门名称', `TERMINAL_TYPE` VARCHAR(20) COMMENT '终端类型', `TERMINAL_IP` VARCHAR(50) COMMENT '终端地址', - `TERMINAL_INFO` VARCHAR(100) COMMENT '终端信息', + `TERMINAL_INFO` VARCHAR(500) COMMENT '终端信息', `ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本', `IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除', `CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户', diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/system/TOKENS_MySQL.sql b/src/main/resources/modules/SpringBoot/resources/dbtool/system/TOKENS_MySQL.sql index f19d703b..f3e01ccf 100644 --- a/src/main/resources/modules/SpringBoot/resources/dbtool/system/TOKENS_MySQL.sql +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/system/TOKENS_MySQL.sql @@ -1,11 +1,12 @@ --- ---------------------------- +-- ---------------------------- -- Table structure for TOKENS - 通行证 -- Target : MySQL --- Author : author --- Date: : 2019-12-19 +-- Author : wangbing +-- Date: : 2019-12-20 -- ---------------------------- CREATE TABLE `SYS_TOKENS` ( `ID` BIGINT(20) NOT NULL COMMENT '主键', + `TOKEN` VARCHAR(50) NOT NULL COMMENT '登录令牌', `USER_ID` BIGINT(20) NOT NULL COMMENT '用户主键', `USER_NAME` VARCHAR(50) NOT NULL COMMENT '用户名称', `LOGIN_TIME` DATETIME NOT NULL COMMENT '登录时间', @@ -16,7 +17,7 @@ CREATE TABLE `SYS_TOKENS` ( `DEPT_NAME` VARCHAR(100) COMMENT '部门名称', `TERMINAL_TYPE` VARCHAR(20) COMMENT '终端类型', `TERMINAL_IP` VARCHAR(50) COMMENT '终端地址', - `TERMINAL_INFO` VARCHAR(100) COMMENT '终端信息', + `TERMINAL_INFO` VARCHAR(500) COMMENT '终端信息', `ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本', `IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除', `CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户', diff --git a/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml b/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml index cbd13f7e..9d8ac998 100644 --- a/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml +++ b/src/main/resources/modules/SpringBoot/resources/dbtool/wadmin.xml @@ -1,14 +1,15 @@ wadmin -com.example -author +${basePackage} +wangbing false +true 系统 SYS_ -system_ +system true @@ -35,7 +36,7 @@ - + @@ -81,6 +82,8 @@ + + @@ -105,6 +108,7 @@
+ @@ -115,7 +119,7 @@ - + diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl index 5f84263a..56c72f42 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl @@ -11,6 +11,7 @@ background-color="#252a2f" text-color="#d6d6d6" active-text-color="#ffd04b"> + <#if sysMD>