├── .gitignore ├── LICENSE ├── README.md ├── pom.xml ├── src ├── main │ ├── java │ │ └── com │ │ │ ├── example │ │ │ ├── Application.java │ │ │ ├── common │ │ │ │ ├── IBaseService.java │ │ │ │ ├── ResponseBean.java │ │ │ │ └── impl │ │ │ │ │ └── BaseServiceImpl.java │ │ │ ├── config │ │ │ │ ├── DataBaseConfig.java │ │ │ │ ├── ExceptionAdvice.java │ │ │ │ └── WebMvcConfig.java │ │ │ ├── constant │ │ │ │ ├── Constant.java │ │ │ │ └── DataBaseEnum.java │ │ │ ├── controller │ │ │ │ ├── DataBaseController.java │ │ │ │ ├── IndexController.java │ │ │ │ └── RestartController.java │ │ │ ├── dao │ │ │ │ ├── GeneratorDao.java │ │ │ │ ├── MySqlGeneratorDao.java │ │ │ │ ├── OracleGeneratorDao.java │ │ │ │ ├── PostgreSqlGeneratorDao.java │ │ │ │ └── SqlServerGeneratorDao.java │ │ │ ├── exception │ │ │ │ ├── CustomException.java │ │ │ │ └── SystemException.java │ │ │ ├── run │ │ │ │ └── FileRun.java │ │ │ └── util │ │ │ │ ├── SafeProperties.java │ │ │ │ └── ZipUtil.java │ │ │ └── generator │ │ │ └── CustomGeneratorFacade.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ ├── banner.txt │ │ ├── config │ │ └── generator.properties │ │ ├── mapper │ │ ├── MySQLGeneratorDao.xml │ │ ├── OracleGeneratorDao.xml │ │ ├── PostgreSQLGeneratorDao.xml │ │ └── SQLServerGeneratorDao.xml │ │ ├── sql │ │ └── MySQL.sql │ │ ├── static │ │ ├── css │ │ │ ├── admin.css │ │ │ ├── amazeui.css │ │ │ ├── amazeui.jqgrid.min.css │ │ │ ├── component.css │ │ │ ├── core.css │ │ │ ├── font-awesome.css │ │ │ ├── index.css │ │ │ ├── menu.css │ │ │ └── page │ │ │ │ ├── form.css │ │ │ │ └── typography.css │ │ ├── element-ui │ │ │ ├── fonts │ │ │ │ ├── element-icons.ttf │ │ │ │ └── element-icons.woff │ │ │ ├── index.css │ │ │ └── index.js │ │ ├── favicon.ico │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ │ ├── img │ │ │ └── avatar-1.jpg │ │ └── js │ │ │ ├── amazeui.min.js │ │ │ ├── axios.min.js │ │ │ ├── blockUI.js │ │ │ ├── jquery-2.1.0.js │ │ │ ├── moment.min.js │ │ │ └── vue.min.js │ │ └── templates │ │ ├── common │ │ └── common.html │ │ ├── config.html │ │ ├── index.html │ │ └── table.html └── test │ └── java │ └── com │ └── example │ ├── ApplicationTests.java │ ├── base │ └── BaseTest.java │ ├── generator │ └── GeneratorCode.java │ └── test │ ├── TestRole.java │ └── TestSafeProperties.java └── template ├── LayUI ├── java │ └── ${basepackage_dir} │ │ ├── controller │ │ └── ${className}Controller.java │ │ ├── dao │ │ └── ${className}Dao.java │ │ ├── dto │ │ ├── custom │ │ │ └── ${className}Dto.java │ │ └── domain │ │ │ └── ${className}DtoBase.java │ │ └── service │ │ ├── ${className}Service.java │ │ └── impl │ │ └── ${className}ServiceImpl.java ├── java_copyright.include ├── macro.include ├── resources │ ├── i18n │ │ └── ${classNameFirstLower}_zh_CN.properties │ └── mapper │ │ └── ${className}Dao.xml └── webapp │ ├── WEB-INF │ └── ${namespace} │ │ └── ${modulepackage} │ │ └── ${classNameFirstLower} │ │ └── ${classNameFirstLower}.jsp │ └── js │ └── ${modulepackage} │ └── ${classNameFirstLower} │ └── ${classNameFirstLower}.js └── RESTful ├── java └── ${basepackage_dir} │ ├── controller │ └── ${className}Controller.java │ ├── dao │ └── ${className}Dao.java │ ├── dto │ ├── custom │ │ └── ${className}Dto.java │ └── domain │ │ └── ${className}DtoBase.java │ └── service │ ├── I${className}Service.java │ └── impl │ └── ${className}ServiceImpl.java ├── java_copyright.include ├── macro.include ├── resources ├── i18n │ └── ${classNameFirstLower}_zh_CN.properties └── mapper │ └── ${className}Dao.xml └── vue ├── HelloWorld.vue ├── api └── ${moduleName} │ └── ${classNameFirstLower}.js └── views └── modules └── ${moduleName} ├── ${classNameFirstLower}.vue └── ${classNameFirstLower}Edit.vue /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /temp/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /build/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 随心 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ViewGenerator 2 | 3 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 4 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dolyw/ViewGenerator/pulls) 5 | [![GitHub stars](https://img.shields.io/github/stars/dolyw/ViewGenerator.svg?style=social&label=Stars)](https://github.com/dolyw/ViewGenerator) 6 | [![GitHub forks](https://img.shields.io/github/forks/dolyw/ViewGenerator.svg?style=social&label=Fork)](https://github.com/dolyw/ViewGenerator) 7 | 8 | > 可视化自定义模板代码生成系统 9 | 10 | #### 项目相关 11 | 12 | 版本 | 描述 13 | ----|------ 14 | SpringBoot1.5 | Test类生成代码 15 | SpringBoot2.1 | 可视化界面及Test类两种 16 | SpringBoot2.5 | 可视化界面及Test类,在线切换数据库 17 | 18 | #### 项目介绍 19 | 20 | ViewGenerator是一个基于SpringBoot & FreeMarker的自定义模板代码生成系统,用于快速构建中小型项目,稳定、简单、快速,使我们摆脱那些重复劳动,专注于业务代码的编写,能在短短几十秒钟内实现一套简单的基础代码(自动生成Model、Mapper、MapperXML、Service、ServiceImpl、Controller、JS、Vue等自定义模板代码) 21 | 22 | 1. 可视化界面,上手操作简单 23 | 2. 高度灵活的代码模板配置(提供两套模板参考),可以自行添加N套代码模板 24 | 3. 支持多数据库,在线切换数据库,支持在线生成代码且可提供ZIP文件下载 25 | 26 | #### 软件架构 27 | 28 | SpringBoot + Mybatis + PageHelper + 通用Mapper + Thymeleaf(Amaze UI(布局) + Element UI(数据操作Vue.js)) 29 | 30 | #### 安装教程 31 | 32 | 1. 配置resource下config/generator.properties数据库信息启动Application即可,也可以本地直接执行Test类在src\test\java\com\example\generator\GeneratorCode 33 | 2. 模板提供两套示例LayUI和RESTful,自行添加模板路径\template\ 34 | 3. 可视化界面操作访问[http://localhost:8080](http://localhost:8080),可以在线设置生成代码的配置 35 | 4. 服务器部署,下载代码到本地打包成jar包上传到服务器启动即可 36 | 5. 服务器部署后需要自行复制template文件夹到与jar包同级目录下 37 | 38 | #### 使用说明 39 | 40 | ``` 41 | 数据库要配置好,且必须有帐号权限(resource下config/generator.properties数据库信息) 42 | ``` 43 | 44 | ##### 系统预览 45 | ``` 46 | 启动首页界面 47 | ``` 48 | ![image text](https://docs.dolyw.com/Project/ViewGenerator/image/20190406001.png) 49 | ``` 50 | 生成代码界面如下 51 | ``` 52 | ![image text](https://docs.dolyw.com/Project/ViewGenerator/image/20190406002.png) 53 | ``` 54 | 查看表详细信息界面如下 55 | ``` 56 | ![image text](https://docs.dolyw.com/Project/ViewGenerator/image/20190406003.png) 57 | ``` 58 | 输入表名生成代码界面如下 59 | ``` 60 | ![image text](https://docs.dolyw.com/Project/ViewGenerator/image/20190406004.png) 61 | ``` 62 | 配置更新界面如下 63 | ``` 64 | ![image text](https://docs.dolyw.com/Project/ViewGenerator/image/20190406005.png) 65 | 66 | #### 搭建参考 67 | 68 | 1. 感谢zeng1994的Java实现将文件或者文件夹压缩成zip:[https://www.cnblogs.com/zeng1994/p/7862288.html](https://www.cnblogs.com/zeng1994/p/7862288.html) 69 | 70 | #### 参与贡献 71 | 72 | 1. Fork 本项目 73 | 2. 新建 Feat_xxx 分支 74 | 3. 提交代码 75 | 4. 新建 Pull Request -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | ViewGenerator 8 | 1.0 9 | jar 10 | 11 | ViewGenerator 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.5.6 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 1.3.2 26 | 1.1.10 27 | 1.2.3 28 | 1.2.3 29 | 1.2.47 30 | 2.3.23 31 | 1.3.6 32 | 23.0 33 | 3.7 34 | 2.7 35 | 4.0.6 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter 42 | 43 | 44 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-starter-web 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-thymeleaf 67 | 68 | 73 | 74 | 75 | 76 | mysql 77 | mysql-connector-java 78 | 79 | 84 | 89 | 93 | 94 | 95 | 96 | org.mybatis.spring.boot 97 | mybatis-spring-boot-starter 98 | ${mybatis.version} 99 | 100 | 101 | 102 | 103 | com.alibaba 104 | druid-spring-boot-starter 105 | ${druid.version} 106 | 107 | 108 | 109 | 110 | com.github.pagehelper 111 | pagehelper-spring-boot-starter 112 | ${pagehelper.version} 113 | 114 | 115 | 116 | 117 | tk.mybatis 118 | mapper-spring-boot-starter 119 | ${mapper.version} 120 | 121 | 122 | 123 | 124 | com.alibaba 125 | fastjson 126 | ${fastjson.version} 127 | 128 | 129 | 130 | 131 | org.freemarker 132 | freemarker 133 | ${freemarker.version} 134 | 135 | 136 | com.googlecode.rapid-framework 137 | rapid-generator 138 | ${rapid.version} 139 | 140 | 145 | 146 | 147 | 152 | 153 | 154 | 155 | org.apache.commons 156 | commons-lang3 157 | ${commons-lang3.version} 158 | 159 | 160 | 161 | 162 | commons-io 163 | commons-io 164 | ${commons-io.version} 165 | 166 | 167 | 168 | 169 | cn.hutool 170 | hutool-all 171 | 5.7.2 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | org.springframework.boot 180 | spring-boot-maven-plugin 181 | 182 | 183 | 184 | org.apache.maven.plugins 185 | maven-compiler-plugin 186 | 187 | ${java.version} 188 | ${java.version} 189 | ${project.build.sourceEncoding} 190 | 191 | 192 | 193 | 194 | org.apache.maven.plugins 195 | maven-javadoc-plugin 196 | 3.0.0 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /src/main/java/com/example/Application.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import cn.hutool.setting.dialect.Props; 4 | import com.example.constant.Constant; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.ConfigurableApplicationContext; 8 | import org.springframework.context.annotation.PropertySource; 9 | 10 | import java.io.File; 11 | import java.util.concurrent.ArrayBlockingQueue; 12 | import java.util.concurrent.ExecutorService; 13 | import java.util.concurrent.ThreadPoolExecutor; 14 | import java.util.concurrent.TimeUnit; 15 | 16 | /** 17 | * Application 18 | * 19 | * @author wliduo[i@dolyw.com] 20 | * @date 2018/11/16 19:29 21 | */ 22 | @SpringBootApplication 23 | @tk.mybatis.spring.annotation.MapperScan({"com.example.mapper", "com.example.dao"}) 24 | /*@PropertySource(value = {"classpath:config/generator.properties"})*/ 25 | public class Application { 26 | 27 | public static String[] args; 28 | public static ConfigurableApplicationContext context; 29 | 30 | public static void main(String[] args) { 31 | SpringApplication application = new SpringApplication(Application.class); 32 | application.setDefaultProperties(config()); 33 | Application.args = args; 34 | Application.context = application.run(args); 35 | } 36 | 37 | /** 38 | * 配置选择 39 | * 40 | * @param 41 | * @return cn.hutool.setting.dialect.Props 42 | * @throws 43 | * @author wliduo[i@dolyw.com] 44 | * @date 2021/11/17 13:50 45 | */ 46 | public static Props config() { 47 | File file = new File(Constant.CONFIG_PATH_TEMP); 48 | if (file.exists()) { 49 | return new Props(Constant.CONFIG_PATH_TEMP); 50 | } else { 51 | return new Props("classpath:config/generator.properties"); 52 | } 53 | } 54 | 55 | /** 56 | * 重启项目方法,注意,必须将maven的spring-boot-devtools开发热部署包去除 57 | * 不然重启后ConfigurableApplicationContext会为空 58 | * 59 | * https://blog.csdn.net/weixin_44695125/article/details/108059877 60 | */ 61 | public static void restart() { 62 | ExecutorService threadPool = new ThreadPoolExecutor(1, 1, 0, 63 | TimeUnit.SECONDS, new ArrayBlockingQueue<>(1), new ThreadPoolExecutor.DiscardOldestPolicy()); 64 | threadPool.execute(() -> { 65 | // SpringApplication.exit(context); 66 | context.close(); 67 | SpringApplication application = new SpringApplication(Application.class); 68 | application.setDefaultProperties(config()); 69 | Application.context = application.run(args); 70 | }); 71 | threadPool.shutdown(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/example/common/IBaseService.java: -------------------------------------------------------------------------------- 1 | package com.example.common; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.apache.ibatis.session.RowBounds; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * IBaseService 10 | * 11 | * @author wliduo[i@dolyw.com] 12 | * @date 2018/8/9 15:45 13 | */ 14 | public interface IBaseService { 15 | 16 | // Select 17 | 18 | /** 19 | * 根据实体中的属性值进行查询,查询条件使用等号 20 | * 21 | * @param record 22 | * @return java.util.List 23 | * @author wliduo[i@dolyw.com] 24 | * @date 2018/8/9 15:43 25 | */ 26 | List select(T record); 27 | 28 | /** 29 | * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号 30 | * 31 | * @param key 32 | * @return T 33 | * @author wliduo[i@dolyw.com] 34 | * @date 2018/8/9 15:43 35 | */ 36 | T selectByPrimaryKey(Object key); 37 | 38 | /** 39 | * 查询全部结果,select(null)方法能达到同样的效果 40 | * 41 | * @param 42 | * @return java.util.List 43 | * @author wliduo[i@dolyw.com] 44 | * @date 2018/8/9 15:43 45 | */ 46 | List selectAll(); 47 | 48 | /** 49 | * 根据实体中的属性进行查询,只能有一个返回值,有多个结果是抛出异常,查询条件使用等号 50 | * 51 | * @param record 52 | * @return T 53 | * @author wliduo[i@dolyw.com] 54 | * @date 2018/8/9 15:43 55 | */ 56 | T selectOne(T record); 57 | 58 | /** 59 | * 根据实体中的属性查询总数,查询条件使用等号 60 | * 61 | * @param record 62 | * @return int 63 | * @author wliduo[i@dolyw.com] 64 | * @date 2018/8/9 15:43 65 | */ 66 | int selectCount(T record); 67 | 68 | // Insert 69 | 70 | /** 71 | * 保存一个实体,null的属性也会保存,不会使用数据库默认值 72 | * 73 | * @param record 74 | * @return int 75 | * @author wliduo[i@dolyw.com] 76 | * @date 2018/8/9 15:43 77 | */ 78 | int insert(T record); 79 | 80 | /** 81 | * 保存一个实体,null的属性不会保存,会使用数据库默认值 82 | * 83 | * @param record 84 | * @return int 85 | * @author wliduo[i@dolyw.com] 86 | * @date 2018/8/9 15:43 87 | */ 88 | int insertSelective(T record); 89 | 90 | // Update 91 | 92 | /** 93 | * 根据主键更新实体全部字段,null值会被更新 94 | * 95 | * @param record 96 | * @return int 97 | * @author wliduo[i@dolyw.com] 98 | * @date 2018/8/9 15:43 99 | */ 100 | int updateByPrimaryKey(T record); 101 | 102 | /** 103 | * 根据主键更新属性不为null的值 104 | * 105 | * @param record 106 | * @return int 107 | * @author wliduo[i@dolyw.com] 108 | * @date 2018/8/9 15:43 109 | */ 110 | int updateByPrimaryKeySelective(T record); 111 | 112 | // Delete 113 | 114 | /** 115 | * 根据实体属性作为条件进行删除,查询条件使用等号 116 | * 117 | * @param record 118 | * @return int 119 | * @author wliduo[i@dolyw.com] 120 | * @date 2018/8/9 15:43 121 | */ 122 | int delete(T record); 123 | 124 | /** 125 | * 根据主键字段进行删除,方法参数必须包含完整的主键属性 126 | * 127 | * @param key 128 | * @return int 129 | * @author wliduo[i@dolyw.com] 130 | * @date 2018/8/9 15:44 131 | */ 132 | int deleteByPrimaryKey(Object key); 133 | 134 | // Example 135 | 136 | /** 137 | * 根据Example条件进行查询,这个查询支持通过Example类指定查询列,通过selectProperties方法指定查询列 138 | * 139 | * @param example 140 | * @return java.util.List 141 | * @author wliduo[i@dolyw.com] 142 | * @date 2018/8/9 15:44 143 | */ 144 | List selectByExample(Object example); 145 | 146 | /** 147 | * 根据Example条件进行查询总数 148 | * 149 | * @param example 150 | * @return int 151 | * @author wliduo[i@dolyw.com] 152 | * @date 2018/8/9 15:44 153 | */ 154 | int selectCountByExample(Object example); 155 | 156 | /** 157 | * 根据Example条件更新实体record包含的全部属性,null值会被更新 158 | * 159 | * @param record 160 | * @param example 161 | * @return int 162 | * @author wliduo[i@dolyw.com] 163 | * @date 2018/8/9 15:44 164 | */ 165 | int updateByExample(@Param("record") T record, @Param("example") Object example); 166 | 167 | /** 168 | * 根据Example条件更新实体record包含的不是null的属性值 169 | * 170 | * @param record 171 | * @param example 172 | * @return int 173 | * @author wliduo[i@dolyw.com] 174 | * @date 2018/8/9 15:44 175 | */ 176 | int updateByExampleSelective(@Param("record") T record, @Param("example") Object example); 177 | 178 | /** 179 | * 根据Example条件删除数据 180 | * 181 | * @param example 182 | * @return int 183 | * @author wliduo[i@dolyw.com] 184 | * @date 2018/8/9 15:44 185 | */ 186 | int deleteByExample(Object example); 187 | 188 | // RowBounds 189 | 190 | /** 191 | * 根据实体属性和RowBounds进行分页查询 192 | * 193 | * @param record 194 | * @param rowBounds 195 | * @return java.util.List 196 | * @author wliduo[i@dolyw.com] 197 | * @date 2018/8/9 15:44 198 | */ 199 | List selectByRowBounds(T record, RowBounds rowBounds); 200 | 201 | /** 202 | * 根据example条件和RowBounds进行分页查询 203 | * 204 | * @param example 205 | * @param rowBounds 206 | * @return java.util.List 207 | * @author wliduo[i@dolyw.com] 208 | * @date 2018/8/9 15:44 209 | */ 210 | List selectByExampleAndRowBounds(Object example, RowBounds rowBounds); 211 | } 212 | -------------------------------------------------------------------------------- /src/main/java/com/example/common/ResponseBean.java: -------------------------------------------------------------------------------- 1 | package com.example.common; 2 | 3 | /** 4 | * ResponseBean 5 | * 6 | * @author wliduo[i@dolyw.com] 7 | * @date 2018/8/30 11:39 8 | */ 9 | public class ResponseBean { 10 | /** 11 | * HTTP状态码 12 | */ 13 | private Integer code; 14 | 15 | /** 16 | * 返回信息 17 | */ 18 | private String msg; 19 | 20 | /** 21 | * 返回的数据 22 | */ 23 | private Object data; 24 | 25 | public ResponseBean(int code, String msg, Object data) { 26 | this.code = code; 27 | this.msg = msg; 28 | this.data = data; 29 | } 30 | 31 | public Integer getCode() { 32 | return code; 33 | } 34 | 35 | public void setCode(Integer code) { 36 | this.code = code; 37 | } 38 | 39 | public String getMsg() { 40 | return msg; 41 | } 42 | 43 | public void setMsg(String msg) { 44 | this.msg = msg; 45 | } 46 | 47 | public Object getData() { 48 | return data; 49 | } 50 | 51 | public void setData(Object data) { 52 | this.data = data; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/example/common/impl/BaseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.common.impl; 2 | 3 | import com.example.common.IBaseService; 4 | import org.apache.ibatis.session.RowBounds; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import tk.mybatis.mapper.common.Mapper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * BaseServiceImpl 12 | * 13 | * @author wliduo[i@dolyw.com] 14 | * @date 2018/8/9 15:45 15 | */ 16 | public abstract class BaseServiceImpl implements IBaseService { 17 | 18 | @Autowired 19 | protected Mapper mapper; 20 | 21 | public Mapper getMapper() { 22 | return mapper; 23 | } 24 | 25 | @Override 26 | public List select(T record) { 27 | return mapper.select(record); 28 | } 29 | 30 | @Override 31 | public T selectByPrimaryKey(Object key) { 32 | return mapper.selectByPrimaryKey(key); 33 | } 34 | 35 | @Override 36 | public List selectAll() { 37 | return mapper.selectAll(); 38 | } 39 | 40 | @Override 41 | public T selectOne(T record) { 42 | return mapper.selectOne(record); 43 | } 44 | 45 | @Override 46 | public int selectCount(T record) { 47 | return mapper.selectCount(record); 48 | } 49 | 50 | @Override 51 | public int insert(T record) { 52 | return mapper.insert(record); 53 | } 54 | 55 | @Override 56 | public int insertSelective(T record) { 57 | return mapper.insertSelective(record); 58 | } 59 | 60 | @Override 61 | public int updateByPrimaryKey(T record) { 62 | return mapper.updateByPrimaryKey(record); 63 | } 64 | 65 | @Override 66 | public int updateByPrimaryKeySelective(T record) { 67 | return mapper.updateByPrimaryKeySelective(record); 68 | } 69 | 70 | @Override 71 | public int delete(T record) { 72 | return mapper.delete(record); 73 | } 74 | 75 | @Override 76 | public int deleteByPrimaryKey(Object key) { 77 | return mapper.deleteByPrimaryKey(key); 78 | } 79 | 80 | @Override 81 | public List selectByExample(Object example) { 82 | return mapper.selectByExample(example); 83 | } 84 | 85 | @Override 86 | public int selectCountByExample(Object example) { 87 | return mapper.selectCountByExample(example); 88 | } 89 | 90 | @Override 91 | public int updateByExample(T record, Object example) { 92 | return mapper.updateByExample(record, example); 93 | } 94 | 95 | @Override 96 | public int updateByExampleSelective(T record, Object example) { 97 | return mapper.updateByExampleSelective(record, example); 98 | } 99 | 100 | @Override 101 | public int deleteByExample(Object example) { 102 | return mapper.deleteByExample(example); 103 | } 104 | 105 | @Override 106 | public List selectByRowBounds(T record, RowBounds rowBounds) { 107 | return mapper.selectByRowBounds(record, rowBounds); 108 | } 109 | 110 | @Override 111 | public List selectByExampleAndRowBounds(Object example, RowBounds rowBounds) { 112 | return mapper.selectByExampleAndRowBounds(example, rowBounds); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/example/config/DataBaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.config; 2 | 3 | import com.example.constant.DataBaseEnum; 4 | import com.example.dao.*; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Primary; 10 | 11 | /** 12 | * Dao配置注入 13 | * 14 | * @author wliduo[i@dolyw.com] 15 | * @date 2019/4/5 17:56 16 | */ 17 | @Configuration 18 | public class DataBaseConfig { 19 | 20 | @Value("${jdbc_driver}") 21 | private String driver; 22 | 23 | @Autowired 24 | private MySqlGeneratorDao mySqlGeneratorDao; 25 | 26 | @Autowired 27 | private OracleGeneratorDao oracleGeneratorDao; 28 | 29 | @Autowired 30 | private PostgreSqlGeneratorDao postgreSqlGeneratorDao; 31 | 32 | @Autowired 33 | private SqlServerGeneratorDao sqlServerGeneratorDao; 34 | 35 | /** 36 | * 根据驱动判断注入那个类型数据库 37 | * 38 | * @param 39 | * @return com.example.dao.GeneratorDao 40 | * @throws 41 | * @author wliduo[i@dolyw.com] 42 | * @date 2019/4/5 17:59 43 | */ 44 | @Bean 45 | @Primary 46 | public GeneratorDao getGeneratorDao() { 47 | if (driver.indexOf(DataBaseEnum.MYSQL.getValue()) >= 0) { 48 | return mySqlGeneratorDao; 49 | } else if (driver.indexOf(DataBaseEnum.ORACLE.getValue()) >= 0) { 50 | return oracleGeneratorDao; 51 | } else if (driver.indexOf(DataBaseEnum.POSTGRESQL.getValue()) >= 0) { 52 | return postgreSqlGeneratorDao; 53 | } else if (driver.indexOf(DataBaseEnum.SQLSERVER.getValue()) >= 0) { 54 | return sqlServerGeneratorDao; 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/example/config/ExceptionAdvice.java: -------------------------------------------------------------------------------- 1 | package com.example.config; 2 | 3 | import com.example.common.ResponseBean; 4 | import com.example.exception.CustomException; 5 | import com.example.exception.SystemException; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.ResponseStatus; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | import org.springframework.web.servlet.NoHandlerFoundException; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | 14 | /** 15 | * 异常控制处理器 16 | * 17 | * @author wliduo[i@dolyw.com] 18 | * @date 2018/8/30 14:02 19 | */ 20 | @RestControllerAdvice 21 | public class ExceptionAdvice { 22 | /** 23 | * 捕捉自定义异常 24 | * 25 | * @return 26 | */ 27 | @ResponseStatus(HttpStatus.BAD_REQUEST) 28 | @ExceptionHandler(CustomException.class) 29 | public ResponseBean handle(CustomException e) { 30 | e.printStackTrace(); 31 | return new ResponseBean(HttpStatus.BAD_REQUEST.value(), e.getMessage(), null); 32 | } 33 | 34 | /** 35 | * 捕捉系统异常 36 | * 37 | * @return 38 | */ 39 | @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) 40 | @ExceptionHandler(SystemException.class) 41 | public ResponseBean handle(SystemException e) { 42 | e.printStackTrace(); 43 | return new ResponseBean(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), null); 44 | } 45 | 46 | /** 47 | * 捕捉404异常 48 | * 49 | * @return 50 | */ 51 | @ResponseStatus(HttpStatus.NOT_FOUND) 52 | @ExceptionHandler(NoHandlerFoundException.class) 53 | public ResponseBean handle(NoHandlerFoundException e) { 54 | e.printStackTrace(); 55 | return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null); 56 | } 57 | 58 | /** 59 | * 捕捉其他所有异常 60 | * 61 | * @param request 62 | * @param ex 63 | * @return 64 | */ 65 | @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) 66 | @ExceptionHandler(Exception.class) 67 | public ResponseBean globalException(HttpServletRequest request, Throwable ex) { 68 | ex.printStackTrace(); 69 | return new ResponseBean(this.getStatus(request).value(), ex.toString() + ": " + ex.getMessage(), null); 70 | } 71 | 72 | /** 73 | * 获取状态码 74 | * 75 | * @param request 76 | * @return 77 | */ 78 | private HttpStatus getStatus(HttpServletRequest request) { 79 | Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); 80 | if (statusCode == null) { 81 | return HttpStatus.INTERNAL_SERVER_ERROR; 82 | } 83 | return HttpStatus.valueOf(statusCode); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/example/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 6 | 7 | /** 8 | * SpringBoot全局支持CORS(跨源请求)的配置 9 | * 10 | * @author wliduo[i@dolyw.com] 11 | * @date 2018/8/9 17:28 12 | */ 13 | @Configuration 14 | public class WebMvcConfig extends WebMvcConfigurerAdapter { 15 | 16 | @Override 17 | public void addCorsMappings(CorsRegistry registry) { 18 | registry.addMapping("/**").allowedOrigins("*") 19 | .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") 20 | .allowCredentials(false).maxAge(3600); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/example/constant/Constant.java: -------------------------------------------------------------------------------- 1 | package com.example.constant; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * Constant 7 | * 8 | * @author wliduo[i@dolyw.com] 9 | * @date 2019/4/6 19:50 10 | */ 11 | public interface Constant { 12 | 13 | /** 14 | * 项目在硬盘上的基础路径 15 | */ 16 | String PROJECT_PATH = System.getProperty("user.dir"); 17 | 18 | /** 19 | * 冒号 20 | */ 21 | String COLON = ":"; 22 | 23 | /** 24 | * 模板 25 | */ 26 | String TEMPLATE = "template"; 27 | 28 | /** 29 | * OS_NAME 30 | */ 31 | String OS_NAME = "os.name"; 32 | 33 | /** 34 | * Windows 35 | */ 36 | String WINDOWS = "Windows"; 37 | 38 | /** 39 | * TMEP_DIR 40 | */ 41 | String TMEP_DIR = PROJECT_PATH + File.separator + "temp" + File.separator; 42 | 43 | /** 44 | * CONFIG_PATH 45 | */ 46 | String CONFIG_PATH = "config" + File.separator + "generator.properties"; 47 | 48 | /** 49 | * CONFIG_PATH_TEMP 50 | */ 51 | String CONFIG_PATH_TEMP = TMEP_DIR + File.separator + CONFIG_PATH; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/example/constant/DataBaseEnum.java: -------------------------------------------------------------------------------- 1 | package com.example.constant; 2 | 3 | /** 4 | * 数据库类型 5 | * 6 | * @author wliduo[i@dolyw.com] 7 | * @date 2019/4/6 19:53 8 | */ 9 | public enum DataBaseEnum { 10 | /** 11 | * MYSQL 12 | */ 13 | MYSQL("mysql"), 14 | /** 15 | * ORACLE 16 | */ 17 | ORACLE("oracle"), 18 | /** 19 | * POSTGRESQL 20 | */ 21 | POSTGRESQL("postgresql"), 22 | /** 23 | * SQLSERVER 24 | */ 25 | SQLSERVER("sqlserver"); 26 | 27 | private String value; 28 | 29 | DataBaseEnum(String type) { 30 | value = type; 31 | } 32 | 33 | public String getValue() { 34 | return value; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | /** 8 | * 通用访问匹配页面跳转 9 | * 10 | * @author wliduo[i@dolyw.com] 11 | * @date 2019/1/24 19:27 12 | */ 13 | @Controller 14 | public class IndexController { 15 | 16 | /** 17 | * 主页 18 | * 19 | * @return java.lang.String 20 | * @author wliduo[i@dolyw.com] 21 | * @date 2019/4/6 13:17 22 | */ 23 | @RequestMapping("/") 24 | public String index() { 25 | return "index"; 26 | } 27 | 28 | /** 29 | * 通用页面跳转 30 | * 31 | * @param url 32 | * @return java.lang.String 33 | * @author wliduo[i@dolyw.com] 34 | * @date 2019/1/24 19:27 35 | */ 36 | @RequestMapping("{url}.shtml") 37 | public String page(@PathVariable("url") String url) { 38 | return url; 39 | } 40 | 41 | /** 42 | * 通用页面跳转(二级目录) 43 | * 44 | * @param module 45 | * @param url 46 | * @return java.lang.String 47 | * @author wliduo[i@dolyw.com] 48 | * @date 2019/1/24 19:27 49 | */ 50 | @RequestMapping("{module}/{url}.shtml") 51 | public String page(@PathVariable("module") String module, @PathVariable("url") String url) { 52 | return module + "/" + url; 53 | } 54 | 55 | /** 56 | * 通用页面跳转(三级目录) 57 | * 58 | * @param module 59 | * @param url 60 | * @return java.lang.String 61 | * @author wliduo[i@dolyw.com] 62 | * @date 2019/1/25 19:35 63 | */ 64 | @RequestMapping("{module}/{module2}/{url}.shtml") 65 | public String page(@PathVariable("module") String module, @PathVariable("module2") String module2, 66 | @PathVariable("url") String url) { 67 | return module + "/" + module2 + "/" + url; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/RestartController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.Application; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * 重新启动项目 11 | * 12 | * @author wliduo[i@dolyw.com] 13 | * @date 2021/11/17 11:14 14 | */ 15 | @RestController 16 | public class RestartController { 17 | 18 | /** 19 | * logger 20 | */ 21 | private static Logger logger = LoggerFactory.getLogger(RestartController.class); 22 | 23 | /** 24 | * 重新启动项目 25 | * 26 | * @param 27 | * @return java.lang.String 28 | * @throws 29 | * @author wliduo[i@dolyw.com] 30 | * @date 2021/11/17 11:14 31 | */ 32 | @GetMapping("/restart") 33 | public String restart() { 34 | Application.restart(); 35 | return "success"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/example/dao/GeneratorDao.java: -------------------------------------------------------------------------------- 1 | package com.example.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * GeneratorDao 8 | * 9 | * @author wliduo[i@dolyw.com] 10 | * @date 2019/4/5 17:51 11 | */ 12 | public interface GeneratorDao { 13 | 14 | /** 15 | * 查询数据库所有表 16 | * 17 | * @param map 18 | * @return java.util.List> 19 | * @throws 20 | * @author wliduo[i@dolyw.com] 21 | * @date 2019/4/5 17:51 22 | */ 23 | List> queryList(Map map); 24 | 25 | /** 26 | * 查询表信息 27 | * 28 | * @param tableName 29 | * @return java.util.Map 30 | * @throws 31 | * @author wliduo[i@dolyw.com] 32 | * @date 2019/4/5 17:52 33 | */ 34 | Map queryTable(String tableName); 35 | 36 | /** 37 | * 查询列信息 38 | * 39 | * @param tableName 40 | * @return java.util.List> 41 | * @throws 42 | * @author wliduo[i@dolyw.com] 43 | * @date 2019/4/5 17:52 44 | */ 45 | List> queryColumns(String tableName); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/example/dao/MySqlGeneratorDao.java: -------------------------------------------------------------------------------- 1 | package com.example.dao; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | /** 6 | * MySQL 7 | * 8 | * @author wliduo[i@dolyw.com] 9 | * @date 2019/4/5 17:53 10 | */ 11 | @Repository 12 | public interface MySqlGeneratorDao extends GeneratorDao { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/example/dao/OracleGeneratorDao.java: -------------------------------------------------------------------------------- 1 | package com.example.dao; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | /** 6 | * Oracle 7 | * 8 | * @author wliduo[i@dolyw.com] 9 | * @date 2019/4/5 17:53 10 | */ 11 | @Repository 12 | public interface OracleGeneratorDao extends GeneratorDao { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/example/dao/PostgreSqlGeneratorDao.java: -------------------------------------------------------------------------------- 1 | package com.example.dao; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | /** 6 | * PostgreSQL 7 | * 8 | * @author wliduo[i@dolyw.com] 9 | * @date 2019/4/5 18:21 10 | */ 11 | @Repository 12 | public interface PostgreSqlGeneratorDao extends GeneratorDao { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/example/dao/SqlServerGeneratorDao.java: -------------------------------------------------------------------------------- 1 | package com.example.dao; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | /** 6 | * SQLServer 7 | * 8 | * @author wliduo[i@dolyw.com] 9 | * @date 2019/4/5 18:22 10 | */ 11 | @Repository 12 | public interface SqlServerGeneratorDao extends GeneratorDao { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/example/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.example.exception; 2 | 3 | /** 4 | * 自定义异常(CustomException) 5 | * 6 | * @author wliduo[i@dolyw.com] 7 | * @date 2018/8/30 13:59 8 | */ 9 | public class CustomException extends RuntimeException { 10 | 11 | public CustomException(String msg) { 12 | super(msg); 13 | } 14 | 15 | public CustomException() { 16 | super(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/example/exception/SystemException.java: -------------------------------------------------------------------------------- 1 | package com.example.exception; 2 | 3 | /** 4 | * 系统异常(SystemException) 5 | * 6 | * @author wliduo[i@dolyw.com] 7 | * @date 2018/8/30 13:59 8 | */ 9 | public class SystemException extends RuntimeException { 10 | 11 | public SystemException(String msg) { 12 | super(msg); 13 | } 14 | 15 | public SystemException() { 16 | super(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/example/run/FileRun.java: -------------------------------------------------------------------------------- 1 | package com.example.run; 2 | 3 | import com.example.constant.Constant; 4 | import com.example.controller.DataBaseController; 5 | import org.apache.commons.io.FileUtils; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.io.File; 12 | import java.io.InputStream; 13 | 14 | /** 15 | * FileRun 16 | * 17 | * @author wliduo[i@dolyw.com] 18 | * @date 2021/11/15 15:07 19 | */ 20 | @Component 21 | public class FileRun implements CommandLineRunner { 22 | 23 | /** 24 | * logger 25 | */ 26 | private static final Logger logger = LoggerFactory.getLogger(FileRun.class); 27 | 28 | @Override 29 | public void run(String... strings) throws Exception { 30 | File file = new File(Constant.CONFIG_PATH_TEMP); 31 | if (!file.exists()) { 32 | InputStream properties = FileRun.class.getClassLoader().getResourceAsStream(Constant.CONFIG_PATH); 33 | FileUtils.copyInputStreamToFile(properties, file); 34 | } 35 | } 36 | 37 | /** 38 | * 递归获取文件 39 | * 40 | * @param files 41 | * @param tmpDir 42 | * @return void 43 | * @throws 44 | * @author wliduo[i@dolyw.com] 45 | * @date 2021/11/16 17:21 46 | */ 47 | public void getFile(File[] files, String tmpDir) { 48 | if (files == null) { 49 | return; 50 | } 51 | for (int i = 0; i < files.length; i++) { 52 | // 如果是文件 53 | if (files[i].isFile()) { 54 | // FileUtil.copy(files[i], new File(tmpDir + files[i].getAbsolutePath().substring(files[i].getAbsolutePath().indexOf("template" + File.separator + "two"))), true); 55 | } else if (files[i].isDirectory()) { 56 | // 如果是文件夹需要调用递归,深度+1 57 | getFile(files[i].listFiles(), tmpDir); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/example/util/ZipUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.util; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.io.OutputStream; 7 | import java.nio.charset.Charset; 8 | import java.util.List; 9 | import java.util.zip.ZipEntry; 10 | import java.util.zip.ZipOutputStream; 11 | 12 | /** 13 | * ZipUtil 14 | * 15 | * @author wliduo[i@dolyw.com] 16 | * @date 2019/4/6 12:00 17 | */ 18 | public class ZipUtil { 19 | 20 | /** 21 | * BUFFER_SIZE 22 | */ 23 | private static final int BUFFER_SIZE = 2 * 1024; 24 | 25 | /** 26 | * 压缩成ZIP 方法1 27 | * 28 | * @param srcDir 压缩文件夹路径 29 | * @param out 压缩文件输出流 30 | * @param comment 压缩文件注释 31 | * @param keepDirStructure 是否保留原来的目录结构,true:保留目录结构; 32 | * false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败) 33 | * @throws RuntimeException 压缩失败会抛出运行时异常 34 | */ 35 | public static void toZip(String srcDir, OutputStream out, String comment, boolean keepDirStructure) 36 | throws RuntimeException { 37 | long start = System.currentTimeMillis(); 38 | ZipOutputStream zos = null; 39 | try { 40 | zos = new ZipOutputStream(out, Charset.forName("GBK")); 41 | zos.setComment(comment); 42 | File sourceFile = new File(srcDir); 43 | compress(sourceFile, zos, sourceFile.getName(), keepDirStructure); 44 | long end = System.currentTimeMillis(); 45 | System.out.println("压缩完成,耗时:" + (end - start) + " ms"); 46 | } catch (Exception e) { 47 | throw new RuntimeException("zip error from ZipUtil", e); 48 | } finally { 49 | if (zos != null) { 50 | try { 51 | zos.close(); 52 | } catch (IOException e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | } 57 | 58 | } 59 | 60 | /** 61 | * 压缩成ZIP 方法2 62 | * 63 | * @param srcFiles 需要压缩的文件列表 64 | * @param out 压缩文件输出流 65 | * @throws RuntimeException 压缩失败会抛出运行时异常 66 | */ 67 | public static void toZip(List srcFiles, OutputStream out) throws RuntimeException { 68 | long start = System.currentTimeMillis(); 69 | ZipOutputStream zos = null; 70 | try { 71 | zos = new ZipOutputStream(out); 72 | for (File srcFile : srcFiles) { 73 | byte[] buf = new byte[BUFFER_SIZE]; 74 | zos.putNextEntry(new ZipEntry(srcFile.getName())); 75 | int len; 76 | FileInputStream in = new FileInputStream(srcFile); 77 | while ((len = in.read(buf)) != -1) { 78 | zos.write(buf, 0, len); 79 | } 80 | zos.closeEntry(); 81 | in.close(); 82 | } 83 | long end = System.currentTimeMillis(); 84 | System.out.println("压缩完成,耗时:" + (end - start) + " ms"); 85 | } catch (Exception e) { 86 | throw new RuntimeException("zip error from ZipUtil", e); 87 | } finally { 88 | if (zos != null) { 89 | try { 90 | zos.close(); 91 | } catch (IOException e) { 92 | e.printStackTrace(); 93 | } 94 | } 95 | } 96 | } 97 | 98 | /** 99 | * 递归压缩方法 100 | * 101 | * @param sourceFile 源文件 102 | * @param zos zip输出流 103 | * @param name 压缩后的名称 104 | * @param keepDirStructure 是否保留原来的目录结构,true:保留目录结构; 105 | * false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败) 106 | * @throws Exception 107 | */ 108 | private static void compress(File sourceFile, ZipOutputStream zos, String name, 109 | boolean keepDirStructure) throws Exception { 110 | byte[] buf = new byte[BUFFER_SIZE]; 111 | if (sourceFile.isFile()) { 112 | // 向zip输出流中添加一个zip实体,构造器中name为zip实体的文件的名字 113 | zos.putNextEntry(new ZipEntry(name)); 114 | // copy文件到zip输出流中 115 | int len; 116 | FileInputStream in = new FileInputStream(sourceFile); 117 | while ((len = in.read(buf)) != -1) { 118 | zos.write(buf, 0, len); 119 | } 120 | // Complete the entry 121 | zos.closeEntry(); 122 | in.close(); 123 | } else { 124 | File[] listFiles = sourceFile.listFiles(); 125 | if (listFiles == null || listFiles.length == 0) { 126 | // 需要保留原来的文件结构时,需要对空文件夹进行处理 127 | if (keepDirStructure) { 128 | // 空文件夹的处理 129 | zos.putNextEntry(new ZipEntry(name + "/")); 130 | // 没有文件,不需要文件的copy 131 | zos.closeEntry(); 132 | } 133 | 134 | } else { 135 | for (File file : listFiles) { 136 | // 判断是否需要保留原来的文件结构 137 | if (keepDirStructure) { 138 | // 注意:file.getName()前面需要带上父文件夹的名字加一斜杠, 139 | // 不然最后压缩包中就不能保留原来的文件结构,即:所有文件都跑到压缩包根目录下了 140 | compress(file, zos, name + "/" + file.getName(), keepDirStructure); 141 | } else { 142 | compress(file, zos, file.getName(), keepDirStructure); 143 | } 144 | } 145 | } 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/com/generator/CustomGeneratorFacade.java: -------------------------------------------------------------------------------- 1 | package com.generator; 2 | 3 | import cn.org.rapid_framework.generator.GeneratorFacade; 4 | import cn.org.rapid_framework.generator.util.StringHelper; 5 | 6 | /** 7 | * 重写GeneratorFacade 8 | * 9 | * @author wliduo[i@dolyw.com] 10 | * @date 2019/4/6 19:36 11 | */ 12 | public class CustomGeneratorFacade extends GeneratorFacade { 13 | 14 | /** 15 | * CustomGeneratorFacade 16 | * 17 | * @param outRootDir 18 | * @author wliduo[i@dolyw.com] 19 | * @date 2019/4/8 9:27 20 | */ 21 | public CustomGeneratorFacade(String outRootDir) { 22 | if (StringHelper.isNotBlank(outRootDir)) { 23 | super.getGenerator().setOutRootDir(outRootDir); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | name: dev 4 | url: ${jdbc_url} 5 | username: ${jdbc_username} 6 | password: ${jdbc_password} -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | # 配置环境 6 | profiles: 7 | active: dev 8 | # 使用Druid数据源 9 | datasource: 10 | type: com.alibaba.druid.pool.DruidDataSource 11 | driver-class-name: ${jdbc_driver} 12 | druid: 13 | filters: stat 14 | maxActive: 20 15 | initialSize: 1 16 | maxWait: 60000 17 | minIdle: 1 18 | timeBetweenEvictionRunsMillis: 60000 19 | minEvictableIdleTimeMillis: 300000 20 | # validationQuery: select 'x' 21 | validation-query: SELECT 1 from dual 22 | testWhileIdle: true 23 | testOnBorrow: false 24 | testOnReturn: false 25 | poolPreparedStatements: true 26 | maxOpenPreparedStatements: 20 27 | # 开启thymeleaf必须关闭404交给异常处理器处理配置 28 | # 不然无法访问静态资源 29 | thymeleaf: 30 | # 开发时关闭缓存不然没法看到实时页面 31 | cache: false 32 | # 启用不严格检查 33 | mode: HTML 34 | 35 | mybatis: 36 | # Mybatis配置Mapper路径 37 | mapper-locations: classpath:mapper/*.xml 38 | # Mybatis配置Model类对应 39 | type-aliases-package: com.example.model 40 | 41 | pagehelper: 42 | params: count=countSql 43 | # 指定分页插件使用哪种方言 44 | # helper-dialect: mysql 45 | # 自动识别方言 46 | auto-runtime-dialect: 'true' 47 | # 分页合理化参数 pageNum<=0时会查询第一页 pageNum>pages(超过总数时) 会查询最后一页 48 | reasonable: 'true' 49 | support-methods-arguments: 'true' 50 | 51 | mapper: 52 | # 通用Mapper的insertSelective和updateByPrimaryKeySelective中是否判断字符串类型!='' 53 | not-empty: true 54 | 55 | logging: 56 | # Debug打印SQL 57 | level.com.example.mapper: debug 58 | level.com.example.dao: debug -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////// 2 | // _ooOoo_ // 3 | // o8888888o // 4 | // 88" . "88 // 5 | // (| ^_^ |) // 6 | // O\ = /O // 7 | // ____/`---'\____ // 8 | // .' \\| |// `. // 9 | // / \\||| : |||// \ // 10 | // / _||||| -:- |||||- \ // 11 | // | | \\\ - /// | | // 12 | // | \_| ''\---/'' | | // 13 | // \ .-\__ `-` ___/-. / // 14 | // ___`. .' /--.--\ `. . ___ // 15 | // ."" '< `.___\_<|>_/___.' >'"". // 16 | // | | : `- \`.;`\ _ /`;.`/ - ` : | | // 17 | // \ \ `-. \_ __\ /__ _/ .-` / / // 18 | // ========`-.____`-.___\_____/___.-`____.-'======== // 19 | // `=---=' // 20 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // 21 | // 佛祖保佑 永不宕机 永无BUG // 22 | //////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /src/main/resources/config/generator.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/config/generator.properties -------------------------------------------------------------------------------- /src/main/resources/mapper/MySQLGeneratorDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/resources/mapper/OracleGeneratorDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 30 | 31 | 34 | 35 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PostgreSQLGeneratorDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 30 | 31 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SQLServerGeneratorDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20 | 21 | 29 | 30 | 91 | 92 | -------------------------------------------------------------------------------- /src/main/resources/sql/MySQL.sql: -------------------------------------------------------------------------------- 1 | drop database dev; 2 | 3 | create database dev; 4 | 5 | use dev; 6 | 7 | create table user ( 8 | id int primary key auto_increment COMMENT "ID", 9 | account varchar(20) not null COMMENT "帐号", 10 | password varchar(80) not null COMMENT "密码", 11 | reg_time datetime not null COMMENT "注册时间" 12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "用户表"; 13 | 14 | CREATE TABLE role ( 15 | id int primary key auto_increment COMMENT "ID", 16 | name varchar(128) not null COMMENT "角色名称" 17 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "角色表"; 18 | 19 | CREATE TABLE permission ( 20 | id int primary key auto_increment COMMENT "ID", 21 | name varchar(128) COMMENT '资源名称', 22 | per_code varchar(128) not null COMMENT '权限代码字符串' 23 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "资源表"; 24 | 25 | insert into user values(null, "admin", "admin", now()); 26 | insert into user values(null, "wang", "wang", now()); 27 | insert into user values(null, "guest", "guest", now()); 28 | 29 | insert into role values(null, "admin"); 30 | insert into role values(null, "customer"); 31 | 32 | insert into permission values(null, "查看用户", "user:view"); 33 | insert into permission values(null, "操作用户", "user:edit"); 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/static/css/admin.css: -------------------------------------------------------------------------------- 1 | /** 2 | * admin.css 3 | */ 4 | 5 | 6 | /* 7 | fixed-layout 固定头部和边栏布局 8 | */ 9 | 10 | html, 11 | body { 12 | height: 100%; 13 | overflow: hidden; 14 | } 15 | 16 | ul { 17 | margin-top: 0; 18 | } 19 | 20 | .admin-icon-yellow { 21 | color: #ffbe40; 22 | } 23 | 24 | .admin-header { 25 | position: fixed; 26 | top: 0; 27 | left: 0; 28 | right: 0; 29 | z-index: 1500; 30 | font-size: 1.4rem; 31 | margin-bottom: 0; 32 | } 33 | 34 | .admin-header-list a:hover :after { 35 | content: none; 36 | } 37 | 38 | .admin-main { 39 | position: relative; 40 | height: 100%; 41 | padding-top: 51px; 42 | background: #f3f3f3; 43 | } 44 | 45 | .admin-menu { 46 | position: fixed; 47 | z-index: 10; 48 | bottom: 30px; 49 | right: 20px; 50 | } 51 | 52 | .admin-sidebar { 53 | width: 270px; 54 | min-height: 100%; 55 | float: left; 56 | border-right: 1px solid #cecece; 57 | } 58 | 59 | .admin-sidebar.am-active { 60 | z-index: 1600; 61 | } 62 | 63 | .admin-sidebar-list { 64 | margin-bottom: 0; 65 | } 66 | 67 | .admin-sidebar-list li a { 68 | color: #5c5c5c; 69 | padding-left: 24px; 70 | } 71 | 72 | .admin-sidebar-list li:first-child { 73 | border-top: none; 74 | } 75 | 76 | .admin-sidebar-sub { 77 | margin-top: 0; 78 | margin-bottom: 0; 79 | box-shadow: 0 16px 8px -15px #e2e2e2 inset; 80 | background: #ececec; 81 | padding-left: 24px; 82 | } 83 | 84 | .admin-sidebar-sub li:first-child { 85 | border-top: 1px solid #dedede; 86 | } 87 | 88 | .admin-sidebar-panel { 89 | margin: 10px; 90 | } 91 | 92 | .admin-content { 93 | display: -webkit-box; 94 | display: -webkit-flex; 95 | display: -ms-flexbox; 96 | display: flex; 97 | -webkit-box-orient: vertical; 98 | -webkit-box-direction: normal; 99 | -webkit-flex-direction: column; 100 | -ms-flex-direction: column; 101 | flex-direction: column; 102 | background: #fff; 103 | } 104 | 105 | .admin-content, 106 | .admin-sidebar { 107 | height: 100%; 108 | overflow-x: hidden; 109 | overflow-y: scroll; 110 | -webkit-overflow-scrolling: touch; 111 | } 112 | 113 | .admin-content-body { 114 | -webkit-box-flex: 1; 115 | -webkit-flex: 1 0 auto; 116 | -ms-flex: 1 0 auto; 117 | flex: 1 0 auto; 118 | } 119 | 120 | .admin-content-footer { 121 | font-size: 85%; 122 | color: #777; 123 | } 124 | 125 | .admin-content-list { 126 | border: 1px solid #e9ecf1; 127 | margin-top: 0; 128 | } 129 | 130 | .admin-content-list li { 131 | border: 1px solid #e9ecf1; 132 | border-width: 0 1px; 133 | margin-left: -1px; 134 | } 135 | 136 | .admin-content-list li:first-child { 137 | border-left: none; 138 | } 139 | 140 | .admin-content-list li:last-child { 141 | border-right: none; 142 | } 143 | 144 | .admin-content-table a { 145 | color: #535353; 146 | } 147 | .admin-content-file { 148 | margin-bottom: 0; 149 | color: #666; 150 | } 151 | 152 | .admin-content-file p { 153 | margin: 0 0 5px 0; 154 | font-size: 1.4rem; 155 | } 156 | 157 | .admin-content-file li { 158 | padding: 10px 0; 159 | } 160 | 161 | .admin-content-file li:first-child { 162 | border-top: none; 163 | } 164 | 165 | .admin-content-file li:last-child { 166 | border-bottom: none; 167 | } 168 | 169 | .admin-content-file li .am-progress { 170 | margin-bottom: 4px; 171 | } 172 | 173 | .admin-content-file li .am-progress-bar { 174 | line-height: 14px; 175 | } 176 | 177 | .admin-content-task { 178 | margin-bottom: 0; 179 | } 180 | 181 | .admin-content-task li { 182 | padding: 5px 0; 183 | border-color: #eee; 184 | } 185 | 186 | .admin-content-task li:first-child { 187 | border-top: none; 188 | } 189 | 190 | .admin-content-task li:last-child { 191 | border-bottom: none; 192 | } 193 | 194 | .admin-task-meta { 195 | font-size: 1.2rem; 196 | color: #999; 197 | } 198 | 199 | .admin-task-bd { 200 | font-size: 1.4rem; 201 | margin-bottom: 5px; 202 | } 203 | 204 | .admin-content-comment { 205 | margin-bottom: 0; 206 | } 207 | 208 | .admin-content-comment .am-comment-bd { 209 | font-size: 1.4rem; 210 | } 211 | 212 | .admin-content-pagination { 213 | margin-bottom: 0; 214 | } 215 | .admin-content-pagination li a { 216 | padding: 4px 8px; 217 | } 218 | 219 | @media only screen and (min-width: 641px) { 220 | .admin-sidebar { 221 | display: block; 222 | position: static; 223 | background: none; 224 | width: 290px; 225 | margin-top: 25px; 226 | margin-right: -6px; 227 | } 228 | 229 | .admin-offcanvas-bar { 230 | position: static; 231 | width: auto; 232 | background: none; 233 | -webkit-transform: translate3d(0, 0, 0); 234 | -ms-transform: translate3d(0, 0, 0); 235 | transform: translate3d(0, 0, 0); 236 | overflow-y: visible; 237 | min-height: 100%; 238 | } 239 | .admin-offcanvas-bar:after { 240 | content: none; 241 | } 242 | } 243 | 244 | @media only screen and (max-width: 640px) { 245 | .admin-sidebar { 246 | width: inherit; 247 | } 248 | 249 | .admin-offcanvas-bar { 250 | background: #f3f3f3; 251 | } 252 | 253 | .admin-offcanvas-bar:after { 254 | background: #BABABA; 255 | } 256 | 257 | .admin-sidebar-list a:hover, .admin-sidebar-list a:active{ 258 | -webkit-transition: background-color .3s ease; 259 | -moz-transition: background-color .3s ease; 260 | -ms-transition: background-color .3s ease; 261 | -o-transition: background-color .3s ease; 262 | transition: background-color .3s ease; 263 | background: #E4E4E4; 264 | } 265 | 266 | .admin-content-list li { 267 | padding: 10px; 268 | border-width: 1px 0; 269 | margin-top: -1px; 270 | } 271 | 272 | .admin-content-list li:first-child { 273 | border-top: none; 274 | } 275 | 276 | .admin-content-list li:last-child { 277 | border-bottom: none; 278 | } 279 | 280 | .admin-form-text { 281 | text-align: left !important; 282 | } 283 | 284 | } 285 | 286 | /* 287 | * user.html css 288 | */ 289 | .user-info { 290 | margin-bottom: 15px; 291 | } 292 | 293 | .user-info .am-progress { 294 | margin-bottom: 4px; 295 | } 296 | 297 | .user-info p { 298 | margin: 5px; 299 | } 300 | 301 | .user-info-order { 302 | font-size: 1.4rem; 303 | } 304 | 305 | /* 306 | * errorLog.html css 307 | */ 308 | 309 | .error-log .am-pre-scrollable { 310 | max-height: 40rem; 311 | } 312 | 313 | /* 314 | * table.html css 315 | */ 316 | 317 | .table-main { 318 | font-size: 1.4rem; 319 | padding: .5rem; 320 | } 321 | 322 | .table-main button { 323 | background: #fff; 324 | } 325 | 326 | .table-check { 327 | width: 30px; 328 | } 329 | 330 | .table-id { 331 | width: 50px; 332 | } 333 | 334 | @media only screen and (max-width: 640px) { 335 | .table-select { 336 | margin-top: 10px; 337 | margin-left: 5px; 338 | } 339 | } 340 | 341 | /* 342 | gallery.html css 343 | */ 344 | 345 | .gallery-list li { 346 | padding: 10px; 347 | } 348 | 349 | .gallery-list a { 350 | color: #666; 351 | } 352 | 353 | .gallery-list a:hover { 354 | color: #3bb4f2; 355 | } 356 | 357 | .gallery-title { 358 | margin-top: 6px; 359 | font-size: 1.4rem; 360 | } 361 | 362 | .gallery-desc { 363 | font-size: 1.2rem; 364 | margin-top: 4px; 365 | } 366 | 367 | /* 368 | 404.html css 369 | */ 370 | 371 | .page-404 { 372 | background: #fff; 373 | border: none; 374 | width: 200px; 375 | margin: 0 auto; 376 | } 377 | -------------------------------------------------------------------------------- /src/main/resources/static/css/amazeui.jqgrid.min.css: -------------------------------------------------------------------------------- 1 | /*! Amaze UI Plugin ~ jqgrid */.ui-jqgrid{border-width:1px 1px 1px 0;border-radius:0}.ui-grid-ico-sort.am-disabled{color:#ccc}.ui-pager-table{border-left:1px solid #ddd} -------------------------------------------------------------------------------- /src/main/resources/static/css/index.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/css/index.css -------------------------------------------------------------------------------- /src/main/resources/static/css/menu.css: -------------------------------------------------------------------------------- 1 | .am-topbar{ 2 | border-top: 3px solid #71b6f9; 3 | background: none; 4 | border-bottom: none; 5 | } 6 | 7 | .am-topbar .am-topbar-left { 8 | background: #ffffff; 9 | float: left; 10 | text-align: center; 11 | height: 70px; 12 | position: relative; 13 | width: 272px; 14 | z-index: 1; 15 | 16 | } 17 | 18 | .am-navbar-left{ 19 | float: left; 20 | } 21 | 22 | .am-topbar .am-topbar-left .logo { 23 | line-height: 70px; 24 | } 25 | 26 | .logo { 27 | color: #188ae2 !important; 28 | font-size: 32px; 29 | font-family: 'Rancho', cursive; 30 | } 31 | 32 | .am-navbar-default .am-navbar-left { 33 | padding-left: 10px; 34 | } 35 | 36 | .am-navbar-default .am-navbar-left li { 37 | padding: 0px 10px; 38 | } 39 | 40 | .page-title { 41 | font-size: 18px; 42 | font-weight: 600; 43 | margin-bottom: 0px; 44 | margin-top: 0px; 45 | line-height: 62px; 46 | margin-left: 35px; 47 | } 48 | 49 | .am-navbar-default .am-navbar-left { 50 | padding-left: 10px; 51 | } 52 | 53 | .am-navbar-right{ 54 | float: right!important; 55 | margin-right: 30px; 56 | margin-top: 10px; 57 | } 58 | 59 | .am-navbar-right li{ 60 | float: left; 61 | } 62 | 63 | .app-search .form-control, .app-search .form-control:focus { 64 | border: 1px solid rgba(152, 166, 173, 0.15); 65 | font-size: 13px; 66 | height: 34px; 67 | color: #435966; 68 | font-weight: 600; 69 | padding-left: 20px; 70 | padding-right: 40px; 71 | margin-left: 20px; 72 | background: rgba(152, 166, 173, 0.1); 73 | box-shadow: none; 74 | border-radius: 30px; 75 | width: 190px; 76 | } 77 | 78 | .inform{ 79 | line-height: 40px; 80 | } 81 | 82 | .hidden-xs{ 83 | position: relative; 84 | } 85 | 86 | .app-search a{ 87 | position: absolute; 88 | display: block; 89 | width: 19px; 90 | height: 21px; 91 | top: 8px; 92 | right: 20px; 93 | color: rgba(152, 166, 173, 0.7); 94 | } 95 | 96 | .admin-menu { 97 | position: fixed; 98 | z-index: 10; 99 | bottom: 30px; 100 | right: 20px; 101 | } 102 | 103 | .admin{ 104 | width: 100%; 105 | /*position: relative;*/ 106 | height: 100%; 107 | 108 | } 109 | 110 | .admin .am-g{ 111 | padding-left: 0; 112 | padding-right: 0; 113 | } 114 | 115 | 116 | 117 | 118 | /*--------Left Sidebar Start----------*/ 119 | /*---user---*/ 120 | .side-menu { 121 | top: 70px; 122 | width: 250px; 123 | z-index: 10; 124 | background: #ffffff; 125 | bottom: 50px; 126 | height: 100%; 127 | margin-bottom: -70px; 128 | margin-top: 0px; 129 | padding-bottom: 70px; 130 | position: fixed; 131 | box-shadow: 0 0px 24px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02); 132 | } 133 | 134 | .user-box { 135 | text-align: center; 136 | padding: 30px 0px 0px 0px; 137 | background: #fff; 138 | } 139 | 140 | .user-box .user-img { 141 | position: relative; 142 | height: 88px; 143 | width: 88px; 144 | margin: 0px auto; 145 | } 146 | 147 | .img-thumbnail { 148 | border: 1px solid #EBEFF2; 149 | } 150 | .img-circle { 151 | border-radius: 50%; 152 | } 153 | .img-thumbnail { 154 | display: inline-block; 155 | max-width: 100%; 156 | height: auto; 157 | padding: 4px; 158 | line-height: 1.42857143; 159 | background-color: #fff; 160 | border: 1px solid #ddd; 161 | border-radius: 4px; 162 | -webkit-transition: all .2s ease-in-out; 163 | -o-transition: all .2s ease-in-out; 164 | transition: all .2s ease-in-out; 165 | border-radius: 50%; 166 | } 167 | 168 | .user-box .user-status { 169 | height: 12px; 170 | width: 12px; 171 | position: absolute; 172 | bottom: 7px; 173 | right: 15px; 174 | } 175 | 176 | .user-box .user-status.offline i { 177 | color: #ff5b5b; 178 | } 179 | .user-box .user-status i { 180 | font-size: 15px; 181 | } 182 | 183 | .list-inline { 184 | padding-left: 0; 185 | margin-left: -5px; 186 | list-style: none; 187 | } 188 | 189 | .list-inline>li { 190 | display: inline-block; 191 | padding-right: 5px; 192 | padding-left: 5px; 193 | } 194 | 195 | .user-box ul li a { 196 | color: #98a6ad; 197 | } 198 | 199 | .user-box h5 a { 200 | color: #98a6ad; 201 | } 202 | a:hover { 203 | outline: 0; 204 | text-decoration: none; 205 | } 206 | 207 | 208 | 209 | /*---Sidemenu---*/ 210 | #sidebar-menu { 211 | padding-bottom: 30px; 212 | width: 100%; 213 | } 214 | #sidebar-menu, #sidebar-menu ul, #sidebar-menu li, #sidebar-menu a { 215 | border: 0; 216 | font-weight: normal; 217 | line-height: 1; 218 | list-style: none; 219 | margin: 0; 220 | padding: 0; 221 | position: relative; 222 | text-decoration: none; 223 | } 224 | 225 | 226 | #sidebar-menu, #sidebar-menu ul, #sidebar-menu li, #sidebar-menu a { 227 | border: 0; 228 | font-weight: normal; 229 | line-height: 1; 230 | list-style: none; 231 | margin: 0; 232 | padding: 0; 233 | position: relative; 234 | text-decoration: none; 235 | } 236 | 237 | .menu-title { 238 | padding: 12px 20px !important; 239 | letter-spacing: .035em; 240 | pointer-events: none; 241 | cursor: default; 242 | font-size: 13px; 243 | } 244 | .text-muted { 245 | color: #98a6ad !important; 246 | font-size: 12px; 247 | } 248 | 249 | #sidebar-menu > ul > li > a.active { 250 | border-left: 3px solid #71b6f9; 251 | color: #71b6f9 !important; 252 | } 253 | 254 | #sidebar-menu > ul > li > a { 255 | color: #435966; 256 | display: block; 257 | padding: 12px 20px; 258 | margin: 4px 0px; 259 | background-color: #ffffff; 260 | border-left: 3px solid transparent; 261 | } 262 | #sidebar-menu a { 263 | line-height: 1.3; 264 | } 265 | 266 | .has_sub .fa-chevron-right{ 267 | position: absolute; 268 | top: 13px; 269 | right: 20px; 270 | line-height: 18px; 271 | font-size: 10px; 272 | color: #435966; 273 | } 274 | 275 | #sidebar-menu ul ul a { 276 | color: #63747c; 277 | -webkit-transition: all 0.3s ease-out; 278 | -moz-transition: all 0.3s ease-out; 279 | -o-transition: all 0.3s ease-out; 280 | -ms-transition: all 0.3s ease-out; 281 | transition: all 0.3s ease-out; 282 | border-left: 3px solid transparent; 283 | display: block; 284 | padding: 10px 20px 10px 65px; 285 | } 286 | 287 | .inform{ 288 | font-size: 16px; 289 | line-height: 48px; 290 | } 291 | 292 | 293 | 294 | 295 | /*---right Content here---*/ 296 | .content-page { 297 | overflow: auto; 298 | /*height: 700px;*/ 299 | margin-top: 15px; 300 | /* padding-left: 260px;*/ 301 | 302 | } 303 | 304 | .content-page .content { 305 | /*padding: 0px 5px;*/ 306 | /*margin-top: 20px;*/ 307 | } 308 | 309 | .am-g{ 310 | padding-right: 15px; 311 | padding-left: 15px; 312 | margin-right: auto; 313 | margin-left: auto; 314 | } 315 | 316 | 317 | 318 | 319 | 320 | @media screen and (max-width: 641px) { /*当屏幕尺寸小于600px时,应用下面的CSS样式*/ 321 | .am-topbar{ 322 | background: #fff; 323 | } 324 | .content-page{ 325 | /*padding-left: 15px;*/ 326 | } 327 | 328 | .page-title{ 329 | margin-left: 20px; 330 | } 331 | 332 | } 333 | 334 | 335 | .contain{ 336 | overflow: hidden; 337 | } 338 | 339 | 340 | /*--navbar--*/ 341 | .admin-menu { 342 | position: fixed; 343 | z-index: 10; 344 | bottom: 30px; 345 | right: 20px; 346 | } 347 | 348 | .admin{ 349 | width: 100%; 350 | height: 100%; 351 | display: flex; 352 | display: -webkit-flex; 353 | } 354 | 355 | .admin-sidebar{ 356 | float: left; 357 | } 358 | 359 | .content-page{ 360 | flex: 1; 361 | -webkit-flex: 1; 362 | } 363 | 364 | -------------------------------------------------------------------------------- /src/main/resources/static/css/page/form.css: -------------------------------------------------------------------------------- 1 | #doc-ipt-pwd-1{ 2 | background-color: #FFFFFF; 3 | border: 1px solid #E3E3E3; 4 | border-radius: 4px; 5 | color: #565656; 6 | padding: 7px 12px; 7 | height: 38px; 8 | max-width: 100%; 9 | -webkit-box-shadow: none; 10 | box-shadow: none; 11 | -webkit-transition: all 300ms linear; 12 | -moz-transition: all 300ms linear; 13 | -o-transition: all 300ms linear; 14 | -ms-transition: all 300ms linear; 15 | transition: all 300ms linear; 16 | width: 83.33333333%; 17 | } 18 | 19 | 20 | 21 | #doc-ta-1,#doc-ds-ipt-1,#doc-select-1{ 22 | border: 1px solid #E3E3E3; 23 | border-radius: 4px; 24 | color: #565656; 25 | padding: 7px 12px; 26 | max-width: 100%; 27 | -webkit-box-shadow: none; 28 | box-shadow: none; 29 | -webkit-transition: all 300ms linear; 30 | -moz-transition: all 300ms linear; 31 | -o-transition: all 300ms linear; 32 | -ms-transition: all 300ms linear; 33 | transition: all 300ms linear; 34 | width: 83.33333333%; 35 | } 36 | 37 | #rightPa{ 38 | right: 25px; 39 | } 40 | 41 | .help-block { 42 | display: block; 43 | margin-top: 5px; 44 | margin-bottom: 10px; 45 | color: rgb(115, 115, 115); 46 | } 47 | 48 | @media screen and (max-width: 641px){ 49 | #doc-ipt-pwd-1,#doc-ta-1,#doc-ds-ipt-1,#doc-select-1{ 50 | width: 100%; 51 | } 52 | 53 | 54 | } 55 | 56 | 57 | 58 | /*----------------------登录-----------------------*/ 59 | .account-pages { 60 | height: 100%; 61 | width: 100%; 62 | background:url(../../img/bg1.jpg) center !important; 63 | background-size: cover; 64 | } 65 | .wrapper-page { 66 | margin: 5% auto; 67 | position: relative; 68 | width: 420px; 69 | } 70 | @media (max-width: 768px){ 71 | .wrapper-page { 72 | width: 90%; 73 | } 74 | } 75 | .text-center { 76 | text-align: center; 77 | } 78 | .wrapper-page .logo { 79 | font-size: 42px; 80 | } 81 | .logo { 82 | color: #188ae2 !important; 83 | font-size: 32px; 84 | font-family: 'Rancho', cursive; 85 | text-decoration: none; 86 | } 87 | .panel-body { 88 | padding: 15px; 89 | } 90 | .remeber{ 91 | width: 15px; 92 | height: 15px; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /src/main/resources/static/css/page/typography.css: -------------------------------------------------------------------------------- 1 | .card-box .am-nav > li > a:hover, .am-nav > li > a:focus { 2 | text-decoration: none; 3 | background-color: none; 4 | } -------------------------------------------------------------------------------- /src/main/resources/static/element-ui/fonts/element-icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/element-ui/fonts/element-icons.ttf -------------------------------------------------------------------------------- /src/main/resources/static/element-ui/fonts/element-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/element-ui/fonts/element-icons.woff -------------------------------------------------------------------------------- /src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/img/avatar-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolyw/ViewGenerator/cd561e28b35f56aab785c0b136cffb9dffb86e5c/src/main/resources/static/img/avatar-1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/js/axios.min.js: -------------------------------------------------------------------------------- 1 | /* axios v0.18.0 | (c) 2018 by Matt Zabriskie */ 2 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new s(e),n=i(s.prototype.request,t);return o.extend(n,s.prototype,t),o.extend(n,t),n}var o=n(2),i=n(3),s=n(5),u=n(6),a=r(u);a.Axios=s,a.create=function(e){return r(o.merge(u,e))},a.Cancel=n(23),a.CancelToken=n(24),a.isCancel=n(20),a.all=function(e){return Promise.all(e)},a.spread=n(25),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";function r(e){return"[object Array]"===R.call(e)}function o(e){return"[object ArrayBuffer]"===R.call(e)}function i(e){return"undefined"!=typeof FormData&&e instanceof FormData}function s(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function u(e){return"string"==typeof e}function a(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===R.call(e)}function d(e){return"[object File]"===R.call(e)}function l(e){return"[object Blob]"===R.call(e)}function h(e){return"[object Function]"===R.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function w(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n 6 | * @license MIT 7 | */ 8 | e.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new s,response:new s}}var o=n(6),i=n(2),s=n(17),u=n(18);r.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(o,{method:"get"},this.defaults,e),e.method=e.method.toLowerCase();var t=[u,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(i.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof XMLHttpRequest?e=n(8):"undefined"!=typeof process&&(e=n(8)),e}var i=n(2),s=n(7),u={"Content-Type":"application/x-www-form-urlencoded"},a={adapter:o(),transformRequest:[function(e,t){return s(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e)?e:i.isArrayBufferView(e)?e.buffer:i.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):i.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){a.headers[e]={}}),i.forEach(["post","put","patch"],function(e){a.headers[e]=i.merge(u)}),e.exports=a},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(9),i=n(12),s=n(13),u=n(14),a=n(10),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(15);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||u(e.url)||(l=new window.XDomainRequest,h="onload",m=!0,l.onprogress=function(){},l.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";d.Authorization="Basic "+c(y+":"+w)}if(l.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l[h]=function(){if(l&&(4===l.readyState||m)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?s(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:r,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:n,config:e,request:l};o(t,f,i),l=null}},l.onerror=function(){f(a("Network Error",e,null,l)),l=null},l.ontimeout=function(){f(a("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=n(16),v=(e.withCredentials||u(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(10);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(11);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(o.isURLSearchParams(t))i=t.toString();else{var s=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),i=s.join("&")}return i&&(e+=(e.indexOf("?")===-1?"?":"&")+i),e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?s[t]=(s[t]?s[t]:[]).concat([n]):s[t]=s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(){this.message="String contains an invalid character"}function r(e){for(var t,r,i=String(e),s="",u=0,a=o;i.charAt(0|u)||(a="=",u%1);s+=a.charAt(63&t>>8-u%1*8)){if(r=i.charCodeAt(u+=.75),r>255)throw new n;t=t<<8|r}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),r.isString(o)&&u.push("path="+o),r.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),i=n(19),s=n(20),u=n(6),a=n(21),c=n(22);e.exports=function(e){r(e),e.baseURL&&!a(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||u.adapter;return t(e).then(function(t){return r(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return s(t)||(r(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])}); 9 | //# sourceMappingURL=axios.min.map -------------------------------------------------------------------------------- /src/main/resources/templates/common/common.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 后台模板 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 | 43 | 44 |
45 | 46 | 47 |
48 |
49 |
50 | 51 |
52 | 53 |
54 |
    55 |
  • 56 |
57 |
    58 |
  • 59 | 66 |
67 |
68 |
69 |
70 | 71 | 72 |
73 |
74 |
75 | 76 |
77 |
78 | 79 | user-img 81 | 82 |
83 |
84 |
随心
85 | 98 |
99 | 100 | 133 |
134 |
135 |
136 | 137 | -------------------------------------------------------------------------------- /src/main/resources/templates/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | 15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
23 |
24 | 25 |
26 | 27 |
28 |
29 |
配置
30 |
31 | 32 | 33 | 34 | 刷新 35 | 设置 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 |
91 |
92 |
93 | 94 |
95 |
96 |
说明
97 |
98 | 99 | 100 | 103 |
数据库配置
104 |
105 | 106 | 109 |
模板代码位置,示例: 相对路径(/src/main/resources/template/two/RESTful)
110 |
111 | 112 | 115 |
生成代码需要移除的表名前缀,例如t_user变User类则配置t_,使用逗号分隔同时配置多个前缀,示例: table_,t_(不能有空格)
116 |
117 | 118 | 121 |
生成代码需要移除的列名前缀,例如user_password字段变password属性则配置user_,使用逗号分隔同时配置多个前缀,示例: user_,item_(不能有空格)
122 |
123 | 124 | 127 |
模板代码的basepackage属性,示例: com.example
128 |
129 | 130 | 133 |
模板代码的commonspackage属性,示例: com.example
134 |
135 | 136 | 139 |
模板代码的namespace属性,示例: view
140 |
141 | 142 | 145 |
模板代码的modulepackage属性,示例: generator
146 |
147 | 148 | 151 |
模板代码的author属性(注释的作者名称),示例: wliduo[i@dolyw.com]
152 |
153 | 154 | 157 |
代码生成的文件输出路径(路径为部署应用系统下),示例: 绝对路径(E:/work/outRoot) 相对路径(/src/main)
158 |
159 | 160 | 163 |
更多配置请自行修改项目配置文件/src/main/resources/config/generator.properties
164 |
165 |
166 | 167 |
168 |
169 |
170 | 171 |
172 | 173 |
174 |
175 |
176 | 177 |
178 | 179 | 332 | 333 | 334 | 335 | -------------------------------------------------------------------------------- /src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 |
11 | 12 |
13 | 14 |
15 |
16 | 17 |
18 | 19 | 20 |
21 |
22 | 23 | 项目介绍
24 |

25 | ViewGenerator是一个基于SpringBoot & FreeMarker的自定义模板代码生成系统,用于快速构建中小型项目,稳定、简单、快速,使我们摆脱那些重复劳动,专注于业务代码的编写,能在短短几十秒钟内实现一套简单的基础代码(自动生成Model、Mapper、MapperXML、Service、ServiceImpl、Controller、JS、Vue等自定义模板代码)
26 |
27 | 1. 可视化界面,上手操作简单
28 | 2. 高度灵活的代码模板配置(提供两套模板参考),可以自行添加N套代码模板
29 | 3. 支持多数据库,在线切换数据库,支持在线生成代码且可提供ZIP文件下载
30 |

31 | 安装使用
32 |

33 | 1. 配置resource下config/generator.properties数据库信息启动Application即可,也可以本地直接执行Test类在src\test\java\com\example\generator\GeneratorCode
34 | 2. 模板提供两套示例LayUI和RESTful,自行添加模板路径\template\
35 | 3. 可视化界面操作访问访问http://localhost:8080,可以在线设置生成代码的配置
36 | 4. 服务器部署,下载代码到本地打包成jar包上传到服务器启动即可
37 | 5. 服务器部署后需要自行复制template文件夹到与jar包同级目录下
38 |

39 | 更多详细说明
40 |

41 | 1. Github:https://github.com/dolyw/ViewGenerator
42 | 2. Gitee(码云):https://gitee.com/dolyw/ViewGenerator
43 | 3. 关于作者:https://note.dolyw.com
44 |

45 |
46 |
47 |
48 | 49 |
50 |
51 |
52 | 53 |
54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/test/java/com/example/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.TestPropertySource; 6 | 7 | @SpringBootTest 8 | @TestPropertySource(value = {"classpath:config/generator.properties"}) 9 | public class ApplicationTests { 10 | 11 | @Test 12 | public void contextLoads() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/example/base/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.example.base; 2 | 3 | import com.example.Application; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.annotation.Rollback; 6 | import org.springframework.test.context.TestPropertySource; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | /** 10 | * 单元测试继承该类即可 11 | */ 12 | @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 13 | @Transactional(rollbackFor = Exception.class) 14 | @TestPropertySource(value = {"classpath:config/generator.properties"}) 15 | @Rollback 16 | public abstract class BaseTest {} -------------------------------------------------------------------------------- /src/test/java/com/example/generator/GeneratorCode.java: -------------------------------------------------------------------------------- 1 | package com.example.generator; 2 | 3 | import cn.org.rapid_framework.generator.Generator; 4 | import cn.org.rapid_framework.generator.GeneratorFacade; 5 | import cn.org.rapid_framework.generator.GeneratorProperties; 6 | import com.example.base.BaseTest; 7 | import com.generator.CustomGeneratorFacade; 8 | 9 | /** 10 | * Test类生成代码 11 | * 12 | * @author wliduo[i@dolyw.com] 13 | * @date 2019/04/08 09:21 14 | */ 15 | public class GeneratorCode extends BaseTest { 16 | 17 | /** 18 | * 项目在硬盘上的基础路径 19 | */ 20 | private static final String PROJECT_PATH = System.getProperty("user.dir"); 21 | 22 | /** 23 | * 生成代码板位置 24 | */ 25 | private static final String OUT_ROOT = "E:/work/outRoot"; 26 | 27 | /** 28 | * 配置文件位置 29 | */ 30 | private static final String CONFIG_PATH = PROJECT_PATH + "/src/main/resources/config/generator.properties"; 31 | 32 | /** 33 | * 代码模板位置 34 | */ 35 | private static final String TEMPLATE_FILE_PATH = PROJECT_PATH + "/template/RESTful"; 36 | 37 | /** 38 | * 有三点需要引起特别的注意 39 | * (1)配置resource下config/generator.properties数据库信息 40 | * (2)表无主键,无法生成 41 | * (3)外键关联的表无读权限,无法生成 42 | */ 43 | public static void main(String[] args) throws Exception { 44 | // 配置表名 45 | genCode("user", "role"); 46 | } 47 | 48 | /** 49 | * 通过表名称生成代码 50 | * @param tableNames 51 | */ 52 | public static void genCode(String... tableNames) throws Exception { 53 | // GeneratorFacade 54 | GeneratorFacade generatorFacade = new CustomGeneratorFacade(OUT_ROOT); 55 | // 配置信息 56 | GeneratorProperties.load(CONFIG_PATH); 57 | // 模板位置 58 | Generator generator = generatorFacade.getGenerator(); 59 | generator.addTemplateRootDir(TEMPLATE_FILE_PATH); 60 | // 开始执行 61 | try { 62 | for (String tableName : tableNames) { 63 | // 删除旧文件 64 | generatorFacade.deleteByTable(tableName); 65 | // 生成新文件 66 | generatorFacade.generateByTable(tableName); 67 | } 68 | // 打开文件夹 69 | Runtime.getRuntime().exec("cmd.exe /c start " + OUT_ROOT); 70 | } catch (Exception e) { 71 | System.out.println("----- 生成失败 请检查数据库是否连接正常及表名是否正确以及权限是否缺失 -----"); 72 | e.printStackTrace(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/com/example/test/TestRole.java: -------------------------------------------------------------------------------- 1 | package com.example.test; 2 | 3 | import com.example.base.BaseTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.web.client.TestRestTemplate; 7 | import org.springframework.http.ResponseEntity; 8 | 9 | /** 10 | * 参考https://my.oschina.net/zjllovecode/blog/1605981 11 | * 12 | * @author wliduo[i@dolyw.com] 13 | * @date 2018/11/15 17:13 14 | */ 15 | public class TestRole extends BaseTest { 16 | 17 | @Autowired 18 | private TestRestTemplate restTemplate; 19 | 20 | /** 21 | * 测试REST类型Controller列表 22 | * @throws Exception 23 | */ 24 | @Test 25 | public void get() throws Exception { 26 | String body = this.restTemplate.getForObject("/role", String.class); 27 | System.out.println(body); 28 | } 29 | 30 | /** 31 | * 测试POST类型Controller列表 32 | * @throws Exception 33 | */ 34 | @Test 35 | public void post() throws Exception { 36 | ResponseEntity body = this.restTemplate.postForEntity("/role/list", "", String.class); 37 | System.out.println(body); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/example/test/TestSafeProperties.java: -------------------------------------------------------------------------------- 1 | package com.example.test; 2 | 3 | import com.example.base.BaseTest; 4 | import com.example.util.SafeProperties; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.io.FileOutputStream; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | import java.net.URL; 11 | import java.net.URLConnection; 12 | import java.util.Enumeration; 13 | 14 | /** 15 | * 参考https://blog.csdn.net/xiaosemei/article/details/77334677 16 | * 17 | * @author wliduo[i@dolyw.com] 18 | * @date 2018/11/15 17:13 19 | */ 20 | public class TestSafeProperties extends BaseTest { 21 | 22 | /** 23 | * SafeProperties读写 24 | * @throws Exception 25 | */ 26 | @Test 27 | public void write() throws Exception { 28 | final Enumeration urls = TestSafeProperties.class.getClassLoader().getResources("config/generator.properties"); 29 | while (urls.hasMoreElements()) { 30 | final URL url = (URL) urls.nextElement(); 31 | InputStream input = null; 32 | OutputStream output = null; 33 | try { 34 | final URLConnection con = url.openConnection(); 35 | con.setUseCaches(false); 36 | input = con.getInputStream(); 37 | SafeProperties safeProperties = new SafeProperties(); 38 | // 读 39 | safeProperties.load(input); 40 | // 写 41 | safeProperties.setProperty("outRoot", "/src2"); 42 | output = new FileOutputStream(url.getPath()); 43 | safeProperties.store(output, null); 44 | } 45 | finally { 46 | if (input != null) { 47 | input.close(); 48 | } 49 | if (output != null) { 50 | output.close(); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /template/LayUI/java/${basepackage_dir}/controller/${className}Controller.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.controller; 6 | 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RequestMethod; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | 21 | import com.alibaba.fastjson.JSON; 22 | import ${commonspackage}.dto.JsonRequest; 23 | import com.mybatis.pagehelper.PageInfo; 24 | 25 | import ${basepackage}.dto.custom.${className}Dto; 26 | import ${basepackage}.service.${className}Service; 27 | 28 | /** 29 | * ${className}Controller 30 | * @author ${author} 31 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 32 | */ 33 | @Controller 34 | @RequestMapping("${classNameLower}") 35 | public class ${className}Controller { 36 | 37 | @Autowired 38 | private ${className}Service ${classNameLower}Service; 39 | 40 | /** 41 | * 主页面 42 | * @author ${author} 43 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 44 | */ 45 | @RequestMapping 46 | public String index(HttpServletRequest request) { 47 | return "${modulepackage}/${classNameLower}/${classNameLower}"; 48 | } 49 | 50 | /** 51 | * 列表 52 | * @author ${author} 53 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 54 | */ 55 | @ResponseBody 56 | @RequestMapping(value = "list", method = RequestMethod.POST) 57 | public Map list(@RequestBody ${className}Dto ${classNameLower}Dto) throws Exception { 58 | Map resultMap = new HashMap(16); 59 | PageInfo<${className}Dto> pageInfo = ${classNameLower}Service.findPageInfo(${classNameLower}Dto.getPage(), 60 | ${classNameLower}Dto.getLimit(), ${classNameLower}Dto, ${classNameLower}Dto.getField() + " " + ${classNameLower}Dto.getOrder()); 61 | resultMap.put("code", "0"); 62 | resultMap.put("count", pageInfo.getTotal()); 63 | resultMap.put("data", pageInfo.getList()); 64 | return resultMap; 65 | } 66 | 67 | /** 68 | * 预新增 69 | * @author ${author} 70 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 71 | */ 72 | @ResponseBody 73 | @RequestMapping(value = "/prepareInsert", method = RequestMethod.POST) 74 | public Map prepareInsert(@RequestBody ${className}Dto ${classNameLower}Dto) throws Exception { 75 | Map resultMap = new HashMap(16); 76 | ${classNameLower}Dto = new ${className}Dto(); 77 | resultMap.put("${classNameLower}Dto", ${classNameLower}Dto); 78 | return resultMap; 79 | } 80 | 81 | /** 82 | * 新增 83 | * @author ${author} 84 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 85 | */ 86 | @ResponseBody 87 | @RequestMapping(value = "/insert", method = RequestMethod.POST) 88 | public Map insert(@RequestBody ${className}Dto ${classNameLower}Dto) throws Exception { 89 | Map resultMap = new HashMap(16); 90 | ${classNameLower}Service.insertNotNull(${classNameLower}Dto); 91 | resultMap.put("flag", "Y"); 92 | resultMap.put("msg", "保存成功"); 93 | return resultMap; 94 | } 95 | 96 | /** 97 | * 预修改 98 | * @author ${author} 99 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 100 | */ 101 | @ResponseBody 102 | @RequestMapping(value = "/prepareUpdate", method = RequestMethod.POST) 103 | public Map prepareUpdate(@RequestBody ${className}Dto ${classNameLower}Dto) throws Exception { 104 | Map resultMap = new HashMap(16); 105 | ${classNameLower}Dto = ${classNameLower}Service.selectByPrimaryKey(${classNameLower}Dto); 106 | resultMap.put("${classNameLower}Dto", ${classNameLower}Dto); 107 | return resultMap; 108 | } 109 | 110 | /** 111 | * 修改 112 | * @author ${author} 113 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 114 | */ 115 | @ResponseBody 116 | @RequestMapping(value = "/update", method = RequestMethod.POST) 117 | public Map update(@RequestBody ${className}Dto ${classNameLower}Dto) throws Exception { 118 | Map resultMap = new HashMap(16); 119 | ${classNameLower}Service.updateByPrimaryKey(${classNameLower}Dto); 120 | resultMap.put("flag", "Y"); 121 | resultMap.put("msg", "修改成功"); 122 | return resultMap; 123 | } 124 | 125 | /** 126 | * 删除 127 | * @author ${author} 128 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 129 | */ 130 | @ResponseBody 131 | @Transactional 132 | @RequestMapping(value = "/delete", method = RequestMethod.POST) 133 | public Map delete(@RequestBody JsonRequest<${className}Dto> jsonRequest) throws Exception { 134 | Map resultMap = new HashMap(16); 135 | List<${className}Dto> ${classNameLower}List = JSON.parseArray((jsonRequest.getExtend().get("${classNameLower}List")), ${className}Dto.class); 136 | for(${className}Dto ${classNameLower}Dto : ${classNameLower}List) { 137 | ${classNameLower}Service.deleteByPrimaryKey(${classNameLower}Dto); 138 | } 139 | resultMap.put("flag", "Y"); 140 | resultMap.put("msg", "删除成功"); 141 | return resultMap; 142 | } 143 | } -------------------------------------------------------------------------------- /template/LayUI/java/${basepackage_dir}/dao/${className}Dao.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.dao; 6 | 7 | import java.util.List; 8 | 9 | import ${basepackage}.dto.custom.${className}Dto; 10 | import org.springframework.stereotype.Repository; 11 | import ${commonspackage}.dao.BaseDao; 12 | 13 | /** 14 | * ${className}Dao 15 | * @author ${author} 16 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 17 | */ 18 | @Repository 19 | public interface ${className}Dao extends BaseDao<${className}Dto> { 20 | 21 | /** 22 | * 列表 23 | * @param ${classNameLower}Dto 24 | * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> 25 | * @author ${author} 26 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 27 | */ 28 | public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto); 29 | 30 | } -------------------------------------------------------------------------------- /template/LayUI/java/${basepackage_dir}/dto/custom/${className}Dto.java: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"/> 2 | <#include "/java_copyright.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.dto.custom; 6 | 7 | import java.io.Serializable; 8 | import javax.persistence.Table; 9 | import ${basepackage}.dto.domain.${className}DtoBase; 10 | 11 | /** 12 | * ${className}Dto 13 | * @author ${author} 14 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 15 | */ 16 | @Table(name = "${table.sqlName}") 17 | public class ${className}Dto extends ${className}DtoBase implements Serializable { 18 | 19 | private static final long serialVersionUID = ${className}Dto.class.getName().hashCode(); 20 | 21 | } -------------------------------------------------------------------------------- /template/LayUI/java/${basepackage_dir}/dto/domain/${className}DtoBase.java: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"/> 2 | <#include "/java_copyright.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.dto.domain; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.GenerationType; 12 | import javax.persistence.Id; 13 | 14 | import org.apache.commons.lang.builder.EqualsBuilder; 15 | import org.apache.commons.lang.builder.HashCodeBuilder; 16 | import org.apache.commons.lang.builder.ToStringBuilder; 17 | import org.apache.commons.lang.builder.ToStringStyle; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | 21 | import ${commonspackage}.dto.BaseDto; 22 | 23 | /** 24 | * ${className}DtoBase 25 | * @author ${author} 26 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 27 | */ 28 | public class ${className}DtoBase extends BaseDto implements Serializable { 29 | 30 | private static final long serialVersionUID = ${className}DtoBase.class.getName().hashCode(); 31 | 32 | <@generateFieldsNew/> 33 | <@generateProperties/> 34 | 35 | @Override 36 | public boolean equals(Object obj) { 37 | return EqualsBuilder.reflectionEquals(this, obj); 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return HashCodeBuilder.reflectionHashCode(this); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); 48 | } 49 | 50 | <#macro generateFieldsNew> 51 | <#--自定义函数,根据数据库中表字段生成java中的属性 --> 52 | <#list table.columns as column> 53 | /** ${column.columnAlias!} */ 54 | <#if column.isDateTimeColumn> 55 | <#if (column.columnNameLower != 'createdDate')&&(column.columnNameLower != 'updatedDate')> 56 | @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8") 57 | <#elseif (column.columnNameLower == 'createdDate')> 58 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 59 | <#elseif (column.columnNameLower == 'updatedDate')> 60 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 61 | <#else> 62 | 63 | private ${column.javaType} ${column.columnNameLower}; 64 | 65 | <#else> 66 | <#if column.pk> 67 | @Id 68 | @GeneratedValue(strategy = GenerationType.IDENTITY) 69 | 70 | private ${column.javaType} ${column.columnNameLower}; 71 | 72 | 73 | 74 | 75 | 76 | 77 | <#macro generateProperties> 78 | <#list table.columns as column> 79 | 80 | /** 81 | * 获取属性${column.columnAlias!}的值 82 | */ 83 | public ${column.javaType} get${column.columnName}() { 84 | return this.${column.columnNameLower}; 85 | } 86 | 87 | /** 88 | * 设置属性${column.columnAlias!}的值 89 | */ 90 | public void set${column.columnName}(${column.javaType} ${column.columnNameLower}) { 91 | this.${column.columnNameLower} = ${column.columnNameLower}; 92 | } 93 | 94 | 95 | } -------------------------------------------------------------------------------- /template/LayUI/java/${basepackage_dir}/service/${className}Service.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.service; 6 | 7 | import ${commonspackage}.service.IBaseService; 8 | import ${commonspackage}.mybatis.pagehelper.PageInfo; 9 | import ${basepackage}.dto.custom.${className}Dto; 10 | 11 | /** 12 | * ${className}Service 13 | * @author ${author} 14 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 15 | */ 16 | public interface ${className}Service extends IBaseService<${className}Dto> { 17 | 18 | /** 19 | * 列表 20 | * @param ${classNameLower}Dto 21 | * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> 22 | * @author ${author} 23 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 24 | */ 25 | public PageInfo<${className}Dto> findPageInfo(int page, int rows, ${className}Dto ${classNameLower}Dto, String orderBy); 26 | 27 | } -------------------------------------------------------------------------------- /template/LayUI/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.service.impl; 6 | 7 | import java.util.List; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import ${commonspackage}.mybatis.pagehelper.PageHelper; 13 | import ${commonspackage}.mybatis.pagehelper.PageInfo; 14 | import ${commonspackage}.service.BaseService; 15 | 16 | import ${basepackage}.dao.${className}Dao; 17 | import ${basepackage}.dto.custom.${className}Dto; 18 | import ${basepackage}.service.${className}Service; 19 | 20 | /** 21 | * ${className}ServiceImpl 22 | * @author ${author} 23 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 24 | */ 25 | @Service("${classNameLower}Service") 26 | public class ${className}ServiceImpl extends BaseService<${className}Dto> implements ${className}Service { 27 | 28 | @Autowired 29 | private ${className}Dao ${classNameLower}Dao; 30 | 31 | @Override 32 | public PageInfo<${className}Dto> findPageInfo(int page, int rows, ${className}Dto ${classNameLower}Dto, String orderBy) { 33 | PageHelper.startPage(page, rows, orderBy); 34 | List<${className}Dto> list = ${classNameLower}Dao.findPageInfo(${classNameLower}Dto); 35 | return new PageInfo<${className}Dto>(list); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /template/LayUI/java_copyright.include: -------------------------------------------------------------------------------- 1 | /* 2 | * PDMS wliduo https://github.com/dolyw 3 | * Created By dolyw.com 4 | * Date By (${now?string('yyyy-MM-dd HH:mm:ss')}) 5 | */ 6 | -------------------------------------------------------------------------------- /template/LayUI/macro.include: -------------------------------------------------------------------------------- 1 | <#-- 本文件包含一些公共的函数,本文件会被其它模板自动include --> 2 | 3 | <#-- 将value变成jsp el表达式,主要由于FreeMarker生成表达式不方便 --> 4 | <#macro jspEl value>${r"${"}${value}} 5 | 6 | <#-- 生成java构造函数 --> 7 | <#macro generateConstructor constructor> 8 | public ${constructor}Domain(){ 9 | } 10 | 11 | public ${constructor}Domain( 12 | <#list table.compositeIdColumns as column> 13 | ${column.javaType} ${column.columnNameLower}<#if column_has_next>, 14 | 15 | ){ 16 | <#list table.compositeIdColumns as column> 17 | <#if column.pk> 18 | this.${column.columnNameLower} = ${column.columnNameLower}; 19 | 20 | 21 | } 22 | 23 | 24 | 25 | <#-- 生成属性getter和setter方法 --> 26 | <#macro genGetSetProperties> 27 | <#list table.columns as column> 28 | 29 | public ${column.javaType} get${column.columnName}() { 30 | return this.${column.columnNameLower}; 31 | } 32 | 33 | public void set${column.columnName}(${column.javaType} value) { 34 | this.${column.columnNameLower} = value; 35 | } 36 | 37 | 38 | 39 | 40 | <#--页面生成非外键表单 --> 41 | <#macro generateForm column> 42 | 43 | <%=${className}Domain.ALIAS_${column.constantName}%>: 44 | 45 | <#if column.isDateTimeColumn> 46 | 47 | 49 | 50 | <#else> 51 | 52 | 53 | 54 | 55 | 56 | 57 | <#--toolbar.jsp页面生成外键表单查询用 --> 58 | <#macro generateFormOpen column fkPojoClass> 59 | 60 |
61 | <#if column.isDateTimeColumn> 62 |
63 | <#else> 64 |
65 | 66 | 67 |
68 | 76 | 77 | 78 | 79 | 80 | <#--jsp页面生成表单新增,编辑用,无弹出框--> 81 | <#macro generateEditForm column> 82 | 83 |
84 | <#if column.isDateTimeColumn> 85 |
86 | <#else> 87 |
88 | 89 | 90 | 91 | 92 | <#--jsp页面生成表单新增,编辑用,外键表单有弹出框--> 93 | <#macro generateEditFormOpen column fkPojoClass> 94 | 95 |
96 | <#if column.isDateTimeColumn> 97 |
98 | <#else> 99 |
100 | 101 | 102 |
103 | 111 | 112 | 113 | 114 | 115 | <#--主键数据类型,暂不考虑复合主键--> 116 | <#macro getPKDataType> 117 | ${table.pkColumn.javaType} 118 | 119 | 120 | <#--主键数据类型加上引号,以免在ibaits配置文件中不识别,暂不考虑复合主键--> 121 | <#macro getPKDataTypeForIbatis> 122 | "${table.pkColumn.javaType}" 123 | 124 | 125 | <#--返回主键的get方法,暂不考虑复合主键--> 126 | <#macro getPKGetMethod> 127 | get${table.pkColumn.columnName}() 128 | 129 | 130 | <#--查看页面(view.jsp)表单布局 --> 131 | <#macro generateViewForm column> 132 | 133 |
134 |
135 | 136 | 137 | 138 | <#--获取表中所有主键 --> 139 | <#macro generateIdQueryString> 140 | <#assign itemPrefix = 'item.'> 141 | <#compress> 142 | <#list table.compositeIdColumns as column> 143 | <#if column.isDateTimeColumn> 144 | <#t>${column.columnNameLower}=& 145 | <#else> 146 | <#t>${column.columnNameLower}=<@jspEl itemPrefix + column.columnNameLower/>& 147 | 148 | 149 | 150 | 151 | 152 | 153 | <#--获取表中所有主键,组装成新的方式传递到后台 --> 154 | <#macro generateIdForNew> 155 | <#list table.compositeIdColumns as column> 156 | <#if column.isDateTimeColumn> 157 | <#t>${column.columnNameLower}=& 158 | <#else> 159 | <#t>${column.columnNameLower}=row['${column.columnNameLower}']& 160 | 161 | 162 | 163 | 164 | <#--获取表中所有主键,组成json数据格式 --> 165 | <#macro generateCompIdJsonString> 166 | <#assign itemPrefix = 'item.'> 167 | <#compress> 168 | <#list table.compositeIdColumns as column> 169 | <#t>${column.columnNameLower}:'<@jspEl itemPrefix + column.columnNameLower/>'<#if column_has_next>, 170 | 171 | 172 | 173 | 174 | <#--主键--> 175 | <#macro getAllPK> 176 | <#list table.compositeIdColumns as column> 177 | java.lang.String ${column.columnNameLower}<#if column_has_next>, 178 | 179 | 180 | 181 | <#--把主键放入Map中--> 182 | <#macro setAllPKToMap> 183 | <#list table.compositeIdColumns as column> 184 | map.put("${column.columnNameLower}",${column.columnNameLower}); 185 | 186 | 187 | 188 | <#--domain中字段属性--> 189 | <#macro generateFields> 190 | <#list table.columns as column> 191 | /** 192 | * ${column.columnAlias!} db_column: ${column.sqlName} 193 | */ 194 | <#if column.isDateTimeColumn> 195 | @DateTimeFormat(pattern="yyyy-MM-dd") 196 | private ${column.javaType} ${column.columnNameLower}; 197 | <#else> 198 | private ${column.javaType} ${column.columnNameLower}; 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /template/LayUI/resources/i18n/${classNameFirstLower}_zh_CN.properties: -------------------------------------------------------------------------------- 1 | <#assign className = table.className> 2 | <#assign classNameLower =className?uncap_first> 3 | <#assign tableAlias = table.tableAlias> 4 | #--------${classNameLower}--------# 5 | ${className}Dto.queryTitle=${tableAlias}\u5217\u8868 6 | ${className}Dto.manage=${tableAlias}\u7ba1\u7406 7 | <#list table.columns as column> 8 | ${className}Dto.${column.columnNameLower}=${column.columnAlias!} 9 | -------------------------------------------------------------------------------- /template/LayUI/resources/mapper/${className}Dao.xml: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"/> 2 | <#assign className = table.className> 3 | <#assign classNameLower = className?uncap_first> 4 | 5 | 6 | 7 | 8 | 9 | 10 | <#list table.pkColumns as column> 11 | 12 | 13 | <#list table.notPkColumns as column> 14 | 15 | 16 | 17 | 18 | 19 | <#list table.columns as column> 20 | g.${column.sqlName} AS ${column.columnNameLower}<#if column_has_next>, 21 | 22 | 23 | 24 | 40 | 41 | -------------------------------------------------------------------------------- /template/LayUI/webapp/WEB-INF/${namespace}/${modulepackage}/${classNameFirstLower}/${classNameFirstLower}.jsp: -------------------------------------------------------------------------------- 1 | <#assign className = table.className> 2 | <#assign classNameLower =className?uncap_first> 3 | <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | <%@ include file="/WEB-INF/jsp/head-layui.jsp"%> 12 | 13 | 14 | 15 | 16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 |
24 | 25 | <#list table.columns as column> 26 | <#if (column_index==0)> 27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 | <#elseif ((column_index%3)!=0)&&(column_has_next)> 35 |
36 | 37 |
38 | 39 |
40 |
41 | <#elseif ((column_index%3)==0)&&(column_has_next)> 42 |
43 |
44 |
45 | 46 |
47 | 48 |
49 |
50 | <#elseif ((column_index%3)==0)&&(!column_has_next)> 51 |
52 |
53 |
54 | 55 |
56 | 57 |
58 |
59 |
60 | <#elseif ((column_index%3)!=0)&&(!column_has_next)&&((column_index%3)==1)> 61 |
62 | 63 |
64 | 65 |
66 |
67 |
68 | <#elseif ((column_index%3)!=0)&&(!column_has_next)&&((column_index%3)==2)> 69 |
70 | 71 |
72 | 73 |
74 |
75 |
76 | <#else> 77 | 78 | 79 | 80 |
81 |
82 | 83 | 84 |
85 |
86 | 87 |
88 | 89 | 90 | 91 |
92 |
93 |
94 |
95 |
96 |
97 | 98 |
99 | 100 | 101 | 102 | 109 | 110 | 111 | 116 | 117 | 118 | 198 | 199 | 200 | 201 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /template/LayUI/webapp/js/${modulepackage}/${classNameFirstLower}/${classNameFirstLower}.js: -------------------------------------------------------------------------------- 1 | <#assign className = table.className> 2 | <#assign classNameLower =className?uncap_first> 3 | /* ------------------------------ LayUI已初始化 ------------------------------ */ 4 | /* ------------------------------ 基础初始化 Start ------------------------------ */ 5 | // 数据表格绑定 6 | var ${classNameLower}Table = table.render({ 7 | elem: '#${classNameLower}Table', 8 | url: contextPath + '${classNameLower}/list', 9 | id: '${classNameLower}Table', 10 | contentType: 'application/json', 11 | // 头部工具栏按钮绑定 12 | toolbar: '#${classNameLower}ToolBar', 13 | // 右上角筛选打印 14 | defaultToolbar: ['filter', 'print'], 15 | method : 'post', 16 | loading: true, 17 | // 查询条件 18 | where: { 19 | // 排序字段 20 | field: "created_date", 21 | // 排序方式 22 | order: "desc" 23 | }, 24 | cols: [[ 25 | {type: 'checkbox', align:'center'}, 26 | <#list table.columns as column> 27 | <#if (column.columnNameLower=='invalidFlag')> 28 | {field: '${column.columnNameLower}', title: ${column.columnNameLower}Desc, align: 'center', sort: true, templet: function(obj) { 29 | if (obj.invalidFlag == 0) { 30 | return '有效'; 31 | } else { 32 | return '无效'; 33 | } 34 | }}, 35 | <#else> 36 | {field: '${column.columnNameLower}', title: ${column.columnNameLower}Desc, align: 'center', sort: true}, 37 | 38 | 39 | // 表格行工具栏按钮绑定 40 | {fixed: 'right', title:'操作', toolbar: '#${classNameLower}Bar', align:'center', minWidth: '180'} 41 | ]], 42 | page: true, 43 | limits: [10, 20, 30, 40, 50, 100, 150, 200, 300] 44 | }); 45 | 46 | // 数据表格监听头部工具栏按钮触发事件 47 | table.on('toolbar(${classNameLower}Table)', function(obj) { 48 | var checkStatus = table.checkStatus('${classNameLower}Table'), data = checkStatus.data; 49 | // data当前选中行数据数组 50 | switch(obj.event){ 51 | case 'add': 52 | // 执行预新增方法 53 | prepareInsert(); 54 | break; 55 | case 'del': 56 | // 执行预删除方法 57 | if (data.length < 1) { 58 | layer.msg('请最少选择一条数据'); 59 | } else { 60 | prepareDelete(data); 61 | } 62 | break; 63 | case 'export': 64 | // 执行导出选中数据 65 | exportFile(data); 66 | break; 67 | }; 68 | }); 69 | 70 | // 数据表格行监听表格工具栏按钮触发事件 71 | table.on('tool(${classNameLower}Table)', function(obj){ 72 | // obj.data当前行数据,obj.event当前行点击事件 73 | if (obj.event === 'detail') { 74 | // 点击查看按钮触发事件 75 | viewDetail(obj.data); 76 | } else if (obj.event === 'edit') { 77 | // 点击修改按钮触发事件 78 | prepareUpdate(obj.data); 79 | } else if (obj.event === 'del') { 80 | // 点击删除按钮触发事件,将本身包装成数组调用批量删除方法 81 | var list = []; 82 | list.push(obj.data); 83 | prepareDelete(list); 84 | } 85 | }); 86 | 87 | // 表单监听数据弹框提交事件 88 | form.on('submit(${classNameLower}Form)', function(data) { 89 | // data.field为当前提交form数据 90 | // console.log(JSON.stringify(data.field)); 91 | // 执行保存或更新 92 | deal${classNameLower}(); 93 | // 返回false防止页面刷新 94 | return false; 95 | }); 96 | 97 | // 表单向导初始化 98 | $('#${classNameLower}SmartWizard').smartWizard({ 99 | // 默认第一页 100 | selected: 0, 101 | // 主题 102 | theme: 'dots', 103 | // 下一步效果渐隐 104 | transitionEffect: 'fade', 105 | // 隐藏默认按钮,添加自定义按钮 106 | toolbarSettings: { 107 | showNextButton: false, 108 | showPreviousButton: false, 109 | toolbarExtraButtons: [ 110 | $('').text('上一步').addClass('layui-btn layui-btn-normal') 111 | .on('click', function(){ $('#${classNameLower}SmartWizard').smartWizard("prev"); }), 112 | $('').text('下一步').addClass('layui-btn layui-btn-normal') 113 | .on('click', function(){ $('#${classNameLower}SmartWizard').smartWizard("next"); }), 114 | $('').text('完成').addClass('layui-btn layui-btn-normal') 115 | .on('click', function(){ layer.closeAll(); }), 116 | $('').text('重置').addClass('layui-btn layui-btn-danger') 117 | .on('click', function(){ cleanData(); }) 118 | ] 119 | } 120 | }); 121 | 122 | // 表单向导操作按钮显示 123 | $("#${classNameLower}SmartWizard").on("showStep", function(e, anchorObject, stepNumber, stepDirection, stepPosition) { 124 | // stepNumber当前是第几页,从0开始 125 | // stepDirection行为描述,点击下一步为forward,上一步为backward 126 | // stepPosition第一页是first,最后一页是final,中间页为middle 127 | // 第一页和最后一页上下步按钮控制是否可用,完成按钮只有最后一页可见 128 | if (stepPosition === 'first') { 129 | $("#prevBtn").removeClass('layui-btn-normal').addClass('layui-btn-disabled'); 130 | $("#nextBtn").removeClass('layui-btn-disabled').addClass('layui-btn-normal'); 131 | $("#finishBtn").hide(); 132 | } else if (stepPosition === 'final') { 133 | $("#prevBtn").removeClass('layui-btn-disabled').addClass('layui-btn-normal'); 134 | $("#nextBtn").removeClass('layui-btn-normal').addClass('layui-btn-disabled'); 135 | $("#finishBtn").show(); 136 | } else { 137 | $("#prevBtn").removeClass('layui-btn-disabled').addClass('layui-btn-normal'); 138 | $("#nextBtn").removeClass('layui-btn-disabled').addClass('layui-btn-normal'); 139 | $("#finishBtn").hide(); 140 | } 141 | }); 142 | 143 | // 表单向导操作按钮事件 144 | $("#${classNameLower}SmartWizard").on("leaveStep", function(e, anchorObject, stepNumber, stepDirection) { 145 | // stepNumber当前是第几页,从0开始 146 | // stepDirection行为描述,点击下一步为forward,上一步为backward 147 | // 行为类型actionType不为查看 148 | if ($("#actionType").val() != "V") { 149 | // 第1页点击下一步事件 150 | if (stepNumber == "0" && stepDirection == "forward") { 151 | // 校验表单 152 | $("#${classNameLower}FormVerify").trigger("click"); 153 | // 判断是否校验通过,校验红框数大于0说明校验不通过 154 | if ($("input.layui-form-danger").length > 0) { 155 | return false; 156 | } else { 157 | return true; 158 | } 159 | } 160 | } 161 | }); 162 | 163 | // 数据表格查询按钮绑定事件 164 | $('#${classNameLower}TableQuery').on('click', function() { 165 | // 调用查询(数据表格重载)方法 166 | reloadTable(); 167 | }); 168 | /* ------------------------------ 基础初始化 End ------------------------------ */ 169 | 170 | /* ------------------------------ 自定义初始化 Start ------------------------------ */ 171 | 172 | // 自定义初始化代码..... 173 | 174 | /* ------------------------------ 自定义初始化 End ------------------------------ */ 175 | 176 | /* ------------------------------ 基础执行方法 Start ------------------------------ */ 177 | /** 178 | * 查询(数据表格重载)方法 179 | */ 180 | function reloadTable() { 181 | ${classNameLower}Table = table.reload('${classNameLower}Table', { 182 | page: { 183 | // 重新定位当前页 184 | // curr: userTable.config.page.curr 185 | // 重新定位第一页 186 | curr: 1 187 | }, 188 | where: { 189 | // 排序字段 190 | field: "created_date", 191 | // 排序方式 192 | order: "desc", 193 | // 查询条件 194 | <#list table.columns as column> 195 | "${column.columnNameLower}": $.trim($("#search${column.columnName}").val())<#if column_has_next>, 196 | 197 | } 198 | }); 199 | } 200 | 201 | /** 202 | * 预新增方法 203 | */ 204 | function prepareInsert() { 205 | $("#actionType").val("I"); 206 | // 新增数据弹框打开 207 | var prepareInsertOpen = layer.open({ 208 | type: 1, 209 | title: '新增', 210 | area: ['992px', '480px'], 211 | content: $('#${classNameLower}Content'), 212 | // 关闭窗口隐藏数据弹框内容,防止显示出来 213 | end: function(index, layero){ 214 | $('#${classNameLower}Content').hide(); 215 | } 216 | }); 217 | // 最大化窗口 218 | layer.full(prepareInsertOpen); 219 | // 清除数据弹框数据 220 | cleanData(); 221 | // 重置表单向导 222 | $('#${classNameLower}SmartWizard').smartWizard("reset"); 223 | } 224 | 225 | /** 226 | * 预修改方法 227 | */ 228 | function prepareUpdate(data) { 229 | $("#actionType").val("U"); 230 | // 修改数据弹框打开 231 | var prepareUpdateOpen = layer.open({ 232 | type: 1, 233 | title: '修改', 234 | area: ['992px', '480px'], 235 | content: $('#${classNameLower}Content'), 236 | // 关闭窗口隐藏数据弹框内容,防止显示出来 237 | end: function(index, layero){ 238 | $('#${classNameLower}Content').hide(); 239 | } 240 | }); 241 | // 最大化窗口 242 | layer.full(prepareUpdateOpen); 243 | // 清除数据弹框数据 244 | cleanData(); 245 | // 写入数据弹框数据 246 | writeData(data); 247 | // 表单向导重置 248 | $('#${classNameLower}SmartWizard').smartWizard("reset"); 249 | // 表单向导开启全部可点击,获取当前可li下所有同胞元素添加done移除disabled即可点击 250 | $("#${classNameLower}SmartWizard ul li[class='active']").siblings().addClass("done").removeClass("disabled"); 251 | } 252 | 253 | /** 254 | * 查看方法 255 | */ 256 | function viewDetail(data) { 257 | $("#actionType").val("V"); 258 | // 查看数据弹框打开 259 | var viewDetailOpen = layer.open({ 260 | type: 1, 261 | title: '查看', 262 | area: ['992px', '480px'], 263 | content: $('#${classNameLower}Content'), 264 | // 关闭窗口隐藏数据弹框内容,防止显示出来 265 | end: function(index, layero){ 266 | $('#${classNameLower}Content').hide(); 267 | } 268 | }); 269 | // 最大化窗口 270 | layer.full(viewDetailOpen); 271 | // 清除数据弹框数据 272 | cleanData(); 273 | // 写入数据弹框数据 274 | writeData(data); 275 | // 使数据弹框数据只读 276 | lockData(); 277 | // 表单向导重置 278 | $('#${classNameLower}SmartWizard').smartWizard("reset"); 279 | // 表单向导开启全部可点击,获取当前可li下所有同胞元素添加done移除disabled即可点击 280 | $("#${classNameLower}SmartWizard ul li[class='active']").siblings().addClass("done").removeClass("disabled"); 281 | // 隐藏表单向导操作按钮 282 | $("#${classNameLower}SmartWizard nav").hide(); 283 | 284 | } 285 | 286 | /** 287 | * 新增或修改方法 288 | */ 289 | function deal${classNameLower}() { 290 | // 判断是新增或修改 291 | var url = null; 292 | if ($("#actionType").val() == "I") { 293 | url = contextPath + "${classNameLower}/insert"; 294 | } else { 295 | url = contextPath + "${classNameLower}/update"; 296 | } 297 | var data = getData(); 298 | // 请求后台 299 | axios.post(url, data).then(function (response) { 300 | var data = response.data; 301 | if (data.flag == "N") { 302 | layer.alert(data.msg); 303 | } else { 304 | // 提示信息 305 | layer.msg(data.msg); 306 | reloadTable(); 307 | } 308 | }).catch(function (error) { 309 | layer.alert(error.toString()); 310 | console.log(error); 311 | }); 312 | } 313 | 314 | /** 315 | * 预删除方法 316 | */ 317 | function prepareDelete(list) { 318 | layer.confirm('确定删除吗', function(index){ 319 | deleteSure(list); 320 | layer.close(index); 321 | }); 322 | } 323 | 324 | /** 325 | * 删除方法 326 | */ 327 | function deleteSure(list) { 328 | // 请求后台 329 | axios.post(contextPath + '${classNameLower}/delete', { 330 | "extend" : { 331 | "${classNameLower}List" : JSON.stringify(list) 332 | } 333 | }).then(function (response) { 334 | var data = response.data; 335 | if (data.flag == "N") { 336 | layer.alert(data.msg); 337 | } else { 338 | layer.msg(data.msg); 339 | reloadTable(); 340 | } 341 | }).catch(function (error) { 342 | layer.alert(error.toString()); 343 | console.log(error); 344 | }); 345 | } 346 | 347 | /** 348 | * 导出数据方法 349 | */ 350 | function exportFile(data) { 351 | layui.use(['excel', 'xlsx', 'FileSaver'], function() { 352 | // 初始化excel模块 353 | var excel = layui.excel; 354 | try { 355 | // 判断数据是否大于0 356 | if (data.length > 0) { 357 | // 1. 数组头部新增表头 358 | data.unshift({ 359 | <#list table.columns as column> 360 | ${column.columnNameLower}: ${column.columnNameLower}Desc<#if column_has_next>, 361 | 362 | }); 363 | // 2. 如果需要调整顺序,请执行梳理函数 364 | var excelData = excel.filterExportData(data, [ 365 | <#list table.columns as column> 366 | "${column.columnNameLower}"<#if column_has_next>, 367 | 368 | ]); 369 | // 3. 执行导出函数,系统会弹出弹框 370 | excel.exportExcel({ 371 | sheet1: excelData 372 | }, '${className}.xlsx', 'xlsx'); 373 | layer.msg('导出成功'); 374 | } else { 375 | layer.msg("请最少选择一条数据"); 376 | } 377 | } catch (e) { 378 | layer.alert('导出错误:' + e.toString()); 379 | } 380 | }); 381 | } 382 | /* ------------------------------ 基础执行方法 End ------------------------------ */ 383 | 384 | /* ------------------------------ 基础通用方法 Start ------------------------------ */ 385 | /** 386 | * 获取数据弹框数据方法 387 | */ 388 | function getData() { 389 | return { 390 | <#list table.columns as column> 391 | "${column.columnNameLower}": $.trim($("#${column.columnNameLower}").val())<#if column_has_next>, 392 | 393 | } 394 | } 395 | 396 | /** 397 | * 清除数据弹框数据方法 398 | */ 399 | function cleanData() { 400 | <#list table.columns as column> 401 | $('#${column.columnNameLower}').prop("disabled", false).val(''); 402 | 403 | } 404 | 405 | /** 406 | * 写入数据弹框数据方法 407 | */ 408 | function writeData(data) { 409 | // 显示加载 410 | $('#${classNameLower}Content').loading("show"); 411 | // 请求后台 412 | axios.post(contextPath + '${classNameLower}/prepareUpdate', { 413 | <#list table.compositeIdColumns as column> 414 | '${column.columnNameLower}': data.${column.columnNameLower}<#if column_has_next>, 415 | 416 | }).then(function (response) { 417 | var data = response.data; 418 | if (data.flag == "N") { 419 | layer.alert(data.msg); 420 | } else { 421 | var ${classNameLower}Dto = data.${classNameLower}Dto; 422 | <#list table.columns as column> 423 | $('#${column.columnNameLower}').val(${classNameLower}Dto.${column.columnNameLower}); 424 | 425 | // 关闭加载 426 | $('#${classNameLower}Content').loading("destroy"); 427 | } 428 | }).catch(function (error) { 429 | layer.alert(error.toString()); 430 | console.log(error); 431 | }); 432 | } 433 | 434 | /** 435 | * 使数据弹框数据只读方法 436 | */ 437 | function lockData() { 438 | <#list table.columns as column> 439 | $('#${column.columnNameLower}').prop("disabled", true); 440 | 441 | } 442 | 443 | /* ------------------------------ 基础通用方法 End ------------------------------ */ 444 | 445 | /* ------------------------------ 自定义方法 Start ------------------------------ */ 446 | 447 | // 自定义方法..... 448 | 449 | /* ------------------------------ 自定义方法 End ------------------------------ */ -------------------------------------------------------------------------------- /template/RESTful/java/${basepackage_dir}/controller/${className}Controller.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.controller; 6 | 7 | import org.springframework.web.bind.annotation.*; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import ${basepackage}.dto.custom.${className}Dto; 10 | import ${basepackage}.service.I${className}Service; 11 | import ${basepackage}.common.ResponseBean; 12 | import ${basepackage}.exception.CustomException; 13 | 14 | import com.github.pagehelper.PageHelper; 15 | import com.github.pagehelper.PageInfo; 16 | import org.springframework.http.HttpStatus; 17 | import org.springframework.web.bind.annotation.*; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * ${className}Controller 26 | * @author ${author} 27 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 28 | */ 29 | @RestController 30 | @RequestMapping("${classNameLower}") 31 | public class ${className}Controller { 32 | 33 | private final I${className}Service ${classNameLower}Service; 34 | 35 | @Autowired 36 | public ${className}Controller (I${className}Service ${classNameLower}Service) { 37 | this.${classNameLower}Service = ${classNameLower}Service; 38 | } 39 | 40 | /** 41 | * 列表 42 | * @author ${author} 43 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 44 | */ 45 | @GetMapping 46 | public ResponseBean list(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer rows) { 47 | if (page <= 0 || rows <= 0) { 48 | page = 1; 49 | rows = 10; 50 | } 51 | PageHelper.startPage(page, rows); 52 | List<${className}Dto> list = ${classNameLower}Service.selectAll(); 53 | if (list == null || list.size() <= 0) { 54 | throw new CustomException("查询失败(Query Failure)"); 55 | } 56 | PageInfo<${className}Dto> pageInfo = new PageInfo<${className}Dto>(list); 57 | Map result = new HashMap(16); 58 | result.put("count", pageInfo.getTotal()); 59 | result.put("data", pageInfo.getList()); 60 | return new ResponseBean(HttpStatus.OK.value(), "查询成功(Query was successful)", result); 61 | } 62 | 63 | /** 64 | * 查询 65 | * @author ${author} 66 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 67 | */ 68 | @GetMapping("/{id}") 69 | public ResponseBean findById(@PathVariable("id") Integer id) { 70 | ${className}Dto ${classNameLower}Dto = ${classNameLower}Service.selectByPrimaryKey(id); 71 | if (${classNameLower}Dto == null) { 72 | throw new CustomException("查询失败(Query Failure)"); 73 | } 74 | return new ResponseBean(HttpStatus.OK.value(), "查询成功(Query was successful)", ${classNameLower}Dto); 75 | } 76 | 77 | /** 78 | * 新增 79 | * @author ${author} 80 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 81 | */ 82 | @PostMapping 83 | public ResponseBean add(@RequestBody ${className}Dto ${classNameLower}Dto) { 84 | int count = ${classNameLower}Service.insert(${classNameLower}Dto); 85 | // 操作数量小于0 86 | if (count <= 0) { 87 | throw new CustomException("新增失败(Insert Failure)"); 88 | } 89 | return new ResponseBean(HttpStatus.OK.value(), "新增成功(Insert Success)", ${classNameLower}Dto); 90 | } 91 | 92 | /** 93 | * 更新 94 | * @author ${author} 95 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 96 | */ 97 | @PutMapping 98 | public ResponseBean update(@RequestBody ${className}Dto ${classNameLower}Dto) { 99 | int count = ${classNameLower}Service.updateByPrimaryKeySelective(${classNameLower}Dto); 100 | // 操作数量小于0 101 | if (count <= 0) { 102 | throw new CustomException("更新失败(Update Failure)"); 103 | } 104 | return new ResponseBean(HttpStatus.OK.value(), "更新成功(Update Success)", ${classNameLower}Dto); 105 | } 106 | 107 | /** 108 | * 删除 109 | * @author ${author} 110 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 111 | */ 112 | @DeleteMapping("/{id}") 113 | public ResponseBean delete(@PathVariable("id") Integer id) { 114 | int count = ${classNameLower}Service.deleteByPrimaryKey(id); 115 | // 操作数量小于0 116 | if (count <= 0) { 117 | throw new CustomException("删除失败,ID不存在(Deletion Failed. ID does not exist.)"); 118 | } 119 | return new ResponseBean(HttpStatus.OK.value(), "删除成功(Delete Success)", null); 120 | } 121 | 122 | } -------------------------------------------------------------------------------- /template/RESTful/java/${basepackage_dir}/dao/${className}Dao.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.dao; 6 | 7 | import ${basepackage}.dto.custom.${className}Dto; 8 | import org.springframework.stereotype.Repository; 9 | import tk.mybatis.mapper.common.Mapper; 10 | import java.util.List; 11 | 12 | /** 13 | * ${className}Dao 14 | * @author ${author} 15 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 16 | */ 17 | @Repository 18 | public interface ${className}Dao extends Mapper<${className}Dto> { 19 | 20 | /** 21 | * 列表 22 | * @param ${classNameLower}Dto 23 | * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> 24 | * @author ${author} 25 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 26 | */ 27 | public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto); 28 | } -------------------------------------------------------------------------------- /template/RESTful/java/${basepackage_dir}/dto/custom/${className}Dto.java: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"/> 2 | <#include "/java_copyright.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.dto.custom; 6 | 7 | import java.io.Serializable; 8 | import javax.persistence.Table; 9 | import ${basepackage}.dto.domain.${className}DtoBase; 10 | 11 | /** 12 | * ${className}Dto 13 | * @author ${author} 14 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 15 | */ 16 | @Table(name = "${table.sqlName}") 17 | public class ${className}Dto extends ${className}DtoBase implements Serializable { 18 | 19 | private static final long serialVersionUID = ${className}Dto.class.getName().hashCode(); 20 | 21 | } -------------------------------------------------------------------------------- /template/RESTful/java/${basepackage_dir}/dto/domain/${className}DtoBase.java: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"/> 2 | <#include "/java_copyright.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.dto.domain; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.GenerationType; 12 | import javax.persistence.Id; 13 | 14 | import org.apache.commons.lang3.builder.EqualsBuilder; 15 | import org.apache.commons.lang3.builder.HashCodeBuilder; 16 | import org.apache.commons.lang3.builder.ToStringBuilder; 17 | import org.apache.commons.lang3.builder.ToStringStyle; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | 21 | /** 22 | * ${className}DtoBase 23 | * @author ${author} 24 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 25 | */ 26 | public class ${className}DtoBase implements Serializable { 27 | 28 | private static final long serialVersionUID = ${className}DtoBase.class.getName().hashCode(); 29 | 30 | <@generateFieldsNew/> 31 | <@generateProperties/> 32 | 33 | @Override 34 | public boolean equals(Object obj) { 35 | return EqualsBuilder.reflectionEquals(this, obj); 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | return HashCodeBuilder.reflectionHashCode(this); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); 46 | } 47 | 48 | <#macro generateFieldsNew> 49 | <#--自定义函数,根据数据库中表字段生成java中的属性 --> 50 | <#list table.columns as column> 51 | /** ${column.columnAlias!} */ 52 | <#if column.isDateTimeColumn> 53 | <#if (column.columnNameLower != 'createdDate')&&(column.columnNameLower != 'updatedDate')> 54 | @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8") 55 | <#elseif (column.columnNameLower == 'createdDate')> 56 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 57 | <#elseif (column.columnNameLower == 'updatedDate')> 58 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 59 | <#else> 60 | 61 | private ${column.javaType} ${column.columnNameLower}; 62 | 63 | <#else> 64 | <#if column.pk> 65 | @Id 66 | @GeneratedValue(strategy = GenerationType.IDENTITY) 67 | 68 | private ${column.javaType} ${column.columnNameLower}; 69 | 70 | 71 | 72 | 73 | 74 | 75 | <#macro generateProperties> 76 | <#list table.columns as column> 77 | 78 | /** 79 | * 获取属性${column.columnAlias!}的值 80 | */ 81 | public ${column.javaType} get${column.columnName}() { 82 | return this.${column.columnNameLower}; 83 | } 84 | 85 | /** 86 | * 设置属性${column.columnAlias!}的值 87 | */ 88 | public void set${column.columnName}(${column.javaType} ${column.columnNameLower}) { 89 | this.${column.columnNameLower} = ${column.columnNameLower}; 90 | } 91 | 92 | 93 | } -------------------------------------------------------------------------------- /template/RESTful/java/${basepackage_dir}/service/I${className}Service.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.service; 6 | 7 | import ${basepackage}.common.IBaseService; 8 | import ${basepackage}.dto.custom.${className}Dto; 9 | import java.util.List; 10 | 11 | /** 12 | * I${className}Service 13 | * @author ${author} 14 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 15 | */ 16 | public interface I${className}Service extends IBaseService<${className}Dto> { 17 | 18 | /** 19 | * 列表 20 | * @param ${classNameLower}Dto 21 | * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> 22 | * @author ${author} 23 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 24 | */ 25 | public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto); 26 | } -------------------------------------------------------------------------------- /template/RESTful/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java: -------------------------------------------------------------------------------- 1 | <#include "/java_copyright.include"> 2 | <#include "/macro.include"> 3 | <#assign className = table.className> 4 | <#assign classNameLower = className?uncap_first> 5 | package ${basepackage}.service.impl; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import ${basepackage}.common.impl.BaseServiceImpl; 10 | 11 | import ${basepackage}.dao.${className}Dao; 12 | import ${basepackage}.dto.custom.${className}Dto; 13 | import ${basepackage}.service.I${className}Service; 14 | import java.util.List; 15 | 16 | /** 17 | * ${className}ServiceImpl 18 | * @author ${author} 19 | * @date ${now?string('yyyy-MM-dd HH:mm:ss')} 20 | */ 21 | @Service("${classNameLower}Service") 22 | public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dto> implements I${className}Service { 23 | 24 | @Autowired 25 | private ${className}Dao ${classNameLower}Dao; 26 | 27 | @Override 28 | public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto) { 29 | return ${classNameLower}Dao.findPageInfo(${classNameLower}Dto); 30 | } 31 | } -------------------------------------------------------------------------------- /template/RESTful/java_copyright.include: -------------------------------------------------------------------------------- 1 | /* 2 | * PDMS wliduo https://github.com/dolyw 3 | * Created By dolyw.com 4 | * Date By (${now?string('yyyy-MM-dd HH:mm:ss')}) 5 | */ 6 | -------------------------------------------------------------------------------- /template/RESTful/macro.include: -------------------------------------------------------------------------------- 1 | <#-- 本文件包含一些公共的函数,本文件会被其它模板自动include --> 2 | 3 | <#-- 将value变成jsp el表达式,主要由于FreeMarker生成表达式不方便 --> 4 | <#macro jspEl value>${r"${"}${value}} 5 | 6 | <#-- 生成java构造函数 --> 7 | <#macro generateConstructor constructor> 8 | public ${constructor}Domain(){ 9 | } 10 | 11 | public ${constructor}Domain( 12 | <#list table.compositeIdColumns as column> 13 | ${column.javaType} ${column.columnNameLower}<#if column_has_next>, 14 | 15 | ){ 16 | <#list table.compositeIdColumns as column> 17 | <#if column.pk> 18 | this.${column.columnNameLower} = ${column.columnNameLower}; 19 | 20 | 21 | } 22 | 23 | 24 | 25 | <#-- 生成属性getter和setter方法 --> 26 | <#macro genGetSetProperties> 27 | <#list table.columns as column> 28 | 29 | public ${column.javaType} get${column.columnName}() { 30 | return this.${column.columnNameLower}; 31 | } 32 | 33 | public void set${column.columnName}(${column.javaType} value) { 34 | this.${column.columnNameLower} = value; 35 | } 36 | 37 | 38 | 39 | 40 | <#--页面生成非外键表单 --> 41 | <#macro generateForm column> 42 | 43 | <%=${className}Domain.ALIAS_${column.constantName}%>: 44 | 45 | <#if column.isDateTimeColumn> 46 | 47 | 49 | 50 | <#else> 51 | 52 | 53 | 54 | 55 | 56 | 57 | <#--toolbar.jsp页面生成外键表单查询用 --> 58 | <#macro generateFormOpen column fkPojoClass> 59 | 60 |
61 | <#if column.isDateTimeColumn> 62 |
63 | <#else> 64 |
65 | 66 | 67 |
68 | 76 | 77 | 78 | 79 | 80 | <#--jsp页面生成表单新增,编辑用,无弹出框--> 81 | <#macro generateEditForm column> 82 | 83 |
84 | <#if column.isDateTimeColumn> 85 |
86 | <#else> 87 |
88 | 89 | 90 | 91 | 92 | <#--jsp页面生成表单新增,编辑用,外键表单有弹出框--> 93 | <#macro generateEditFormOpen column fkPojoClass> 94 | 95 |
96 | <#if column.isDateTimeColumn> 97 |
98 | <#else> 99 |
100 | 101 | 102 |
103 | 111 | 112 | 113 | 114 | 115 | <#--主键数据类型,暂不考虑复合主键--> 116 | <#macro getPKDataType> 117 | ${table.pkColumn.javaType} 118 | 119 | 120 | <#--主键数据类型加上引号,以免在ibaits配置文件中不识别,暂不考虑复合主键--> 121 | <#macro getPKDataTypeForIbatis> 122 | "${table.pkColumn.javaType}" 123 | 124 | 125 | <#--返回主键的get方法,暂不考虑复合主键--> 126 | <#macro getPKGetMethod> 127 | get${table.pkColumn.columnName}() 128 | 129 | 130 | <#--查看页面(view.jsp)表单布局 --> 131 | <#macro generateViewForm column> 132 | 133 |
134 |
135 | 136 | 137 | 138 | <#--获取表中所有主键 --> 139 | <#macro generateIdQueryString> 140 | <#assign itemPrefix = 'item.'> 141 | <#compress> 142 | <#list table.compositeIdColumns as column> 143 | <#if column.isDateTimeColumn> 144 | <#t>${column.columnNameLower}=& 145 | <#else> 146 | <#t>${column.columnNameLower}=<@jspEl itemPrefix + column.columnNameLower/>& 147 | 148 | 149 | 150 | 151 | 152 | 153 | <#--获取表中所有主键,组装成新的方式传递到后台 --> 154 | <#macro generateIdForNew> 155 | <#list table.compositeIdColumns as column> 156 | <#if column.isDateTimeColumn> 157 | <#t>${column.columnNameLower}=& 158 | <#else> 159 | <#t>${column.columnNameLower}=row['${column.columnNameLower}']& 160 | 161 | 162 | 163 | 164 | <#--获取表中所有主键,组成json数据格式 --> 165 | <#macro generateCompIdJsonString> 166 | <#assign itemPrefix = 'item.'> 167 | <#compress> 168 | <#list table.compositeIdColumns as column> 169 | <#t>${column.columnNameLower}:'<@jspEl itemPrefix + column.columnNameLower/>'<#if column_has_next>, 170 | 171 | 172 | 173 | 174 | <#--主键--> 175 | <#macro getAllPK> 176 | <#list table.compositeIdColumns as column> 177 | java.lang.String ${column.columnNameLower}<#if column_has_next>, 178 | 179 | 180 | 181 | <#--把主键放入Map中--> 182 | <#macro setAllPKToMap> 183 | <#list table.compositeIdColumns as column> 184 | map.put("${column.columnNameLower}",${column.columnNameLower}); 185 | 186 | 187 | 188 | <#--domain中字段属性--> 189 | <#macro generateFields> 190 | <#list table.columns as column> 191 | /** 192 | * ${column.columnAlias!} db_column: ${column.sqlName} 193 | */ 194 | <#if column.isDateTimeColumn> 195 | @DateTimeFormat(pattern="yyyy-MM-dd") 196 | private ${column.javaType} ${column.columnNameLower}; 197 | <#else> 198 | private ${column.javaType} ${column.columnNameLower}; 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /template/RESTful/resources/i18n/${classNameFirstLower}_zh_CN.properties: -------------------------------------------------------------------------------- 1 | <#assign className = table.className> 2 | <#assign classNameLower =className?uncap_first> 3 | <#assign tableAlias = table.tableAlias> 4 | #--------${classNameLower}--------# 5 | ${className}Dto.queryTitle=${tableAlias}\u5217\u8868 6 | ${className}Dto.manage=${tableAlias}\u7ba1\u7406 7 | <#list table.columns as column> 8 | ${className}Dto.${column.columnNameLower}=${column.columnAlias!} 9 | -------------------------------------------------------------------------------- /template/RESTful/resources/mapper/${className}Dao.xml: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"/> 2 | <#assign className = table.className> 3 | <#assign classNameLower = className?uncap_first> 4 | 5 | 6 | 7 | 8 | 9 | 10 | <#list table.pkColumns as column> 11 | 12 | 13 | <#list table.notPkColumns as column> 14 | 15 | 16 | 17 | 18 | 19 | <#list table.columns as column> 20 | g.${column.sqlName} AS ${column.columnNameLower}<#if column_has_next>, 21 | 22 | 23 | 24 | 40 | 41 | -------------------------------------------------------------------------------- /template/RESTful/vue/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"> 2 | <#assign className = table.className> 3 | <#assign classNameLower = className?uncap_first> 4 | 88 | 89 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /template/RESTful/vue/api/${moduleName}/${classNameFirstLower}.js: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"> 2 | <#assign className = table.className> 3 | <#assign classNameLower = className?uncap_first> 4 | import http from '@/utils/httpRequest' 5 | 6 | export const baseURL = process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl 7 | 8 | /** 9 | * 列表查询 10 | * @param {*} searchForm 11 | */ 12 | export function list (searchForm) { 13 | return http({ 14 | url: baseURL + '/${moduleName}/${classNameLower}', 15 | method: 'get', 16 | params: searchForm 17 | }) 18 | } 19 | 20 | /** 21 | * 根据Id查询 22 | * @param {*} id 23 | */ 24 | export function findById (id) { 25 | return http({ 26 | url: baseURL + '/${moduleName}/${classNameLower}/' + id, 27 | method: 'get' 28 | }) 29 | } 30 | 31 | /** 32 | * 新增 33 | * @param {*} data 34 | */ 35 | export function add (data) { 36 | return http({ 37 | url: baseURL + '/${moduleName}/${classNameLower}', 38 | method: 'post', 39 | data 40 | }) 41 | } 42 | 43 | /** 44 | * 修改 45 | * @param {*} data 46 | */ 47 | export function update (data) { 48 | return http({ 49 | url: baseURL + '/${moduleName}/${classNameLower}', 50 | method: 'put', 51 | data 52 | }) 53 | } 54 | 55 | /** 56 | * 删除 57 | * @param {*} id 58 | */ 59 | export function delById (id) { 60 | return http({ 61 | url: baseURL + '/${moduleName}/${classNameLower}/' + id, 62 | method: 'delete' 63 | }) 64 | } 65 | -------------------------------------------------------------------------------- /template/RESTful/vue/views/modules/${moduleName}/${classNameFirstLower}.vue: -------------------------------------------------------------------------------- 1 | <#include "/macro.include"> 2 | <#assign className = table.className> 3 | <#assign classNameLower = className?uncap_first> 4 | 55 | 56 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /template/RESTful/vue/views/modules/${moduleName}/${classNameFirstLower}Edit.vue: -------------------------------------------------------------------------------- 1 | <#assign className = table.className> 2 | <#assign classNameLower = className?uncap_first> 3 | <#assign tableAlias = table.tableAlias> 4 | 28 | 29 | 150 | 151 | 152 | --------------------------------------------------------------------------------