From fee8a5955b61ce8e880f376c68b03a2ec8ac7dbb Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 02 十二月 2019 09:28:11 +0800
Subject: [PATCH] 若依 2.0
---
ruoyi-ui/src/views/tool/gen/genInfoForm.vue | 154 +
ruoyi/src/main/resources/vm/js/api.js.vm | 53
ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java | 66
ruoyi/pom.xml | 9
ruoyi/src/main/java/com/ruoyi/common/constant/GenConstants.java | 94
ruoyi-ui/src/views/system/user/index.vue | 31
ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml | 120 +
ruoyi/src/main/resources/vm/xml/mapper.xml.vm | 95
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java | 99
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java | 68
ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml | 8
ruoyi-ui/src/views/system/dict/index.vue | 1
ruoyi-ui/package.json | 2
ruoyi-ui/src/views/system/user/profile/index.vue | 10
ruoyi-ui/src/views/tool/gen/editTable.vue | 204 ++
ruoyi-ui/src/api/system/dict/type.js | 8
ruoyi/src/main/resources/vm/vue/index.vue.vm | 440 ++++
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java | 35
ruoyi-ui/src/router/index.js | 28
ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml | 8
ruoyi-ui/src/views/system/post/index.vue | 1
ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml | 8
ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java | 999 +++++++++
ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java | 93
ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java | 185 +
ruoyi-ui/src/views/tool/gen/importTable.vue | 114 +
ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java | 76
ruoyi-ui/src/utils/ruoyi.js | 50
ruoyi-ui/src/views/system/notice/index.vue | 1
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java | 1
ruoyi-ui/src/views/system/dept/index.vue | 1
ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java | 368 +++
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java | 340 +++
README.md | 4
ruoyi-ui/src/views/system/config/index.vue | 1
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java | 281 ++
ruoyi-ui/src/api/tool/gen.js | 59
ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java | 87
ruoyi/src/main/resources/vm/java/serviceImpl.java.vm | 109 +
ruoyi-ui/src/views/monitor/online/index.vue | 1
ruoyi-ui/src/utils/zipdownload.js | 40
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java | 1
ruoyi-ui/src/views/tool/gen/index.vue | 286 ++
ruoyi/src/main/resources/vm/java/controller.java.vm | 103 +
ruoyi-ui/src/views/system/role/index.vue | 1
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java | 44
ruoyi-ui/src/views/system/menu/index.vue | 1
ruoyi/src/main/resources/vm/sql/sql.vm | 22
ruoyi-ui/src/api/system/user.js | 3
ruoyi-ui/src/views/tool/swagger/index.vue | 1
ruoyi/src/main/resources/vm/java/service.java.vm | 61
ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml | 8
ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java | 39
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java | 10
ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml | 8
ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml | 181 +
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java | 2
ruoyi-ui/src/views/monitor/logininfor/index.vue | 1
ruoyi-ui/src/views/system/dict/data.vue | 1
ruoyi-ui/src/views/tool/gen/basicInfoForm.vue | 61
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java | 17
ruoyi/src/main/resources/vm/java/mapper.java.vm | 61
ruoyi-ui/src/views/monitor/druid/index.vue | 1
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java | 238 ++
ruoyi-ui/src/views/monitor/server/index.vue | 1
ruoyi-ui/src/assets/styles/ruoyi.scss | 14
ruoyi-ui/src/views/monitor/operlog/index.vue | 1
ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml | 8
/dev/null | 12
ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java | 269 ++
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java | 3
ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java | 52
ruoyi/sql/ry_20191202.sql | 6
ruoyi/src/main/resources/vm/java/domain.java.vm | 76
ruoyi/src/main/resources/application.yml | 15
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java | 2
76 files changed, 5,832 insertions(+), 130 deletions(-)
diff --git a/README.md b/README.md
index a859b1d..fd9c93b 100644
--- a/README.md
+++ b/README.md
@@ -71,6 +71,10 @@
<td><img src="https://oscimg.oschina.net/oscnet/509d2708cfd762b6e6339364cac1cc1970c.jpg"/></td>
</tr>
<tr>
+ <td><img src="https://oscimg.oschina.net/oscnet/up-f1fd681cc9d295db74e85ad6d2fe4389454.png"/></td>
+ <td><img src="https://oscimg.oschina.net/oscnet/up-c195234bbcd30be6927f037a6755e6ab69c.png"/></td>
+ </tr>
+ <tr>
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/5f3d39a141f21f81b90536f391b8408f1fa.jpg"/></td>
</tr>
diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json
index d6f08df..ceb331e 100644
--- a/ruoyi-ui/package.json
+++ b/ruoyi-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "ruoyi",
- "version": "1.1.0",
+ "version": "2.0.0",
"description": "鑻ヤ緷绠$悊绯荤粺",
"author": "鑻ヤ緷",
"license": "MIT",
diff --git a/ruoyi-ui/src/api/system/dict/type.js b/ruoyi-ui/src/api/system/dict/type.js
index 80a6cfa..4b45a35 100644
--- a/ruoyi-ui/src/api/system/dict/type.js
+++ b/ruoyi-ui/src/api/system/dict/type.js
@@ -51,3 +51,11 @@
params: query
})
}
+
+// 鑾峰彇瀛楀吀閫夋嫨妗嗗垪琛�
+export function optionselect() {
+ return request({
+ url: '/system/dict/type/optionselect',
+ method: 'get'
+ })
+}
\ No newline at end of file
diff --git a/ruoyi-ui/src/api/system/user.js b/ruoyi-ui/src/api/system/user.js
index 3b1170e..45c09eb 100644
--- a/ruoyi-ui/src/api/system/user.js
+++ b/ruoyi-ui/src/api/system/user.js
@@ -1,4 +1,5 @@
import request from '@/utils/request'
+import { praseStrEmpty } from "@/utils/ruoyi";
// 鏌ヨ鐢ㄦ埛鍒楄〃
export function listUser(query) {
@@ -12,7 +13,7 @@
// 鏌ヨ鐢ㄦ埛璇︾粏
export function getUser(userId) {
return request({
- url: '/system/user/' + userId,
+ url: '/system/user/' + praseStrEmpty(userId),
method: 'get'
})
}
diff --git a/ruoyi-ui/src/api/tool/gen.js b/ruoyi-ui/src/api/tool/gen.js
new file mode 100644
index 0000000..21b9b83
--- /dev/null
+++ b/ruoyi-ui/src/api/tool/gen.js
@@ -0,0 +1,59 @@
+import request from '@/utils/request'
+
+// 鏌ヨ鐢熸垚琛ㄦ暟鎹�
+export function listTable(query) {
+ return request({
+ url: '/tool/gen/list',
+ method: 'get',
+ params: query
+ })
+}
+// 鏌ヨdb鏁版嵁搴撳垪琛�
+export function listDbTable(query) {
+ return request({
+ url: '/tool/gen/db/list',
+ method: 'get',
+ params: query
+ })
+}
+
+// 鏌ヨ琛ㄨ缁嗕俊鎭�
+export function getGenTable(tableId) {
+ return request({
+ url: '/tool/gen/' + tableId,
+ method: 'get'
+ })
+}
+
+// 淇敼浠g爜鐢熸垚淇℃伅
+export function updateGenTable(data) {
+ return request({
+ url: '/tool/gen',
+ method: 'put',
+ data: data
+ })
+}
+
+// 瀵煎叆琛�
+export function importTable(data) {
+ return request({
+ url: '/tool/gen/importTable',
+ method: 'post',
+ params: data
+ })
+}
+// 棰勮鐢熸垚浠g爜
+export function previewTable(tableId) {
+ return request({
+ url: '/tool/gen/preview/' + tableId,
+ method: 'get'
+ })
+}
+// 鍒犻櫎琛ㄦ暟鎹�
+export function delTable(tableId) {
+ return request({
+ url: '/tool/gen/' + tableId,
+ method: 'delete'
+ })
+}
+
diff --git a/ruoyi-ui/src/assets/styles/ruoyi.scss b/ruoyi-ui/src/assets/styles/ruoyi.scss
index 9e0cdc3..77307e5 100644
--- a/ruoyi-ui/src/assets/styles/ruoyi.scss
+++ b/ruoyi-ui/src/assets/styles/ruoyi.scss
@@ -53,6 +53,10 @@
margin-left: 20px;
}
+.el-dialog {
+ margin-top: 6vh !important;
+}
+
.el-table .el-table__header-wrapper th {
word-break: break-word;
background-color: #f8f8f9;
@@ -61,6 +65,16 @@
font-size: 13px;
}
+/** 琛ㄥ崟甯冨眬 **/
+.form-header {
+ font-size:15px;
+ color:#6379bb;
+ border-bottom:1px solid #ddd;
+ margin:8px 10px 25px 10px;
+ padding-bottom:5px
+}
+
+/** 琛ㄦ牸甯冨眬 **/
.pagination-container {
position: relative;
height: 25px;
diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js
index 526d755..47ddd61 100644
--- a/ruoyi-ui/src/router/index.js
+++ b/ruoyi-ui/src/router/index.js
@@ -27,17 +27,6 @@
// 鍏叡璺敱
export const constantRoutes = [
{
- path: '/redirect',
- component: Layout,
- hidden: true,
- children: [
- {
- path: '/redirect/:path*',
- component: () => import('@/views/redirect')
- }
- ]
- },
- {
path: '/login',
component: () => import('@/views/login'),
hidden: true
@@ -74,7 +63,7 @@
{
path: 'profile',
component: () => import('@/views/system/user/profile/index'),
- name: '涓汉涓績',
+ name: 'Profile',
meta: { title: '涓汉涓績', icon: 'user' }
}
]
@@ -87,10 +76,23 @@
{
path: 'type/data/:dictId(\\d+)',
component: () => import('@/views/system/dict/data'),
- name: '瀛楀吀鏁版嵁',
+ name: 'Data',
meta: { title: '瀛楀吀鏁版嵁', icon: '' }
}
]
+ },
+ {
+ path: '/gen',
+ component: Layout,
+ hidden: true,
+ children: [
+ {
+ path: 'edit',
+ component: () => import('@/views/tool/gen/editTable'),
+ name: 'GenEdit',
+ meta: { title: '淇敼鐢熸垚閰嶇疆' }
+ }
+ ]
}
]
diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js
index db97dcc..602fdd6 100644
--- a/ruoyi-ui/src/utils/ruoyi.js
+++ b/ruoyi-ui/src/utils/ruoyi.js
@@ -9,21 +9,21 @@
export function parseTime(time, pattern) {
if (arguments.length === 0) {
return null
- }
- const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
- let date
- if (typeof time === 'object') {
+ }
+ const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
+ let date
+ if (typeof time === 'object') {
date = time
- } else {
+ } else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
- time = parseInt(time)
+ time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
- time = time * 1000
+ time = time * 1000
}
date = new Date(time)
- }
- const formatObj = {
+ }
+ const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
@@ -31,22 +31,22 @@
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
- }
- const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
+ }
+ const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
- if (key === 'a') { return ['鏃�', '涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�'][value ] }
+ if (key === 'a') { return ['鏃�', '涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�'][value] }
if (result.length > 0 && value < 10) {
- value = '0' + value
+ value = '0' + value
}
return value || 0
- })
- return time_str
+ })
+ return time_str
}
// 琛ㄥ崟閲嶇疆
export function resetForm(refName) {
- if (this.$refs[refName] !== undefined) {
+ if (this.$refs[refName]) {
this.$refs[refName].resetFields();
}
}
@@ -54,11 +54,11 @@
// 娣诲姞鏃ユ湡鑼冨洿
export function addDateRange(params, dateRange) {
var search = params;
- if (null != dateRange) {
- search.params = {
- beginTime: this.dateRange[0],
- endTime: this.dateRange[1]
- };
+ search.beginTime = "";
+ search.endTime = "";
+ if (null != dateRange && '' != dateRange) {
+ search.beginTime = this.dateRange[0];
+ search.endTime = this.dateRange[1];
}
return search;
}
@@ -92,4 +92,12 @@
return arg;
});
return flag ? str : '';
+}
+
+// 杞崲瀛楃涓诧紝undefined,null绛夎浆鍖栦负""
+export function praseStrEmpty(str) {
+ if (!str || str == "undefined" || str == "null") {
+ return "";
+ }
+ return str;
}
\ No newline at end of file
diff --git a/ruoyi-ui/src/utils/zipdownload.js b/ruoyi-ui/src/utils/zipdownload.js
new file mode 100644
index 0000000..3a86814
--- /dev/null
+++ b/ruoyi-ui/src/utils/zipdownload.js
@@ -0,0 +1,40 @@
+import axios from 'axios'
+import { getToken } from '@/utils/auth'
+
+const mimeMap = {
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ zip: 'application/zip'
+}
+
+const baseUrl = process.env.VUE_APP_BASE_API
+export function downLoadZip(str, filename) {
+ var url = baseUrl + str
+ axios({
+ method: 'get',
+ url: url,
+ responseType: 'blob',
+ headers: { 'Authorization': 'Bearer ' + getToken() }
+ }).then(res => {
+ resolveBlob(res, mimeMap.zip)
+ })
+}
+/**
+ * 瑙f瀽blob鍝嶅簲鍐呭骞朵笅杞�
+ * @param {*} res blob鍝嶅簲鍐呭
+ * @param {String} mimeType MIME绫诲瀷
+ */
+export function resolveBlob(res, mimeType) {
+ const aLink = document.createElement('a')
+ var blob = new Blob([res.data], { type: mimeType })
+ // //浠巖esponse鐨刪eaders涓幏鍙杅ilename, 鍚庣response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 璁剧疆鐨勬枃浠跺悕;
+ var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
+ var contentDisposition = decodeURI(res.headers['content-disposition'])
+ var result = patt.exec(contentDisposition)
+ var fileName = result[1]
+ fileName = fileName.replace(/\"/g, '')
+ aLink.href = URL.createObjectURL(blob)
+ aLink.setAttribute('download', fileName) // 璁剧疆涓嬭浇鏂囦欢鍚嶇О
+ document.body.appendChild(aLink)
+ aLink.click()
+ document.body.appendChild(aLink)
+}
diff --git a/ruoyi-ui/src/views/monitor/druid/index.vue b/ruoyi-ui/src/views/monitor/druid/index.vue
index 6ab35b2..9e8e1e7 100644
--- a/ruoyi-ui/src/views/monitor/druid/index.vue
+++ b/ruoyi-ui/src/views/monitor/druid/index.vue
@@ -5,6 +5,7 @@
</template>
<script>
export default {
+ name: "Druid",
data() {
return {
src: process.env.VUE_APP_BASE_API + "/druid/index.html",
diff --git a/ruoyi-ui/src/views/monitor/logininfor/index.vue b/ruoyi-ui/src/views/monitor/logininfor/index.vue
index 9dee330..e2f422e 100644
--- a/ruoyi-ui/src/views/monitor/logininfor/index.vue
+++ b/ruoyi-ui/src/views/monitor/logininfor/index.vue
@@ -117,6 +117,7 @@
import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor";
export default {
+ name: "Logininfor",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/monitor/online/index.vue b/ruoyi-ui/src/views/monitor/online/index.vue
index e5b4b1f..72c4a53 100644
--- a/ruoyi-ui/src/views/monitor/online/index.vue
+++ b/ruoyi-ui/src/views/monitor/online/index.vue
@@ -68,6 +68,7 @@
import { list, forceLogout } from "@/api/monitor/online";
export default {
+ name: "Online",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/monitor/operlog/index.vue b/ruoyi-ui/src/views/monitor/operlog/index.vue
index 187de28..f5e2e63 100644
--- a/ruoyi-ui/src/views/monitor/operlog/index.vue
+++ b/ruoyi-ui/src/views/monitor/operlog/index.vue
@@ -186,6 +186,7 @@
import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog";
export default {
+ name: "Operlog",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/monitor/server/index.vue b/ruoyi-ui/src/views/monitor/server/index.vue
index 36c95e3..6a5060d 100644
--- a/ruoyi-ui/src/views/monitor/server/index.vue
+++ b/ruoyi-ui/src/views/monitor/server/index.vue
@@ -175,6 +175,7 @@
import { getServer } from "@/api/monitor/server";
export default {
+ name: "Server",
data() {
return {
// 鍔犺浇灞備俊鎭�
diff --git a/ruoyi-ui/src/views/redirect.vue b/ruoyi-ui/src/views/redirect.vue
deleted file mode 100644
index 6a62cb7..0000000
--- a/ruoyi-ui/src/views/redirect.vue
+++ /dev/null
@@ -1,12 +0,0 @@
-<script>
-export default {
- created() {
- const { params, query } = this.$route
- const { path } = params
- this.$router.replace({ path: '/' + path, query })
- },
- render: function(h) {
- return h() // avoid warning message
- }
-}
-</script>
diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue
index b84fac5..354f7e0 100644
--- a/ruoyi-ui/src/views/system/config/index.vue
+++ b/ruoyi-ui/src/views/system/config/index.vue
@@ -168,6 +168,7 @@
import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig } from "@/api/system/config";
export default {
+ name: "Config",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue
index 735c3b9..bcefdb8 100644
--- a/ruoyi-ui/src/views/system/dept/index.vue
+++ b/ruoyi-ui/src/views/system/dept/index.vue
@@ -143,6 +143,7 @@
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
+ name: "Dept",
components: { Treeselect },
data() {
return {
diff --git a/ruoyi-ui/src/views/system/dict/data.vue b/ruoyi-ui/src/views/system/dict/data.vue
index 649e302..dcb8cb7 100644
--- a/ruoyi-ui/src/views/system/dict/data.vue
+++ b/ruoyi-ui/src/views/system/dict/data.vue
@@ -159,6 +159,7 @@
import { listType, getType } from "@/api/system/dict/type";
export default {
+ name: "Data",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/system/dict/index.vue b/ruoyi-ui/src/views/system/dict/index.vue
index 2dd211f..44ca109 100644
--- a/ruoyi-ui/src/views/system/dict/index.vue
+++ b/ruoyi-ui/src/views/system/dict/index.vue
@@ -176,6 +176,7 @@
import { listType, getType, delType, addType, updateType, exportType } from "@/api/system/dict/type";
export default {
+ name: "Dict",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue
index eda8d21..b1a5cdb 100644
--- a/ruoyi-ui/src/views/system/menu/index.vue
+++ b/ruoyi-ui/src/views/system/menu/index.vue
@@ -179,6 +179,7 @@
import IconSelect from "@/components/IconSelect";
export default {
+ name: "Menu",
components: { Treeselect, IconSelect },
data() {
return {
diff --git a/ruoyi-ui/src/views/system/notice/index.vue b/ruoyi-ui/src/views/system/notice/index.vue
index caedc50..404bec3 100644
--- a/ruoyi-ui/src/views/system/notice/index.vue
+++ b/ruoyi-ui/src/views/system/notice/index.vue
@@ -176,6 +176,7 @@
import Editor from '@/components/Editor';
export default {
+ name: "Notice",
components: {
Editor
},
diff --git a/ruoyi-ui/src/views/system/post/index.vue b/ruoyi-ui/src/views/system/post/index.vue
index 5c4f28f..ffd3f42 100644
--- a/ruoyi-ui/src/views/system/post/index.vue
+++ b/ruoyi-ui/src/views/system/post/index.vue
@@ -153,6 +153,7 @@
import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post";
export default {
+ name: "Post",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue
index 05379c2..497fed6 100644
--- a/ruoyi-ui/src/views/system/role/index.vue
+++ b/ruoyi-ui/src/views/system/role/index.vue
@@ -238,6 +238,7 @@
import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
export default {
+ name: "Role",
data() {
return {
// 閬僵灞�
diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue
index 760036b..00c3645 100644
--- a/ruoyi-ui/src/views/system/user/index.vue
+++ b/ruoyi-ui/src/views/system/user/index.vue
@@ -290,12 +290,11 @@
<script>
import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus } from "@/api/system/user";
import { treeselect } from "@/api/system/dept";
-import { listPost } from "@/api/system/post";
-import { listRole } from "@/api/system/role";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
+ name: "User",
components: { Treeselect },
data() {
return {
@@ -423,18 +422,6 @@
this.queryParams.deptId = data.id;
this.getList();
},
- /** 鏌ヨ宀椾綅鍒楄〃 */
- getPosts() {
- listPost().then(response => {
- this.postOptions = response.rows;
- });
- },
- /** 鏌ヨ瑙掕壊鍒楄〃 */
- getRoles() {
- listRole().then(response => {
- this.roleOptions = response.rows;
- });
- },
// 鐢ㄦ埛鐘舵�佷慨鏀�
handleStatusChange(row) {
let text = row.status === "0" ? "鍚敤" : "鍋滅敤";
@@ -494,21 +481,23 @@
handleAdd() {
this.reset();
this.getTreeselect();
- this.getPosts();
- this.getRoles();
- this.open = true;
- this.title = "娣诲姞鐢ㄦ埛";
- this.form.password = this.initPassword;
+ getUser().then(response => {
+ this.postOptions = response.posts;
+ this.roleOptions = response.roles;
+ this.open = true;
+ this.title = "娣诲姞鐢ㄦ埛";
+ this.form.password = this.initPassword;
+ });
},
/** 淇敼鎸夐挳鎿嶄綔 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
- this.getPosts();
- this.getRoles();
const userId = row.userId || this.ids
getUser(userId).then(response => {
this.form = response.data;
+ this.postOptions = response.posts;
+ this.roleOptions = response.roles;
this.form.postIds = response.postIds;
this.form.roleIds = response.roleIds;
this.open = true;
diff --git a/ruoyi-ui/src/views/system/user/profile/index.vue b/ruoyi-ui/src/views/system/user/profile/index.vue
index 3b7a117..7aff197 100644
--- a/ruoyi-ui/src/views/system/user/profile/index.vue
+++ b/ruoyi-ui/src/views/system/user/profile/index.vue
@@ -89,13 +89,3 @@
}
};
</script>
-
-<style rel="stylesheet/scss" lang="scss">
-.avatar-uploader-icon {
- font-size: 28px;
- width: 120px;
- height: 120px;
- line-height: 120px;
- text-align: center;
-}
-</style>
diff --git a/ruoyi-ui/src/views/tool/gen/basicInfoForm.vue b/ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
new file mode 100644
index 0000000..f3e8717
--- /dev/null
+++ b/ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
@@ -0,0 +1,61 @@
+<template>
+ <el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="琛ㄥ悕绉�" prop="tableName">
+ <el-input placeholder="璇疯緭鍏ヤ粨搴撳悕绉�" v-model="info.tableName" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="琛ㄦ弿杩�" prop="tableComment">
+ <el-input placeholder="璇疯緭鍏�" v-model="info.tableComment" />
+ </el-form-item>
+ </el-col>
+
+ <el-col :span="12">
+ <el-form-item label="瀹炰綋绫诲悕绉�" prop="className">
+ <el-input placeholder="璇疯緭鍏�" v-model="info.className" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="浣滆��" prop="functionAuthor">
+ <el-input placeholder="璇疯緭鍏�" v-model="info.functionAuthor" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="24">
+ <el-form-item label="澶囨敞" prop="remark">
+ <el-input type="textarea" :rows="3" v-model="info.remark"></el-input>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+</template>
+<script>
+export default {
+ name: "BasicInfoForm",
+ props: {
+ info: {
+ type: Object,
+ default: null
+ }
+ },
+ data() {
+ return {
+ rules: {
+ tableName: [
+ { required: true, message: "璇疯緭鍏ヨ〃鍚嶇О", trigger: "blur" }
+ ],
+ tableComment: [
+ { required: true, message: "璇疯緭鍏ヨ〃鎻忚堪", trigger: "blur" }
+ ],
+ className: [
+ { required: true, message: "璇疯緭鍏ュ疄浣撶被鍚嶇О", trigger: "blur" }
+ ],
+ functionAuthor: [
+ { required: true, message: "璇疯緭鍏ヤ綔鑰�", trigger: "blur" }
+ ]
+ }
+ };
+ }
+};
+</script>
diff --git a/ruoyi-ui/src/views/tool/gen/editTable.vue b/ruoyi-ui/src/views/tool/gen/editTable.vue
new file mode 100644
index 0000000..3897aa4
--- /dev/null
+++ b/ruoyi-ui/src/views/tool/gen/editTable.vue
@@ -0,0 +1,204 @@
+<template>
+ <el-card>
+ <el-tabs v-model="activeName">
+ <el-tab-pane label="鍩烘湰淇℃伅" name="basic">
+ <basic-info-form ref="basicInfo" :info="info" />
+ </el-tab-pane>
+ <el-tab-pane label="瀛楁淇℃伅" name="cloum">
+ <el-table :data="cloumns" :max-height="tableHeight">
+ <el-table-column label="搴忓彿" type="index" min-width="5%" />
+ <el-table-column
+ label="瀛楁鍒楀悕"
+ prop="columnName"
+ min-width="10%"
+ :show-overflow-tooltip="true"
+ />
+ <el-table-column
+ label="瀛楁鎻忚堪"
+ prop="columnComment"
+ min-width="10%"
+ :show-overflow-tooltip="true"
+ />
+ <el-table-column
+ label="鐗╃悊绫诲瀷"
+ prop="columnType"
+ min-width="10%"
+ :show-overflow-tooltip="true"
+ />
+ <el-table-column label="Java绫诲瀷" min-width="11%">
+ <template slot-scope="scope">
+ <el-select v-model="scope.row.javaType">
+ <el-option label="Long" value="Long" />
+ <el-option label="String" value="String" />
+ <el-option label="Ingeter" value="Ingeter" />
+ <el-option label="Double" value="Double" />
+ <el-option label="BigDecimal" value="BigDecimal" />
+ <el-option label="Date" value="Date" />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column label="java灞炴��" min-width="10%">
+ <template slot-scope="scope">
+ <el-input v-model="scope.row.javaField"></el-input>
+ </template>
+ </el-table-column>
+
+ <el-table-column label="鎻掑叆" min-width="5%">
+ <template slot-scope="scope">
+ <el-checkbox true-label="1" v-model="scope.row.isInsert"></el-checkbox>
+ </template>
+ </el-table-column>
+ <el-table-column label="缂栬緫" min-width="5%">
+ <template slot-scope="scope">
+ <el-checkbox true-label="1" v-model="scope.row.isEdit"></el-checkbox>
+ </template>
+ </el-table-column>
+ <el-table-column label="鍒楄〃" min-width="5%">
+ <template slot-scope="scope">
+ <el-checkbox true-label="1" v-model="scope.row.isList"></el-checkbox>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏌ヨ" min-width="5%">
+ <template slot-scope="scope">
+ <el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏌ヨ鏂瑰紡" min-width="10%">
+ <template slot-scope="scope">
+ <el-select v-model="scope.row.queryType">
+ <el-option label="=" value="EQ" />
+ <el-option label="!=" value="NE" />
+ <el-option label=">" value="GT" />
+ <el-option label=">=" value="GTE" />
+ <el-option label="<" value="LT" />
+ <el-option label="<=" value="LTE" />
+ <el-option label="LIKE" value="LIKE" />
+ <el-option label="BETWEEN" value="BETWEEN" />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column label="蹇呭~" min-width="5%">
+ <template slot-scope="scope">
+ <el-checkbox true-label="1" v-model="scope.row.isRequired"></el-checkbox>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏄剧ず绫诲瀷" min-width="12%">
+ <template slot-scope="scope">
+ <el-select v-model="scope.row.htmlType">
+ <el-option label="鏂囨湰妗�" value="input" />
+ <el-option label="鏂囨湰鍩�" value="textarea" />
+ <el-option label="涓嬫媺妗�" value="select" />
+ <el-option label="鍗曢�夋" value="radio" />
+ <el-option label="澶嶉�夋" value="checkbox" />
+ <el-option label="鏃ユ湡鎺т欢" value="datetime" />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column label="瀛楀吀绫诲瀷" min-width="12%">
+ <template slot-scope="scope">
+ <el-select v-model="scope.row.dictType" clearable filterable placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="dict in dictOptions"
+ :key="dict.dictType"
+ :label="dict.dictName"
+ :value="dict.dictType">
+ <span style="float: left">{{ dict.dictName }}</span>
+ <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
+ </el-option>
+ </el-select>
+ </template>
+ </el-table-column>
+ </el-table>
+ </el-tab-pane>
+ <el-tab-pane label="鐢熸垚淇℃伅" name="genInfo">
+ <gen-info-form ref="genInfo" :info="info" />
+ </el-tab-pane>
+ </el-tabs>
+ <el-form label-width="100px">
+ <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
+ <el-button type="primary" @click="submitForm()">鎻愪氦</el-button>
+ <el-button @click="close()">杩斿洖</el-button>
+ </el-form-item>
+ </el-form>
+ </el-card>
+</template>
+<script>
+import { getGenTable, updateGenTable } from "@/api/tool/gen";
+import { optionselect as getDictOptionselect } from "@/api/system/dict/type";
+import basicInfoForm from "./basicInfoForm";
+import genInfoForm from "./genInfoForm";
+export default {
+ name: "GenEdit",
+ components: {
+ basicInfoForm,
+ genInfoForm
+ },
+ data() {
+ return {
+ // 閫変腑閫夐」鍗$殑 name
+ activeName: "cloum",
+ // 琛ㄦ牸鐨勯珮搴�
+ tableHeight: document.documentElement.scrollHeight - 245 + "px",
+ // 琛ㄥ垪淇℃伅
+ cloumns: [],
+ // 瀛楀吀淇℃伅
+ dictOptions: [],
+ // 琛ㄨ缁嗕俊鎭�
+ info: {}
+ };
+ },
+ beforeCreate() {
+ const { tableId } = this.$route.query;
+ if (tableId) {
+ // 鑾峰彇琛ㄨ缁嗕俊鎭�
+ getGenTable(tableId).then(res => {
+ this.cloumns = res.data.rows;
+ this.info = res.data.info;
+ });
+ /** 鏌ヨ瀛楀吀涓嬫媺鍒楄〃 */
+ getDictOptionselect().then(response => {
+ this.dictOptions = response.data;
+ });
+ }
+ },
+ methods: {
+ /** 鎻愪氦鎸夐挳 */
+ submitForm() {
+ const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
+ const genForm = this.$refs.genInfo.$refs.genInfoForm;
+ Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
+ const validateResult = res.every(item => !!item);
+ if (validateResult) {
+ const genTable = Object.assign({}, basicForm.model, genForm.model);
+ genTable.columns = this.cloumns;
+ genTable.params = {
+ treeCode: genTable.treeCode,
+ treeName: genTable.treeName,
+ treeParentCode: genTable.treeParentCode
+ };
+ updateGenTable(genTable).then(res => {
+ this.msgSuccess(res.msg);
+ if (res.code === 200) {
+ this.close();
+ }
+ });
+ } else {
+ this.msgError("琛ㄥ崟鏍¢獙鏈�氳繃锛岃閲嶆柊妫�鏌ユ彁浜ゅ唴瀹�");
+ }
+ });
+ },
+ getFormPromise(form) {
+ return new Promise(resolve => {
+ form.validate(res => {
+ resolve(res);
+ });
+ });
+ },
+ /** 鍏抽棴鎸夐挳 */
+ close() {
+ this.$store.dispatch("tagsView/delView", this.$route);
+ this.$router.push({ path: "/tool/gen", query: { t: Date.now()}})
+ }
+ }
+};
+</script>
diff --git a/ruoyi-ui/src/views/tool/gen/genInfoForm.vue b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue
new file mode 100644
index 0000000..7b9a32a
--- /dev/null
+++ b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue
@@ -0,0 +1,154 @@
+<template>
+ <el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px">
+ <el-row>
+ <el-col :span="12">
+ <el-form-item prop="tplCategory">
+ <span slot="label">鐢熸垚妯℃澘</span>
+ <el-select v-model="info.tplCategory">
+ <el-option label="鍗曡〃锛堝鍒犳敼鏌ワ級" value="crud" />
+ <el-option label="鏍戣〃锛堝鍒犳敼鏌ワ級" value="tree" disabled/>
+ </el-select>
+ </el-form-item>
+ </el-col>
+
+ <el-col :span="12">
+ <el-form-item prop="packageName">
+ <span slot="label">
+ 鐢熸垚鍖呰矾寰�
+ <el-tooltip content="鐢熸垚鍦ㄥ摢涓猨ava鍖呬笅锛屼緥濡� com.ruoyi.system" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-input v-model="info.packageName" />
+ </el-form-item>
+ </el-col>
+
+ <el-col :span="12">
+ <el-form-item prop="moduleName">
+ <span slot="label">
+ 鐢熸垚妯″潡鍚�
+ <el-tooltip content="鍙悊瑙d负瀛愮郴缁熷悕锛屼緥濡� system" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-input v-model="info.moduleName" />
+ </el-form-item>
+ </el-col>
+
+ <el-col :span="12">
+ <el-form-item prop="businessName">
+ <span slot="label">
+ 鐢熸垚涓氬姟鍚�
+ <el-tooltip content="鍙悊瑙d负鍔熻兘鑻辨枃鍚嶏紝渚嬪 user" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-input v-model="info.businessName" />
+ </el-form-item>
+ </el-col>
+
+ <el-col :span="12">
+ <el-form-item prop="functionName">
+ <span slot="label">
+ 鐢熸垚鍔熻兘鍚�
+ <el-tooltip content="鐢ㄤ綔绫绘弿杩帮紝渚嬪 鐢ㄦ埛" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-input v-model="info.functionName" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+
+ <el-row v-show="info.tplCategory == 'tree'">
+ <h4 class="form-header">鍏朵粬淇℃伅</h4>
+ <el-col :span="12">
+ <el-form-item>
+ <span slot="label">
+ 鏍戠紪鐮佸瓧娈�
+ <el-tooltip content="鏍戞樉绀虹殑缂栫爜瀛楁鍚嶏紝 濡傦細dept_id" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-select v-model="info.treeCode" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="column in info.columns"
+ :key="column.columnName"
+ :label="column.columnName + '锛�' + column.columnComment"
+ :value="column.columnName"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item>
+ <span slot="label">
+ 鏍戠埗缂栫爜瀛楁
+ <el-tooltip content="鏍戞樉绀虹殑鐖剁紪鐮佸瓧娈靛悕锛� 濡傦細parent_Id" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-select v-model="info.treeParentCode" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="column in info.columns"
+ :key="column.columnName"
+ :label="column.columnName + '锛�' + column.columnComment"
+ :value="column.columnName"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item>
+ <span slot="label">
+ 鏍戝悕绉板瓧娈�
+ <el-tooltip content="鏍戣妭鐐圭殑鏄剧ず鍚嶇О瀛楁鍚嶏紝 濡傦細dept_name" placement="top">
+ <i class="el-icon-question"></i>
+ </el-tooltip>
+ </span>
+ <el-select v-model="info.treeName" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="column in info.columns"
+ :key="column.columnName"
+ :label="column.columnName + '锛�' + column.columnComment"
+ :value="column.columnName"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+</template>
+<script>
+export default {
+ name: "BasicInfoForm",
+ props: {
+ info: {
+ type: Object,
+ default: null
+ }
+ },
+ data() {
+ return {
+ rules: {
+ tplCategory: [
+ { required: true, message: "璇烽�夋嫨鐢熸垚妯℃澘", trigger: "blur" }
+ ],
+ packageName: [
+ { required: true, message: "璇疯緭鍏ョ敓鎴愬寘璺緞", trigger: "blur" }
+ ],
+ moduleName: [
+ { required: true, message: "璇疯緭鍏ョ敓鎴愭ā鍧楀悕", trigger: "blur" }
+ ],
+ businessName: [
+ { required: true, message: "璇疯緭鍏ョ敓鎴愪笟鍔″悕", trigger: "blur" }
+ ],
+ functionName: [
+ { required: true, message: "璇疯緭鍏ョ敓鎴愬姛鑳藉悕", trigger: "blur" }
+ ]
+ }
+ };
+ },
+ created() {}
+};
+</script>
diff --git a/ruoyi-ui/src/views/tool/gen/importTable.vue b/ruoyi-ui/src/views/tool/gen/importTable.vue
new file mode 100644
index 0000000..e441870
--- /dev/null
+++ b/ruoyi-ui/src/views/tool/gen/importTable.vue
@@ -0,0 +1,114 @@
+<template>
+ <!-- 瀵煎叆琛� -->
+ <el-dialog title="瀵煎叆琛�" :visible.sync="visible" width="800px" top="5vh">
+ <el-form :model="queryParams" ref="queryForm" :inline="true">
+ <el-form-item label="琛ㄥ悕绉�" prop="tableName">
+ <el-input
+ v-model="queryParams.tableName"
+ placeholder="璇疯緭鍏ヨ〃鍚嶇О"
+ clearable
+ size="small"
+ @keyup.enter.native="handleQuery"
+ />
+ </el-form-item>
+ <el-form-item label="琛ㄦ弿杩�" prop="tableComment">
+ <el-input
+ v-model="queryParams.tableComment"
+ placeholder="璇疯緭鍏ヨ〃鎻忚堪"
+ clearable
+ size="small"
+ @keyup.enter.native="handleQuery"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
+ <el-row>
+ <el-table :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
+ <el-table-column type="selection" width="55"></el-table-column>
+ <el-table-column prop="tableName" label="琛ㄥ悕绉�"></el-table-column>
+ <el-table-column prop="tableComment" label="琛ㄦ弿杩�"></el-table-column>
+ <el-table-column prop="createTime" label="鍒涘缓鏃堕棿"></el-table-column>
+ <el-table-column prop="updateTime" label="鏇存柊鏃堕棿"></el-table-column>
+ </el-table>
+ <pagination
+ v-show="total>0"
+ :total="total"
+ :page.sync="queryParams.pageNum"
+ :limit.sync="queryParams.pageSize"
+ @pagination="getList"
+ />
+ </el-row>
+ <div slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="handleImportTable">纭� 瀹�</el-button>
+ <el-button @click="visible = false">鍙� 娑�</el-button>
+ </div>
+ </el-dialog>
+</template>
+
+<script>
+import { listDbTable, importTable } from "@/api/tool/gen";
+export default {
+ data() {
+ return {
+ // 閬僵灞�
+ visible: false,
+ // 閫変腑鏁扮粍鍊�
+ tables: [],
+ // 鎬绘潯鏁�
+ total: 0,
+ // 琛ㄦ暟鎹�
+ dbTableList: [],
+ // 鏌ヨ鍙傛暟
+ queryParams: {
+ pageNum: 1,
+ pageSize: 10,
+ tableName: undefined,
+ tableComment: undefined
+ }
+ };
+ },
+ methods: {
+ // 鏄剧ず寮规
+ show() {
+ this.getList();
+ this.visible = true;
+ },
+ // 澶氶�夋閫変腑鏁版嵁
+ handleSelectionChange(selection) {
+ this.tables = selection.map(item => item.tableName);
+ },
+ // 鏌ヨ琛ㄦ暟鎹�
+ getList() {
+ listDbTable(this.queryParams).then(res => {
+ if (res.code === 200) {
+ this.dbTableList = res.rows;
+ this.total = res.total;
+ }
+ });
+ },
+ /** 鎼滅储鎸夐挳鎿嶄綔 */
+ handleQuery() {
+ this.queryParams.pageNum = 1;
+ this.getList();
+ },
+ /** 閲嶇疆鎸夐挳鎿嶄綔 */
+ resetQuery() {
+ this.resetForm("queryForm");
+ this.handleQuery();
+ },
+ /** 瀵煎叆鎸夐挳鎿嶄綔 */
+ handleImportTable() {
+ importTable({ tables: this.tables.join(",") }).then(res => {
+ this.msgSuccess(res.msg);
+ if (res.code === 200) {
+ this.visible = false;
+ this.$emit("ok");
+ }
+ });
+ }
+ }
+};
+</script>
diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue
index c0c0673..0c159a0 100644
--- a/ruoyi-ui/src/views/tool/gen/index.vue
+++ b/ruoyi-ui/src/views/tool/gen/index.vue
@@ -1,5 +1,287 @@
<template>
<div class="app-container">
- 浠g爜鐢熸垚
+ <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
+ <el-form-item label="琛ㄥ悕绉�" prop="tableName">
+ <el-input
+ v-model="queryParams.tableName"
+ placeholder="璇疯緭鍏ヨ〃鍚嶇О"
+ clearable
+ size="small"
+ @keyup.enter.native="handleQuery"
+ />
+ </el-form-item>
+ <el-form-item label="琛ㄦ弿杩�" prop="tableComment">
+ <el-input
+ v-model="queryParams.tableComment"
+ placeholder="璇疯緭鍏ヨ〃鎻忚堪"
+ clearable
+ size="small"
+ @keyup.enter.native="handleQuery"
+ />
+ </el-form-item>
+ <el-form-item label="鍒涘缓鏃堕棿">
+ <el-date-picker
+ v-model="dateRange"
+ size="small"
+ style="width: 240px"
+ value-format="yyyy-MM-dd"
+ type="daterange"
+ range-separator="-"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ ></el-date-picker>
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
+
+ <el-row :gutter="10" class="mb8">
+ <el-col :span="1.5">
+ <el-button
+ type="primary"
+ icon="el-icon-download"
+ size="mini"
+ @click="handleGenTable"
+ v-hasPermi="['tool:gen:code']"
+ >鐢熸垚</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="info"
+ icon="el-icon-upload"
+ size="mini"
+ @click="openImportTable"
+ v-hasPermi="['tool:gen:import']"
+ >瀵煎叆</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="success"
+ icon="el-icon-edit"
+ size="mini"
+ :disabled="single"
+ @click="handleEditTable"
+ v-hasPermi="['tool:gen:edit']"
+ >淇敼</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="danger"
+ icon="el-icon-delete"
+ size="mini"
+ :disabled="multiple"
+ @click="handleDelete"
+ v-hasPermi="['tool:gen:remove']"
+ >鍒犻櫎</el-button>
+ </el-col>
+ </el-row>
+
+ <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="55"></el-table-column>
+ <el-table-column label="搴忓彿" align="center" prop="tableId" width="50px" />
+ <el-table-column
+ label="琛ㄥ悕绉�"
+ align="center"
+ prop="tableName"
+ :show-overflow-tooltip="true"
+ width="130"
+ />
+ <el-table-column
+ label="琛ㄦ弿杩�"
+ align="center"
+ prop="tableComment"
+ :show-overflow-tooltip="true"
+ width="130"
+ />
+ <el-table-column
+ label="瀹炰綋"
+ align="center"
+ prop="className"
+ :show-overflow-tooltip="true"
+ width="130"
+ />
+ <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="160" />
+ <el-table-column label="鏇存柊鏃堕棿" align="center" prop="updateTime" width="160" />
+ <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
+ <template slot-scope="scope">
+ <el-button
+ type="text"
+ size="small"
+ icon="el-icon-view"
+ @click="handlePreview(scope.row)"
+ v-hasPermi="['tool:gen:preview']"
+ >棰勮</el-button>
+ <el-button
+ type="text"
+ size="small"
+ icon="el-icon-edit"
+ @click="handleEditTable(scope.row)"
+ v-hasPermi="['tool:gen:edit']"
+ >缂栬緫</el-button>
+ <el-button
+ type="text"
+ size="small"
+ icon="el-icon-delete"
+ @click="handleDelete(scope.row)"
+ v-hasPermi="['tool:gen:remove']"
+ >鍒犻櫎</el-button>
+ <el-button
+ type="text"
+ size="small"
+ icon="el-icon-download"
+ @click="handleGenTable(scope.row)"
+ v-hasPermi="['tool:gen:code']"
+ >鐢熸垚浠g爜</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <pagination
+ v-show="total>0"
+ :total="total"
+ :page.sync="queryParams.pageNum"
+ :limit.sync="queryParams.pageSize"
+ @pagination="getList"
+ />
+ <!-- 棰勮鐣岄潰 -->
+ <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh">
+ <el-tabs v-model="preview.activeName">
+ <el-tab-pane
+ v-for="(value, key) in preview.data"
+ :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
+ :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
+ :key="key"
+ >
+ <pre>{{ value }}</pre>
+ </el-tab-pane>
+ </el-tabs>
+ </el-dialog>
+ <import-table ref="import" @ok="handleQuery" />
</div>
-</template>
\ No newline at end of file
+</template>
+
+<script>
+import { listTable, previewTable, delTable } from "@/api/tool/gen";
+import importTable from "./importTable";
+import { downLoadZip } from "@/utils/zipdownload";
+export default {
+ name: "Gen",
+ components: { importTable },
+ data() {
+ return {
+ // 閬僵灞�
+ loading: true,
+ // 鍞竴鏍囪瘑绗�
+ uniqueId: "",
+ // 閫変腑鏁扮粍
+ ids: [],
+ // 閫変腑琛ㄦ暟缁�
+ tableNames: [],
+ // 闈炲崟涓鐢�
+ single: true,
+ // 闈炲涓鐢�
+ multiple: true,
+ // 鎬绘潯鏁�
+ total: 0,
+ // 琛ㄦ暟鎹�
+ tableList: [],
+ // 鏃ユ湡鑼冨洿
+ dateRange: "",
+ // 鏌ヨ鍙傛暟
+ queryParams: {
+ pageNum: 1,
+ pageSize: 10,
+ tableName: undefined,
+ tableComment: undefined
+ },
+ // 棰勮鍙傛暟
+ preview: {
+ open: false,
+ title: "浠g爜棰勮",
+ data: {},
+ activeName: "domain.java"
+ }
+ };
+ },
+ created() {
+ this.getList();
+ },
+ activated() {
+ const time = this.$route.query.t;
+ if (time != null && time != this.uniqueId) {
+ this.uniqueId = time;
+ this.resetQuery();
+ }
+ },
+ methods: {
+ /** 鏌ヨ琛ㄩ泦鍚� */
+ getList() {
+ this.loading = true;
+ listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
+ this.tableList = response.rows;
+ this.total = response.total;
+ this.loading = false;
+ }
+ );
+ },
+ /** 鎼滅储鎸夐挳鎿嶄綔 */
+ handleQuery() {
+ this.queryParams.pageNum = 1;
+ this.getList();
+ },
+ /** 鐢熸垚浠g爜鎿嶄綔 */
+ handleGenTable(row) {
+ const tableNames = row.tableName || this.tableNames;
+ if (tableNames == "") {
+ this.msgError("璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁");
+ return;
+ }
+ downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
+ },
+ /** 鎵撳紑瀵煎叆琛ㄥ脊绐� */
+ openImportTable() {
+ this.$refs.import.show();
+ },
+ /** 閲嶇疆鎸夐挳鎿嶄綔 */
+ resetQuery() {
+ this.dateRange = [];
+ this.resetForm("queryForm");
+ this.handleQuery();
+ },
+ /** 棰勮鎸夐挳 */
+ handlePreview(row) {
+ previewTable(row.tableId).then(response => {
+ this.preview.data = response.data;
+ this.preview.open = true;
+ });
+ },
+ // 澶氶�夋閫変腑鏁版嵁
+ handleSelectionChange(selection) {
+ this.ids = selection.map(item => item.tableId);
+ this.tableNames = selection.map(item => item.tableName);
+ this.single = selection.length != 1;
+ this.multiple = !selection.length;
+ },
+ /** 淇敼鎸夐挳鎿嶄綔 */
+ handleEditTable(row) {
+ const tableId = row.tableId || this.ids[0];
+ this.$router.push({ path: "/gen/edit", query: { tableId: tableId } });
+ },
+ /** 鍒犻櫎鎸夐挳鎿嶄綔 */
+ handleDelete(row) {
+ const tableIds = row.tableId || this.ids;
+ this.$confirm('鏄惁纭鍒犻櫎琛ㄧ紪鍙蜂负"' + tableIds + '"鐨勬暟鎹」?', "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ }).then(function() {
+ return delTable(tableIds);
+ }).then(() => {
+ this.getList();
+ this.msgSuccess("鍒犻櫎鎴愬姛");
+ }).catch(function() {});
+ }
+ }
+};
+</script>
\ No newline at end of file
diff --git a/ruoyi-ui/src/views/tool/swagger/index.vue b/ruoyi-ui/src/views/tool/swagger/index.vue
index 00484e2..624b59a 100644
--- a/ruoyi-ui/src/views/tool/swagger/index.vue
+++ b/ruoyi-ui/src/views/tool/swagger/index.vue
@@ -5,6 +5,7 @@
</template>
<script>
export default {
+ name: "Swagger",
data() {
return {
src: process.env.VUE_APP_BASE_API + "/swagger-ui.html",
diff --git a/ruoyi/pom.xml b/ruoyi/pom.xml
index f9f6b9a..d44b49f 100644
--- a/ruoyi/pom.xml
+++ b/ruoyi/pom.xml
@@ -5,7 +5,7 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId>
- <version>1.1</version>
+ <version>2.0.0</version>
<packaging>jar</packaging>
<name>ruoyi</name>
@@ -34,6 +34,7 @@
<swagger.version>2.9.2</swagger.version>
<poi.version>3.17</poi.version>
<oshi.version>3.9.1</oshi.version>
+ <velocity.version>1.7</velocity.version>
</properties>
<dependencies>
@@ -231,6 +232,12 @@
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
+ <!--velocity浠g爜鐢熸垚浣跨敤妯℃澘 -->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>${velocity.version}</version>
+ </dependency>
</dependencies>
diff --git a/ruoyi/sql/ry_20191120.sql b/ruoyi/sql/ry_20191202.sql
similarity index 98%
rename from ruoyi/sql/ry_20191120.sql
rename to ruoyi/sql/ry_20191202.sql
index b5adba5..6e4e78e 100644
--- a/ruoyi/sql/ry_20191120.sql
+++ b/ruoyi/sql/ry_20191202.sql
@@ -246,8 +246,9 @@
insert into sys_menu values('1055', '鐢熸垚鏌ヨ', '114', '1', '#', '', 1, 'F', '0', 'tool:gen:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1056', '鐢熸垚淇敼', '114', '2', '#', '', 1, 'F', '0', 'tool:gen:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1057', '鐢熸垚鍒犻櫎', '114', '3', '#', '', 1, 'F', '0', 'tool:gen:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-insert into sys_menu values('1058', '棰勮浠g爜', '114', '4', '#', '', 1, 'F', '0', 'tool:gen:preview', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-insert into sys_menu values('1059', '鐢熸垚浠g爜', '114', '5', '#', '', 1, 'F', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
+insert into sys_menu values('1058', '瀵煎叆浠g爜', '114', '2', '#', '', 1, 'F', '0', 'tool:gen:import', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
+insert into sys_menu values('1059', '棰勮浠g爜', '114', '4', '#', '', 1, 'F', '0', 'tool:gen:preview', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
+insert into sys_menu values('1060', '鐢熸垚浠g爜', '114', '5', '#', '', 1, 'F', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- ----------------------------
@@ -362,6 +363,7 @@
insert into sys_role_menu values ('2', '1057');
insert into sys_role_menu values ('2', '1058');
insert into sys_role_menu values ('2', '1059');
+insert into sys_role_menu values ('2', '1060');
-- ----------------------------
-- 8銆佽鑹插拰閮ㄩ棬鍏宠仈琛� 瑙掕壊1-N閮ㄩ棬
diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/GenConstants.java b/ruoyi/src/main/java/com/ruoyi/common/constant/GenConstants.java
new file mode 100644
index 0000000..068969b
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/common/constant/GenConstants.java
@@ -0,0 +1,94 @@
+package com.ruoyi.common.constant;
+
+/**
+ * 浠g爜鐢熸垚閫氱敤甯搁噺
+ *
+ * @author ruoyi
+ */
+public class GenConstants
+{
+ /** 鍗曡〃锛堝鍒犳敼鏌ワ級 */
+ public static final String TPL_CRUD = "crud";
+
+ /** 鏍戣〃锛堝鍒犳敼鏌ワ級 */
+ public static final String TPL_TREE = "tree";
+
+ /** 鏍戠紪鐮佸瓧娈� */
+ public static final String TREE_CODE = "treeCode";
+
+ /** 鏍戠埗缂栫爜瀛楁 */
+ public static final String TREE_PARENT_CODE = "treeParentCode";
+
+ /** 鏍戝悕绉板瓧娈� */
+ public static final String TREE_NAME = "treeName";
+
+ /** 鏁版嵁搴撳瓧绗︿覆绫诲瀷 */
+ public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
+ "mediumtext", "longtext" };
+
+ /** 鏁版嵁搴撴椂闂寸被鍨� */
+ public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
+
+ /** 鏁版嵁搴撴暟瀛楃被鍨� */
+ public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
+ "bigint", "float", "float", "double", "decimal" };
+
+ /** 椤甸潰涓嶉渶瑕佺紪杈戝瓧娈� */
+ public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
+
+ /** 椤甸潰涓嶉渶瑕佹樉绀虹殑鍒楄〃瀛楁 */
+ public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
+ "update_time" };
+
+ /** 椤甸潰涓嶉渶瑕佹煡璇㈠瓧娈� */
+ public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
+ "update_time", "remark" };
+
+ /** Entity鍩虹被瀛楁 */
+ public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
+
+ /** Tree鍩虹被瀛楁 */
+ public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors" };
+
+ /** 鏂囨湰妗� */
+ public static final String HTML_INPUT = "input";
+
+ /** 鏂囨湰鍩� */
+ public static final String HTML_TEXTAREA = "textarea";
+
+ /** 涓嬫媺妗� */
+ public static final String HTML_SELECT = "select";
+
+ /** 鍗曢�夋 */
+ public static final String HTML_RADIO = "radio";
+
+ /** 澶嶉�夋 */
+ public static final String HTML_CHECKBOX = "checkbox";
+
+ /** 鏃ユ湡鎺т欢 */
+ public static final String HTML_DATETIME = "datetime";
+
+ /** 瀛楃涓茬被鍨� */
+ public static final String TYPE_STRING = "String";
+
+ /** 鏁村瀷 */
+ public static final String TYPE_INTEGER = "Integer";
+
+ /** 闀挎暣鍨� */
+ public static final String TYPE_LONG = "Long";
+
+ /** 娴偣鍨� */
+ public static final String TYPE_DOUBLE = "Double";
+
+ /** 楂樼簿搴﹁绠楃被鍨� */
+ public static final String TYPE_BIGDECIMAL = "BigDecimal";
+
+ /** 鏃堕棿绫诲瀷 */
+ public static final String TYPE_DATE = "Date";
+
+ /** 妯$硦鏌ヨ */
+ public static final String QUERY_LIKE = "LIKE";
+
+ /** 闇�瑕� */
+ public static final String REQUIRE = "1";
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java b/ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java
new file mode 100644
index 0000000..f273cf7
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java
@@ -0,0 +1,87 @@
+package com.ruoyi.common.utils.text;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * 瀛楃闆嗗伐鍏风被
+ *
+ * @author ruoyi
+ *
+ */
+public class CharsetKit
+{
+ /** ISO-8859-1 */
+ public static final String ISO_8859_1 = "ISO-8859-1";
+ /** UTF-8 */
+ public static final String UTF_8 = "UTF-8";
+ /** GBK */
+ public static final String GBK = "GBK";
+
+ /** ISO-8859-1 */
+ public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
+ /** UTF-8 */
+ public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
+ /** GBK */
+ public static final Charset CHARSET_GBK = Charset.forName(GBK);
+
+ /**
+ * 杞崲涓篊harset瀵硅薄
+ *
+ * @param charset 瀛楃闆嗭紝涓虹┖鍒欒繑鍥為粯璁ゅ瓧绗﹂泦
+ * @return Charset
+ */
+ public static Charset charset(String charset)
+ {
+ return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
+ }
+
+ /**
+ * 杞崲瀛楃涓茬殑瀛楃闆嗙紪鐮�
+ *
+ * @param source 瀛楃涓�
+ * @param srcCharset 婧愬瓧绗﹂泦锛岄粯璁SO-8859-1
+ * @param destCharset 鐩爣瀛楃闆嗭紝榛樿UTF-8
+ * @return 杞崲鍚庣殑瀛楃闆�
+ */
+ public static String convert(String source, String srcCharset, String destCharset)
+ {
+ return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
+ }
+
+ /**
+ * 杞崲瀛楃涓茬殑瀛楃闆嗙紪鐮�
+ *
+ * @param source 瀛楃涓�
+ * @param srcCharset 婧愬瓧绗﹂泦锛岄粯璁SO-8859-1
+ * @param destCharset 鐩爣瀛楃闆嗭紝榛樿UTF-8
+ * @return 杞崲鍚庣殑瀛楃闆�
+ */
+ public static String convert(String source, Charset srcCharset, Charset destCharset)
+ {
+ if (null == srcCharset)
+ {
+ srcCharset = StandardCharsets.ISO_8859_1;
+ }
+
+ if (null == destCharset)
+ {
+ srcCharset = StandardCharsets.UTF_8;
+ }
+
+ if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
+ {
+ return source;
+ }
+ return new String(source.getBytes(srcCharset), destCharset);
+ }
+
+ /**
+ * @return 绯荤粺瀛楃闆嗙紪鐮�
+ */
+ public static String systemCharset()
+ {
+ return Charset.defaultCharset().name();
+ }
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java b/ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java
new file mode 100644
index 0000000..a9e2f21
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java
@@ -0,0 +1,999 @@
+package com.ruoyi.common.utils.text;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.text.NumberFormat;
+import java.util.Set;
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * 绫诲瀷杞崲鍣�
+ *
+ * @author ruoyi
+ */
+public class Convert
+{
+ /**
+ * 杞崲涓哄瓧绗︿覆<br>
+ * 濡傛灉缁欏畾鐨勫�间负null锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static String toStr(Object value, String defaultValue)
+ {
+ if (null == value)
+ {
+ return defaultValue;
+ }
+ if (value instanceof String)
+ {
+ return (String) value;
+ }
+ return value.toString();
+ }
+
+ /**
+ * 杞崲涓哄瓧绗︿覆<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String toStr(Object value)
+ {
+ return toStr(value, null);
+ }
+
+ /**
+ * 杞崲涓哄瓧绗�<br>
+ * 濡傛灉缁欏畾鐨勫�间负null锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Character toChar(Object value, Character defaultValue)
+ {
+ if (null == value)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Character)
+ {
+ return (Character) value;
+ }
+
+ final String valueStr = toStr(value, null);
+ return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
+ }
+
+ /**
+ * 杞崲涓哄瓧绗�<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Character toChar(Object value)
+ {
+ return toChar(value, null);
+ }
+
+ /**
+ * 杞崲涓篵yte<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Byte toByte(Object value, Byte defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Byte)
+ {
+ return (Byte) value;
+ }
+ if (value instanceof Number)
+ {
+ return ((Number) value).byteValue();
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return Byte.parseByte(valueStr);
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篵yte<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Byte toByte(Object value)
+ {
+ return toByte(value, null);
+ }
+
+ /**
+ * 杞崲涓篠hort<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Short toShort(Object value, Short defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Short)
+ {
+ return (Short) value;
+ }
+ if (value instanceof Number)
+ {
+ return ((Number) value).shortValue();
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return Short.parseShort(valueStr.trim());
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篠hort<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Short toShort(Object value)
+ {
+ return toShort(value, null);
+ }
+
+ /**
+ * 杞崲涓篘umber<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Number toNumber(Object value, Number defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Number)
+ {
+ return (Number) value;
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return NumberFormat.getInstance().parse(valueStr);
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篘umber<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Number toNumber(Object value)
+ {
+ return toNumber(value, null);
+ }
+
+ /**
+ * 杞崲涓篿nt<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Integer toInt(Object value, Integer defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Integer)
+ {
+ return (Integer) value;
+ }
+ if (value instanceof Number)
+ {
+ return ((Number) value).intValue();
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return Integer.parseInt(valueStr.trim());
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篿nt<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer toInt(Object value)
+ {
+ return toInt(value, null);
+ }
+
+ /**
+ * 杞崲涓篒nteger鏁扮粍<br>
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer[] toIntArray(String str)
+ {
+ return toIntArray(",", str);
+ }
+
+ /**
+ * 杞崲涓篖ong鏁扮粍<br>
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long[] toLongArray(String str)
+ {
+ return toLongArray(",", str);
+ }
+
+ /**
+ * 杞崲涓篒nteger鏁扮粍<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param split 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Integer[] toIntArray(String split, String str)
+ {
+ if (StringUtils.isEmpty(str))
+ {
+ return new Integer[] {};
+ }
+ String[] arr = str.split(split);
+ final Integer[] ints = new Integer[arr.length];
+ for (int i = 0; i < arr.length; i++)
+ {
+ final Integer v = toInt(arr[i], 0);
+ ints[i] = v;
+ }
+ return ints;
+ }
+
+ /**
+ * 杞崲涓篖ong鏁扮粍<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long[] toLongArray(String split, String str)
+ {
+ if (StringUtils.isEmpty(str))
+ {
+ return new Long[] {};
+ }
+ String[] arr = str.split(split);
+ final Long[] longs = new Long[arr.length];
+ for (int i = 0; i < arr.length; i++)
+ {
+ final Long v = toLong(arr[i], null);
+ longs[i] = v;
+ }
+ return longs;
+ }
+
+ /**
+ * 杞崲涓篠tring鏁扮粍<br>
+ *
+ * @param str 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String[] toStrArray(String str)
+ {
+ return toStrArray(",", str);
+ }
+
+ /**
+ * 杞崲涓篠tring鏁扮粍<br>
+ *
+ * @param split 鍒嗛殧绗�
+ * @param split 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static String[] toStrArray(String split, String str)
+ {
+ return str.split(split);
+ }
+
+ /**
+ * 杞崲涓簂ong<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Long toLong(Object value, Long defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Long)
+ {
+ return (Long) value;
+ }
+ if (value instanceof Number)
+ {
+ return ((Number) value).longValue();
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ // 鏀寔绉戝璁℃暟娉�
+ return new BigDecimal(valueStr.trim()).longValue();
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓簂ong<br>
+ * 濡傛灉缁欏畾鐨勫�间负<code>null</code>锛屾垨鑰呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Long toLong(Object value)
+ {
+ return toLong(value, null);
+ }
+
+ /**
+ * 杞崲涓篸ouble<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Double toDouble(Object value, Double defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Double)
+ {
+ return (Double) value;
+ }
+ if (value instanceof Number)
+ {
+ return ((Number) value).doubleValue();
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ // 鏀寔绉戝璁℃暟娉�
+ return new BigDecimal(valueStr.trim()).doubleValue();
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篸ouble<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Double toDouble(Object value)
+ {
+ return toDouble(value, null);
+ }
+
+ /**
+ * 杞崲涓篎loat<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Float toFloat(Object value, Float defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Float)
+ {
+ return (Float) value;
+ }
+ if (value instanceof Number)
+ {
+ return ((Number) value).floatValue();
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return Float.parseFloat(valueStr.trim());
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篎loat<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Float toFloat(Object value)
+ {
+ return toFloat(value, null);
+ }
+
+ /**
+ * 杞崲涓篵oolean<br>
+ * String鏀寔鐨勫�间负锛歵rue銆乫alse銆亂es銆乷k銆乶o锛�1,0 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static Boolean toBool(Object value, Boolean defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof Boolean)
+ {
+ return (Boolean) value;
+ }
+ String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ valueStr = valueStr.trim().toLowerCase();
+ switch (valueStr)
+ {
+ case "true":
+ return true;
+ case "false":
+ return false;
+ case "yes":
+ return true;
+ case "ok":
+ return true;
+ case "no":
+ return false;
+ case "1":
+ return true;
+ case "0":
+ return false;
+ default:
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篵oolean<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static Boolean toBool(Object value)
+ {
+ return toBool(value, null);
+ }
+
+ /**
+ * 杞崲涓篍num瀵硅薄<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ *
+ * @param clazz Enum鐨凜lass
+ * @param value 鍊�
+ * @param defaultValue 榛樿鍊�
+ * @return Enum
+ */
+ public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (clazz.isAssignableFrom(value.getClass()))
+ {
+ @SuppressWarnings("unchecked")
+ E myE = (E) value;
+ return myE;
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return Enum.valueOf(clazz, valueStr);
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓篍num瀵硅薄<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ *
+ * @param clazz Enum鐨凜lass
+ * @param value 鍊�
+ * @return Enum
+ */
+ public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value)
+ {
+ return toEnum(clazz, value, null);
+ }
+
+ /**
+ * 杞崲涓築igInteger<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static BigInteger toBigInteger(Object value, BigInteger defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof BigInteger)
+ {
+ return (BigInteger) value;
+ }
+ if (value instanceof Long)
+ {
+ return BigInteger.valueOf((Long) value);
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return new BigInteger(valueStr);
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓築igInteger<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<code>null</code><br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static BigInteger toBigInteger(Object value)
+ {
+ return toBigInteger(value, null);
+ }
+
+ /**
+ * 杞崲涓築igDecimal<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @param defaultValue 杞崲閿欒鏃剁殑榛樿鍊�
+ * @return 缁撴灉
+ */
+ public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ if (value instanceof BigDecimal)
+ {
+ return (BigDecimal) value;
+ }
+ if (value instanceof Long)
+ {
+ return new BigDecimal((Long) value);
+ }
+ if (value instanceof Double)
+ {
+ return new BigDecimal((Double) value);
+ }
+ if (value instanceof Integer)
+ {
+ return new BigDecimal((Integer) value);
+ }
+ final String valueStr = toStr(value, null);
+ if (StringUtils.isEmpty(valueStr))
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return new BigDecimal(valueStr);
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * 杞崲涓築igDecimal<br>
+ * 濡傛灉缁欏畾鐨勫�间负绌猴紝鎴栬�呰浆鎹㈠け璐ワ紝杩斿洖榛樿鍊�<br>
+ * 杞崲澶辫触涓嶄細鎶ラ敊
+ *
+ * @param value 琚浆鎹㈢殑鍊�
+ * @return 缁撴灉
+ */
+ public static BigDecimal toBigDecimal(Object value)
+ {
+ return toBigDecimal(value, null);
+ }
+
+ /**
+ * 灏嗗璞¤浆涓哄瓧绗︿覆<br>
+ * 1銆丅yte鏁扮粍鍜孊yteBuffer浼氳杞崲涓哄搴斿瓧绗︿覆鐨勬暟缁� 2銆佸璞℃暟缁勪細璋冪敤Arrays.toString鏂规硶
+ *
+ * @param obj 瀵硅薄
+ * @return 瀛楃涓�
+ */
+ public static String utf8Str(Object obj)
+ {
+ return str(obj, CharsetKit.CHARSET_UTF_8);
+ }
+
+ /**
+ * 灏嗗璞¤浆涓哄瓧绗︿覆<br>
+ * 1銆丅yte鏁扮粍鍜孊yteBuffer浼氳杞崲涓哄搴斿瓧绗︿覆鐨勬暟缁� 2銆佸璞℃暟缁勪細璋冪敤Arrays.toString鏂规硶
+ *
+ * @param obj 瀵硅薄
+ * @param charsetName 瀛楃闆�
+ * @return 瀛楃涓�
+ */
+ public static String str(Object obj, String charsetName)
+ {
+ return str(obj, Charset.forName(charsetName));
+ }
+
+ /**
+ * 灏嗗璞¤浆涓哄瓧绗︿覆<br>
+ * 1銆丅yte鏁扮粍鍜孊yteBuffer浼氳杞崲涓哄搴斿瓧绗︿覆鐨勬暟缁� 2銆佸璞℃暟缁勪細璋冪敤Arrays.toString鏂规硶
+ *
+ * @param obj 瀵硅薄
+ * @param charset 瀛楃闆�
+ * @return 瀛楃涓�
+ */
+ public static String str(Object obj, Charset charset)
+ {
+ if (null == obj)
+ {
+ return null;
+ }
+
+ if (obj instanceof String)
+ {
+ return (String) obj;
+ }
+ else if (obj instanceof byte[] || obj instanceof Byte[])
+ {
+ return str((Byte[]) obj, charset);
+ }
+ else if (obj instanceof ByteBuffer)
+ {
+ return str((ByteBuffer) obj, charset);
+ }
+ return obj.toString();
+ }
+
+ /**
+ * 灏哹yte鏁扮粍杞负瀛楃涓�
+ *
+ * @param bytes byte鏁扮粍
+ * @param charset 瀛楃闆�
+ * @return 瀛楃涓�
+ */
+ public static String str(byte[] bytes, String charset)
+ {
+ return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
+ }
+
+ /**
+ * 瑙g爜瀛楄妭鐮�
+ *
+ * @param data 瀛楃涓�
+ * @param charset 瀛楃闆嗭紝濡傛灉姝ゅ瓧娈典负绌猴紝鍒欒В鐮佺殑缁撴灉鍙栧喅浜庡钩鍙�
+ * @return 瑙g爜鍚庣殑瀛楃涓�
+ */
+ public static String str(byte[] data, Charset charset)
+ {
+ if (data == null)
+ {
+ return null;
+ }
+
+ if (null == charset)
+ {
+ return new String(data);
+ }
+ return new String(data, charset);
+ }
+
+ /**
+ * 灏嗙紪鐮佺殑byteBuffer鏁版嵁杞崲涓哄瓧绗︿覆
+ *
+ * @param data 鏁版嵁
+ * @param charset 瀛楃闆嗭紝濡傛灉涓虹┖浣跨敤褰撳墠绯荤粺瀛楃闆�
+ * @return 瀛楃涓�
+ */
+ public static String str(ByteBuffer data, String charset)
+ {
+ if (data == null)
+ {
+ return null;
+ }
+
+ return str(data, Charset.forName(charset));
+ }
+
+ /**
+ * 灏嗙紪鐮佺殑byteBuffer鏁版嵁杞崲涓哄瓧绗︿覆
+ *
+ * @param data 鏁版嵁
+ * @param charset 瀛楃闆嗭紝濡傛灉涓虹┖浣跨敤褰撳墠绯荤粺瀛楃闆�
+ * @return 瀛楃涓�
+ */
+ public static String str(ByteBuffer data, Charset charset)
+ {
+ if (null == charset)
+ {
+ charset = Charset.defaultCharset();
+ }
+ return charset.decode(data).toString();
+ }
+
+ // ----------------------------------------------------------------------- 鍏ㄨ鍗婅杞崲
+ /**
+ * 鍗婅杞叏瑙�
+ *
+ * @param input String.
+ * @return 鍏ㄨ瀛楃涓�.
+ */
+ public static String toSBC(String input)
+ {
+ return toSBC(input, null);
+ }
+
+ /**
+ * 鍗婅杞叏瑙�
+ *
+ * @param input String
+ * @param notConvertSet 涓嶆浛鎹㈢殑瀛楃闆嗗悎
+ * @return 鍏ㄨ瀛楃涓�.
+ */
+ public static String toSBC(String input, Set<Character> notConvertSet)
+ {
+ char c[] = input.toCharArray();
+ for (int i = 0; i < c.length; i++)
+ {
+ if (null != notConvertSet && notConvertSet.contains(c[i]))
+ {
+ // 璺宠繃涓嶆浛鎹㈢殑瀛楃
+ continue;
+ }
+
+ if (c[i] == ' ')
+ {
+ c[i] = '\u3000';
+ }
+ else if (c[i] < '\177')
+ {
+ c[i] = (char) (c[i] + 65248);
+
+ }
+ }
+ return new String(c);
+ }
+
+ /**
+ * 鍏ㄨ杞崐瑙�
+ *
+ * @param input String.
+ * @return 鍗婅瀛楃涓�
+ */
+ public static String toDBC(String input)
+ {
+ return toDBC(input, null);
+ }
+
+ /**
+ * 鏇挎崲鍏ㄨ涓哄崐瑙�
+ *
+ * @param text 鏂囨湰
+ * @param notConvertSet 涓嶆浛鎹㈢殑瀛楃闆嗗悎
+ * @return 鏇挎崲鍚庣殑瀛楃
+ */
+ public static String toDBC(String text, Set<Character> notConvertSet)
+ {
+ char c[] = text.toCharArray();
+ for (int i = 0; i < c.length; i++)
+ {
+ if (null != notConvertSet && notConvertSet.contains(c[i]))
+ {
+ // 璺宠繃涓嶆浛鎹㈢殑瀛楃
+ continue;
+ }
+
+ if (c[i] == '\u3000')
+ {
+ c[i] = ' ';
+ }
+ else if (c[i] > '\uFF00' && c[i] < '\uFF5F')
+ {
+ c[i] = (char) (c[i] - 65248);
+ }
+ }
+ String returnString = new String(c);
+
+ return returnString;
+ }
+
+ /**
+ * 鏁板瓧閲戦澶у啓杞崲 鍏堝啓涓畬鏁寸殑鐒跺悗灏嗗闆舵嬀鏇挎崲鎴愰浂
+ *
+ * @param n 鏁板瓧
+ * @return 涓枃澶у啓鏁板瓧
+ */
+ public static String digitUppercase(double n)
+ {
+ String[] fraction = { "瑙�", "鍒�" };
+ String[] digit = { "闆�", "澹�", "璐�", "鍙�", "鑲�", "浼�", "闄�", "鏌�", "鎹�", "鐜�" };
+ String[][] unit = { { "鍏�", "涓�", "浜�" }, { "", "鎷�", "浣�", "浠�" } };
+
+ String head = n < 0 ? "璐�" : "";
+ n = Math.abs(n);
+
+ String s = "";
+ for (int i = 0; i < fraction.length; i++)
+ {
+ s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(闆�.)+", "");
+ }
+ if (s.length() < 1)
+ {
+ s = "鏁�";
+ }
+ int integerPart = (int) Math.floor(n);
+
+ for (int i = 0; i < unit[0].length && integerPart > 0; i++)
+ {
+ String p = "";
+ for (int j = 0; j < unit[1].length && n > 0; j++)
+ {
+ p = digit[integerPart % 10] + unit[1][j] + p;
+ integerPart = integerPart / 10;
+ }
+ s = p.replaceAll("(闆�.)*闆�$", "").replaceAll("^$", "闆�") + unit[0][i] + s;
+ }
+ return head + s.replaceAll("(闆�.)*闆跺厓", "鍏�").replaceFirst("(闆�.)+", "").replaceAll("(闆�.)+", "闆�").replaceAll("^鏁�$", "闆跺厓鏁�");
+ }
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java b/ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java
new file mode 100644
index 0000000..d376bc5
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java
@@ -0,0 +1,93 @@
+package com.ruoyi.common.utils.text;
+
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * 瀛楃涓叉牸寮忓寲
+ *
+ * @author ruoyi
+ */
+public class StrFormatter
+{
+ public static final String EMPTY_JSON = "{}";
+ public static final char C_BACKSLASH = '\\';
+ public static final char C_DELIM_START = '{';
+ public static final char C_DELIM_END = '}';
+
+ /**
+ * 鏍煎紡鍖栧瓧绗︿覆<br>
+ * 姝ゆ柟娉曞彧鏄畝鍗曞皢鍗犱綅绗� {} 鎸夌収椤哄簭鏇挎崲涓哄弬鏁�<br>
+ * 濡傛灉鎯宠緭鍑� {} 浣跨敤 \\杞箟 { 鍗冲彲锛屽鏋滄兂杈撳嚭 {} 涔嬪墠鐨� \ 浣跨敤鍙岃浆涔夌 \\\\ 鍗冲彲<br>
+ * 渚嬶細<br>
+ * 閫氬父浣跨敤锛歠ormat("this is {} for {}", "a", "b") -> this is a for b<br>
+ * 杞箟{}锛� format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
+ * 杞箟\锛� format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
+ *
+ * @param strPattern 瀛楃涓叉ā鏉�
+ * @param argArray 鍙傛暟鍒楄〃
+ * @return 缁撴灉
+ */
+ public static String format(final String strPattern, final Object... argArray)
+ {
+ if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
+ {
+ return strPattern;
+ }
+ final int strPatternLength = strPattern.length();
+
+ // 鍒濆鍖栧畾涔夊ソ鐨勯暱搴︿互鑾峰緱鏇村ソ鐨勬�ц兘
+ StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
+
+ int handledPosition = 0;
+ int delimIndex;// 鍗犱綅绗︽墍鍦ㄤ綅缃�
+ for (int argIndex = 0; argIndex < argArray.length; argIndex++)
+ {
+ delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
+ if (delimIndex == -1)
+ {
+ if (handledPosition == 0)
+ {
+ return strPattern;
+ }
+ else
+ { // 瀛楃涓叉ā鏉垮墿浣欓儴鍒嗕笉鍐嶅寘鍚崰浣嶇锛屽姞鍏ュ墿浣欓儴鍒嗗悗杩斿洖缁撴灉
+ sbuf.append(strPattern, handledPosition, strPatternLength);
+ return sbuf.toString();
+ }
+ }
+ else
+ {
+ if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
+ {
+ if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
+ {
+ // 杞箟绗︿箣鍓嶈繕鏈変竴涓浆涔夌锛屽崰浣嶇渚濇棫鏈夋晥
+ sbuf.append(strPattern, handledPosition, delimIndex - 1);
+ sbuf.append(Convert.utf8Str(argArray[argIndex]));
+ handledPosition = delimIndex + 2;
+ }
+ else
+ {
+ // 鍗犱綅绗﹁杞箟
+ argIndex--;
+ sbuf.append(strPattern, handledPosition, delimIndex - 1);
+ sbuf.append(C_DELIM_START);
+ handledPosition = delimIndex + 1;
+ }
+ }
+ else
+ {
+ // 姝e父鍗犱綅绗�
+ sbuf.append(strPattern, handledPosition, delimIndex);
+ sbuf.append(Convert.utf8Str(argArray[argIndex]));
+ handledPosition = delimIndex + 2;
+ }
+ }
+ }
+ // append the characters following the last {} pair.
+ // 鍔犲叆鏈�鍚庝竴涓崰浣嶇鍚庢墍鏈夌殑瀛楃
+ sbuf.append(strPattern, handledPosition, strPattern.length());
+
+ return sbuf.toString();
+ }
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java b/ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java
new file mode 100644
index 0000000..a74e2c3
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java
@@ -0,0 +1,66 @@
+package com.ruoyi.framework.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 璇诲彇浠g爜鐢熸垚鐩稿叧閰嶇疆
+ *
+ * @author ruoyi
+ */
+@Component
+@ConfigurationProperties(prefix = "gen")
+public class GenConfig
+{
+ /** 浣滆�� */
+ public static String author;
+
+ /** 鐢熸垚鍖呰矾寰� */
+ public static String packageName;
+
+ /** 鑷姩鍘婚櫎琛ㄥ墠缂�锛岄粯璁ゆ槸true */
+ public static boolean autoRemovePre;
+
+ /** 琛ㄥ墠缂�(绫诲悕涓嶄細鍖呭惈琛ㄥ墠缂�) */
+ public static String tablePrefix;
+
+ public static String getAuthor()
+ {
+ return author;
+ }
+
+ public void setAuthor(String author)
+ {
+ GenConfig.author = author;
+ }
+
+ public static String getPackageName()
+ {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName)
+ {
+ GenConfig.packageName = packageName;
+ }
+
+ public static boolean getAutoRemovePre()
+ {
+ return autoRemovePre;
+ }
+
+ public void setAutoRemovePre(boolean autoRemovePre)
+ {
+ GenConfig.autoRemovePre = autoRemovePre;
+ }
+
+ public static String getTablePrefix()
+ {
+ return tablePrefix;
+ }
+
+ public void setTablePrefix(String tablePrefix)
+ {
+ GenConfig.tablePrefix = tablePrefix;
+ }
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java b/ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java
index 7548bc9..6ed760c 100644
--- a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java
+++ b/ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java
@@ -4,7 +4,6 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -40,9 +39,16 @@
/** 鏁版嵁鏉冮檺 */
private String dataScope;
- /** 璇锋眰鍙傛暟 */
+ /** 寮�濮嬫椂闂� */
@JsonIgnore
- private String params;
+ private String beginTime;
+
+ /** 缁撴潫鏃堕棿 */
+ @JsonIgnore
+ private String endTime;
+
+ /** 璇锋眰鍙傛暟 */
+ private Map<String, Object> params;
public String getSearchValue()
{
@@ -114,17 +120,36 @@
this.dataScope = dataScope;
}
- @SuppressWarnings("unchecked")
+ public String getBeginTime()
+ {
+ return beginTime;
+ }
+
+ public void setBeginTime(String beginTime)
+ {
+ this.beginTime = beginTime;
+ }
+
+ public String getEndTime()
+ {
+ return endTime;
+ }
+
+ public void setEndTime(String endTime)
+ {
+ this.endTime = endTime;
+ }
+
public Map<String, Object> getParams()
{
if (params == null)
{
- return new HashMap<>();
+ params = new HashMap<>();
}
- return JSON.parseObject(params, Map.class);
+ return params;
}
- public void setParams(String params)
+ public void setParams(Map<String, Object> params)
{
this.params = params;
}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java
index df175e3..1d59084 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java
@@ -70,7 +70,6 @@
/**
* 鏍规嵁鍙傛暟閿悕鏌ヨ鍙傛暟鍊�
*/
- @PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult getConfigKey(@PathVariable String configKey)
{
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
index 4934dcb..e344a39 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
@@ -57,7 +57,6 @@
/**
* 鑾峰彇閮ㄩ棬涓嬫媺鏍戝垪琛�
*/
- @PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping("/treeselect")
public AjaxResult treeselect(SysDept dept)
{
@@ -68,7 +67,6 @@
/**
* 鍔犺浇瀵瑰簲瑙掕壊閮ㄩ棬鍒楄〃鏍�
*/
- @PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
{
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java
index 8c5f1ea..60becb1 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java
@@ -66,7 +66,6 @@
/**
* 鏍规嵁瀛楀吀绫诲瀷鏌ヨ瀛楀吀鏁版嵁淇℃伅
*/
- @PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/dictType/{dictType}")
public AjaxResult dictType(@PathVariable String dictType)
{
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java
index f1dabc9..4236206 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java
@@ -106,4 +106,14 @@
{
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
}
+
+ /**
+ * 鑾峰彇瀛楀吀閫夋嫨妗嗗垪琛�
+ */
+ @GetMapping("/optionselect")
+ public AjaxResult optionselect()
+ {
+ List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
+ return AjaxResult.success(dictTypes);
+ }
}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java
index 173c0fa..47634f5 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java
@@ -57,7 +57,6 @@
/**
* 鑾峰彇鑿滃崟涓嬫媺鏍戝垪琛�
*/
- @PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu dept)
{
@@ -68,7 +67,6 @@
/**
* 鍔犺浇瀵瑰簲瑙掕壊鑿滃崟鍒楄〃鏍�
*/
- @PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java
index d7449a5..58410b6 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java
@@ -14,6 +14,7 @@
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
@@ -69,12 +70,18 @@
* 鏍规嵁鐢ㄦ埛缂栧彿鑾峰彇璇︾粏淇℃伅
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
- @GetMapping(value = "/{userId}")
- public AjaxResult getInfo(@PathVariable Long userId)
+ @GetMapping(value = { "/", "/{userId}" })
+ public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{
- AjaxResult ajax = AjaxResult.success(userService.selectUserById(userId));
- ajax.put("postIds", postService.selectPostListByUserId(userId));
- ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
+ AjaxResult ajax = AjaxResult.success();
+ ajax.put("roles", roleService.selectRoleAll());
+ ajax.put("posts", postService.selectPostAll());
+ if (StringUtils.isNotNull(userId))
+ {
+ ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
+ ajax.put("postIds", postService.selectPostListByUserId(userId));
+ ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
+ }
return ajax;
}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java
index 735faab..2b19546 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java
@@ -116,11 +116,10 @@
for (SysMenu menu : menus)
{
RouterVo router = new RouterVo();
- router.setName(menu.getMenuName());
+ router.setName(StringUtils.capitalize(menu.getPath()));
router.setPath(getRouterPath(menu));
router.setComponent(StringUtils.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent());
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
- router.setName(menu.getMenuName());
List<SysMenu> cMenus = menu.getChildren();
if (!cMenus.isEmpty() && cMenus.size() > 0 && "M".equals(menu.getMenuType()))
{
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java
new file mode 100644
index 0000000..515842b
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java
@@ -0,0 +1,185 @@
+package com.ruoyi.project.tool.gen.controller;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.utils.text.Convert;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.framework.web.page.TableDataInfo;
+import com.ruoyi.project.tool.gen.domain.GenTable;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+import com.ruoyi.project.tool.gen.service.IGenTableColumnService;
+import com.ruoyi.project.tool.gen.service.IGenTableService;
+
+/**
+ * 浠g爜鐢熸垚 鎿嶄綔澶勭悊
+ *
+ * @author ruoyi
+ */
+@RestController
+@RequestMapping("/tool/gen")
+public class GenController extends BaseController
+{
+
+ @Autowired
+ private IGenTableService genTableService;
+
+ @Autowired
+ private IGenTableColumnService genTableColumnService;
+
+ /**
+ * 鏌ヨ浠g爜鐢熸垚鍒楄〃
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+ @GetMapping("/list")
+ public TableDataInfo genList(GenTable genTable)
+ {
+ startPage();
+ List<GenTable> list = genTableService.selectGenTableList(genTable);
+ return getDataTable(list);
+ }
+
+ /**
+ * 淇敼浠g爜鐢熸垚涓氬姟
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:query')")
+ @GetMapping(value = "/{talbleId}")
+ public AjaxResult getInfo(@PathVariable Long talbleId)
+ {
+ GenTable table = genTableService.selectGenTableById(talbleId);
+ List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("info", table);
+ map.put("rows", list);
+ return AjaxResult.success(map);
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁搴撳垪琛�
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+ @GetMapping("/db/list")
+ public TableDataInfo dataList(GenTable genTable)
+ {
+ startPage();
+ List<GenTable> list = genTableService.selectDbTableList(genTable);
+ return getDataTable(list);
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁琛ㄥ瓧娈靛垪琛�
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+ @GetMapping(value = "/column/{talbleId}")
+ public TableDataInfo columnList(Long tableId)
+ {
+ TableDataInfo dataInfo = new TableDataInfo();
+ List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
+ dataInfo.setRows(list);
+ dataInfo.setTotal(list.size());
+ return dataInfo;
+ }
+
+ /**
+ * 瀵煎叆琛ㄧ粨鏋勶紙淇濆瓨锛�
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+ @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.IMPORT)
+ @PostMapping("/importTable")
+ public AjaxResult importTableSave(String tables)
+ {
+ String[] tableNames = Convert.toStrArray(tables);
+ // 鏌ヨ琛ㄤ俊鎭�
+ List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
+ genTableService.importGenTable(tableList);
+ return AjaxResult.success();
+ }
+
+ /**
+ * 淇敼淇濆瓨浠g爜鐢熸垚涓氬姟
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
+ @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
+ {
+ System.out.println(genTable.getParams().size());
+ genTableService.validateEdit(genTable);
+ genTableService.updateGenTable(genTable);
+ return AjaxResult.success();
+ }
+
+ @PreAuthorize("@ss.hasPermi('tool:gen:remove')")
+ @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{tableIds}")
+ public AjaxResult remove(@PathVariable Long[] tableIds)
+ {
+ genTableService.deleteGenTableByIds(tableIds);
+ return AjaxResult.success();
+ }
+
+ /**
+ * 棰勮浠g爜
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:preview')")
+ @GetMapping("/preview/{tableId}")
+ public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
+ {
+ Map<String, String> dataMap = genTableService.previewCode(tableId);
+ return AjaxResult.success(dataMap);
+ }
+
+ /**
+ * 鐢熸垚浠g爜
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:code')")
+ @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
+ @GetMapping("/genCode/{tableName}")
+ public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
+ {
+ byte[] data = genTableService.generatorCode(tableName);
+ genCode(response, data);
+ }
+
+ /**
+ * 鎵归噺鐢熸垚浠g爜
+ */
+ @PreAuthorize("@ss.hasPermi('tool:gen:code')")
+ @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
+ @GetMapping("/batchGenCode")
+ public void batchGenCode(HttpServletResponse response, String tables) throws IOException
+ {
+ String[] tableNames = Convert.toStrArray(tables);
+ byte[] data = genTableService.generatorCode(tableNames);
+ genCode(response, data);
+ }
+
+ /**
+ * 鐢熸垚zip鏂囦欢
+ */
+ private void genCode(HttpServletResponse response, byte[] data) throws IOException
+ {
+ response.reset();
+ response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
+ response.addHeader("Content-Length", "" + data.length);
+ response.setContentType("application/octet-stream; charset=UTF-8");
+ IOUtils.write(data, response.getOutputStream());
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java
new file mode 100644
index 0000000..d608c82
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java
@@ -0,0 +1,269 @@
+package com.ruoyi.project.tool.gen.domain;
+
+import java.util.List;
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import com.ruoyi.common.constant.GenConstants;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.web.domain.BaseEntity;
+
+/**
+ * 涓氬姟琛� gen_table
+ *
+ * @author ruoyi
+ */
+public class GenTable extends BaseEntity
+{
+ private static final long serialVersionUID = 1L;
+
+ /** 缂栧彿 */
+ private Long tableId;
+
+ /** 琛ㄥ悕绉� */
+ @NotBlank(message = "琛ㄥ悕绉颁笉鑳戒负绌�")
+ private String tableName;
+
+ /** 琛ㄦ弿杩� */
+ @NotBlank(message = "琛ㄦ弿杩颁笉鑳戒负绌�")
+ private String tableComment;
+
+ /** 瀹炰綋绫诲悕绉�(棣栧瓧姣嶅ぇ鍐�) */
+ @NotBlank(message = "瀹炰綋绫诲悕绉颁笉鑳戒负绌�")
+ private String className;
+
+ /** 浣跨敤鐨勬ā鏉匡紙crud鍗曡〃鎿嶄綔 tree鏍戣〃鎿嶄綔锛� */
+ private String tplCategory;
+
+ /** 鐢熸垚鍖呰矾寰� */
+ @NotBlank(message = "鐢熸垚鍖呰矾寰勪笉鑳戒负绌�")
+ private String packageName;
+
+ /** 鐢熸垚妯″潡鍚� */
+ @NotBlank(message = "鐢熸垚妯″潡鍚嶄笉鑳戒负绌�")
+ private String moduleName;
+
+ /** 鐢熸垚涓氬姟鍚� */
+ @NotBlank(message = "鐢熸垚涓氬姟鍚嶄笉鑳戒负绌�")
+ private String businessName;
+
+ /** 鐢熸垚鍔熻兘鍚� */
+ @NotBlank(message = "鐢熸垚鍔熻兘鍚嶄笉鑳戒负绌�")
+ private String functionName;
+
+ /** 鐢熸垚浣滆�� */
+ @NotBlank(message = "浣滆�呬笉鑳戒负绌�")
+ private String functionAuthor;
+
+ /** 涓婚敭淇℃伅 */
+ private GenTableColumn pkColumn;
+
+ /** 琛ㄥ垪淇℃伅 */
+ @Valid
+ private List<GenTableColumn> columns;
+
+ /** 鍏跺畠鐢熸垚閫夐」 */
+ private String options;
+
+ /** 鏍戠紪鐮佸瓧娈� */
+ private String treeCode;
+
+ /** 鏍戠埗缂栫爜瀛楁 */
+ private String treeParentCode;
+
+ /** 鏍戝悕绉板瓧娈� */
+ private String treeName;
+
+ public Long getTableId()
+ {
+ return tableId;
+ }
+
+ public void setTableId(Long tableId)
+ {
+ this.tableId = tableId;
+ }
+
+ public String getTableName()
+ {
+ return tableName;
+ }
+
+ public void setTableName(String tableName)
+ {
+ this.tableName = tableName;
+ }
+
+ public String getTableComment()
+ {
+ return tableComment;
+ }
+
+ public void setTableComment(String tableComment)
+ {
+ this.tableComment = tableComment;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ public String getTplCategory()
+ {
+ return tplCategory;
+ }
+
+ public void setTplCategory(String tplCategory)
+ {
+ this.tplCategory = tplCategory;
+ }
+
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName)
+ {
+ this.packageName = packageName;
+ }
+
+ public String getModuleName()
+ {
+ return moduleName;
+ }
+
+ public void setModuleName(String moduleName)
+ {
+ this.moduleName = moduleName;
+ }
+
+ public String getBusinessName()
+ {
+ return businessName;
+ }
+
+ public void setBusinessName(String businessName)
+ {
+ this.businessName = businessName;
+ }
+
+ public String getFunctionName()
+ {
+ return functionName;
+ }
+
+ public void setFunctionName(String functionName)
+ {
+ this.functionName = functionName;
+ }
+
+ public String getFunctionAuthor()
+ {
+ return functionAuthor;
+ }
+
+ public void setFunctionAuthor(String functionAuthor)
+ {
+ this.functionAuthor = functionAuthor;
+ }
+
+ public GenTableColumn getPkColumn()
+ {
+ return pkColumn;
+ }
+
+ public void setPkColumn(GenTableColumn pkColumn)
+ {
+ this.pkColumn = pkColumn;
+ }
+
+ public List<GenTableColumn> getColumns()
+ {
+ return columns;
+ }
+
+ public void setColumns(List<GenTableColumn> columns)
+ {
+ this.columns = columns;
+ }
+
+ public String getOptions()
+ {
+ return options;
+ }
+
+ public void setOptions(String options)
+ {
+ this.options = options;
+ }
+
+ public String getTreeCode()
+ {
+ return treeCode;
+ }
+
+ public void setTreeCode(String treeCode)
+ {
+ this.treeCode = treeCode;
+ }
+
+ public String getTreeParentCode()
+ {
+ return treeParentCode;
+ }
+
+ public void setTreeParentCode(String treeParentCode)
+ {
+ this.treeParentCode = treeParentCode;
+ }
+
+ public String getTreeName()
+ {
+ return treeName;
+ }
+
+ public void setTreeName(String treeName)
+ {
+ this.treeName = treeName;
+ }
+
+ public boolean isTree()
+ {
+ return isTree(this.tplCategory);
+ }
+
+ public static boolean isTree(String tplCategory)
+ {
+ return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
+ }
+
+ public boolean isCrud()
+ {
+ return isCrud(this.tplCategory);
+ }
+
+ public static boolean isCrud(String tplCategory)
+ {
+ return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
+ }
+
+ public boolean isSuperColumn(String javaField)
+ {
+ return isSuperColumn(this.tplCategory, javaField);
+ }
+
+ public static boolean isSuperColumn(String tplCategory, String javaField)
+ {
+ if (isTree(tplCategory))
+ {
+ StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.TREE_ENTITY);
+ }
+ return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java
new file mode 100644
index 0000000..303575f
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java
@@ -0,0 +1,368 @@
+package com.ruoyi.project.tool.gen.domain;
+
+import javax.validation.constraints.NotBlank;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.web.domain.BaseEntity;
+
+/**
+ * 浠g爜鐢熸垚涓氬姟瀛楁琛� gen_table_column
+ *
+ * @author ruoyi
+ */
+public class GenTableColumn extends BaseEntity
+{
+ private static final long serialVersionUID = 1L;
+
+ /** 缂栧彿 */
+ private Long columnId;
+
+ /** 褰掑睘琛ㄧ紪鍙� */
+ private Long tableId;
+
+ /** 鍒楀悕绉� */
+ private String columnName;
+
+ /** 鍒楁弿杩� */
+ private String columnComment;
+
+ /** 鍒楃被鍨� */
+ private String columnType;
+
+ /** JAVA绫诲瀷 */
+ private String javaType;
+
+ /** JAVA瀛楁鍚� */
+ @NotBlank(message = "Java灞炴�т笉鑳戒负绌�")
+ private String javaField;
+
+ /** 鏄惁涓婚敭锛�1鏄級 */
+ private String isPk;
+
+ /** 鏄惁鑷锛�1鏄級 */
+ private String isIncrement;
+
+ /** 鏄惁蹇呭~锛�1鏄級 */
+ private String isRequired;
+
+ /** 鏄惁涓烘彃鍏ュ瓧娈碉紙1鏄級 */
+ private String isInsert;
+
+ /** 鏄惁缂栬緫瀛楁锛�1鏄級 */
+ private String isEdit;
+
+ /** 鏄惁鍒楄〃瀛楁锛�1鏄級 */
+ private String isList;
+
+ /** 鏄惁鏌ヨ瀛楁锛�1鏄級 */
+ private String isQuery;
+
+ /** 鏌ヨ鏂瑰紡锛圗Q绛変簬銆丯E涓嶇瓑浜庛�丟T澶т簬銆丩T灏忎簬銆丩IKE妯$硦銆丅ETWEEN鑼冨洿锛� */
+ private String queryType;
+
+ /** 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢锛� */
+ private String htmlType;
+
+ /** 瀛楀吀绫诲瀷 */
+ private String dictType;
+
+ /** 鎺掑簭 */
+ private Integer sort;
+
+ public void setColumnId(Long columnId)
+ {
+ this.columnId = columnId;
+ }
+
+ public Long getColumnId()
+ {
+ return columnId;
+ }
+
+ public void setTableId(Long tableId)
+ {
+ this.tableId = tableId;
+ }
+
+ public Long getTableId()
+ {
+ return tableId;
+ }
+
+ public void setColumnName(String columnName)
+ {
+ this.columnName = columnName;
+ }
+
+ public String getColumnName()
+ {
+ return columnName;
+ }
+
+ public void setColumnComment(String columnComment)
+ {
+ this.columnComment = columnComment;
+ }
+
+ public String getColumnComment()
+ {
+ return columnComment;
+ }
+
+ public void setColumnType(String columnType)
+ {
+ this.columnType = columnType;
+ }
+
+ public String getColumnType()
+ {
+ return columnType;
+ }
+
+ public void setJavaType(String javaType)
+ {
+ this.javaType = javaType;
+ }
+
+ public String getJavaType()
+ {
+ return javaType;
+ }
+
+ public void setJavaField(String javaField)
+ {
+ this.javaField = javaField;
+ }
+
+ public String getJavaField()
+ {
+ return javaField;
+ }
+
+ public void setIsPk(String isPk)
+ {
+ this.isPk = isPk;
+ }
+
+ public String getIsPk()
+ {
+ return isPk;
+ }
+
+ public boolean isPk()
+ {
+ return isPk(this.isPk);
+ }
+
+ public boolean isPk(String isPk)
+ {
+ return isPk != null && StringUtils.equals("1", isPk);
+ }
+
+ public String getIsIncrement()
+ {
+ return isIncrement;
+ }
+
+ public void setIsIncrement(String isIncrement)
+ {
+ this.isIncrement = isIncrement;
+ }
+
+ public boolean isIncrement()
+ {
+ return isIncrement(this.isIncrement);
+ }
+
+ public boolean isIncrement(String isIncrement)
+ {
+ return isIncrement != null && StringUtils.equals("1", isIncrement);
+ }
+
+ public void setIsRequired(String isRequired)
+ {
+ this.isRequired = isRequired;
+ }
+
+ public String getIsRequired()
+ {
+ return isRequired;
+ }
+
+ public boolean isRequired()
+ {
+ return isRequired(this.isRequired);
+ }
+
+ public boolean isRequired(String isRequired)
+ {
+ return isRequired != null && StringUtils.equals("1", isRequired);
+ }
+
+ public void setIsInsert(String isInsert)
+ {
+ this.isInsert = isInsert;
+ }
+
+ public String getIsInsert()
+ {
+ return isInsert;
+ }
+
+ public boolean isInsert()
+ {
+ return isInsert(this.isInsert);
+ }
+
+ public boolean isInsert(String isInsert)
+ {
+ return isInsert != null && StringUtils.equals("1", isInsert);
+ }
+
+ public void setIsEdit(String isEdit)
+ {
+ this.isEdit = isEdit;
+ }
+
+ public String getIsEdit()
+ {
+ return isEdit;
+ }
+
+ public boolean isEdit()
+ {
+ return isInsert(this.isEdit);
+ }
+
+ public boolean isEdit(String isEdit)
+ {
+ return isEdit != null && StringUtils.equals("1", isEdit);
+ }
+
+ public void setIsList(String isList)
+ {
+ this.isList = isList;
+ }
+
+ public String getIsList()
+ {
+ return isList;
+ }
+
+ public boolean isList()
+ {
+ return isList(this.isList);
+ }
+
+ public boolean isList(String isList)
+ {
+ return isList != null && StringUtils.equals("1", isList);
+ }
+
+ public void setIsQuery(String isQuery)
+ {
+ this.isQuery = isQuery;
+ }
+
+ public String getIsQuery()
+ {
+ return isQuery;
+ }
+
+ public boolean isQuery()
+ {
+ return isQuery(this.isQuery);
+ }
+
+ public boolean isQuery(String isQuery)
+ {
+ return isQuery != null && StringUtils.equals("1", isQuery);
+ }
+
+ public void setQueryType(String queryType)
+ {
+ this.queryType = queryType;
+ }
+
+ public String getQueryType()
+ {
+ return queryType;
+ }
+
+ public String getHtmlType()
+ {
+ return htmlType;
+ }
+
+ public void setHtmlType(String htmlType)
+ {
+ this.htmlType = htmlType;
+ }
+
+ public void setDictType(String dictType)
+ {
+ this.dictType = dictType;
+ }
+
+ public String getDictType()
+ {
+ return dictType;
+ }
+
+ public void setSort(Integer sort)
+ {
+ this.sort = sort;
+ }
+
+ public Integer getSort()
+ {
+ return sort;
+ }
+
+ public boolean isSuperColumn()
+ {
+ return isSuperColumn(this.javaField);
+ }
+
+ public static boolean isSuperColumn(String javaField)
+ {
+ return StringUtils.equalsAnyIgnoreCase(javaField,
+ // BaseEntity
+ "createBy", "createTime", "updateBy", "updateTime", "remark",
+ // TreeEntity
+ "parentName", "parentId", "orderNum", "ancestors");
+ }
+
+ public boolean isUsableColumn()
+ {
+ return isUsableColumn(javaField);
+ }
+
+ public static boolean isUsableColumn(String javaField)
+ {
+ // isSuperColumn()涓殑鍚嶅崟鐢ㄤ簬閬垮厤鐢熸垚澶氫綑Domain灞炴�э紝鑻ユ煇浜涘睘鎬у湪鐢熸垚椤甸潰鏃堕渶瑕佺敤鍒颁笉鑳藉拷鐣ワ紝鍒欐斁鍦ㄦ澶勭櫧鍚嶅崟
+ return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum");
+ }
+
+ public String readConverterExp()
+ {
+ String remarks = StringUtils.substringBetween(this.columnComment, "锛�", "锛�");
+ StringBuffer sb = new StringBuffer();
+ if (StringUtils.isNotEmpty(remarks))
+ {
+ for (String value : remarks.split(" "))
+ {
+ if (StringUtils.isNotEmpty(value))
+ {
+ Object startStr = value.subSequence(0, 1);
+ String endStr = value.substring(1);
+ sb.append("").append(startStr).append("=").append(endStr).append(",");
+ }
+ }
+ return sb.deleteCharAt(sb.length() - 1).toString();
+ }
+ else
+ {
+ return this.columnComment;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java
new file mode 100644
index 0000000..dfd8ddd
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java
@@ -0,0 +1,52 @@
+package com.ruoyi.project.tool.gen.mapper;
+
+import java.util.List;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+
+/**
+ * 涓氬姟瀛楁 鏁版嵁灞�
+ *
+ * @author ruoyi
+ */
+public interface GenTableColumnMapper
+{
+ /**
+ * 鏍规嵁琛ㄥ悕绉版煡璇㈠垪淇℃伅
+ *
+ * @param tableName 琛ㄥ悕绉�
+ * @return 鍒椾俊鎭�
+ */
+ public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
+
+ /**
+ * 鏌ヨ涓氬姟瀛楁鍒楄〃
+ *
+ * @param tableId 涓氬姟瀛楁缂栧彿
+ * @return 涓氬姟瀛楁闆嗗悎
+ */
+ public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
+
+ /**
+ * 鏂板涓氬姟瀛楁
+ *
+ * @param genTableColumn 涓氬姟瀛楁淇℃伅
+ * @return 缁撴灉
+ */
+ public int insertGenTableColumn(GenTableColumn genTableColumn);
+
+ /**
+ * 淇敼涓氬姟瀛楁
+ *
+ * @param genTableColumn 涓氬姟瀛楁淇℃伅
+ * @return 缁撴灉
+ */
+ public int updateGenTableColumn(GenTableColumn genTableColumn);
+
+ /**
+ * 鎵归噺鍒犻櫎涓氬姟瀛楁
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
+ * @return 缁撴灉
+ */
+ public int deleteGenTableColumnByIds(Long[] ids);
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java
new file mode 100644
index 0000000..eae10e4
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java
@@ -0,0 +1,76 @@
+package com.ruoyi.project.tool.gen.mapper;
+
+import java.util.List;
+import com.ruoyi.project.tool.gen.domain.GenTable;
+
+/**
+ * 涓氬姟 鏁版嵁灞�
+ *
+ * @author ruoyi
+ */
+public interface GenTableMapper
+{
+ /**
+ * 鏌ヨ涓氬姟鍒楄〃
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 涓氬姟闆嗗悎
+ */
+ public List<GenTable> selectGenTableList(GenTable genTable);
+
+ /**
+ * 鏌ヨ鎹簱鍒楄〃
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 鏁版嵁搴撹〃闆嗗悎
+ */
+ public List<GenTable> selectDbTableList(GenTable genTable);
+
+ /**
+ * 鏌ヨ鎹簱鍒楄〃
+ *
+ * @param tableNames 琛ㄥ悕绉扮粍
+ * @return 鏁版嵁搴撹〃闆嗗悎
+ */
+ public List<GenTable> selectDbTableListByNames(String[] tableNames);
+
+ /**
+ * 鏌ヨ琛↖D涓氬姟淇℃伅
+ *
+ * @param id 涓氬姟ID
+ * @return 涓氬姟淇℃伅
+ */
+ public GenTable selectGenTableById(Long id);
+
+ /**
+ * 鏌ヨ琛ㄥ悕绉颁笟鍔′俊鎭�
+ *
+ * @param tableName 琛ㄥ悕绉�
+ * @return 涓氬姟淇℃伅
+ */
+ public GenTable selectGenTableByName(String tableName);
+
+ /**
+ * 鏂板涓氬姟
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 缁撴灉
+ */
+ public int insertGenTable(GenTable genTable);
+
+ /**
+ * 淇敼涓氬姟
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 缁撴灉
+ */
+ public int updateGenTable(GenTable genTable);
+
+ /**
+ * 鎵归噺鍒犻櫎涓氬姟
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
+ * @return 缁撴灉
+ */
+ public int deleteGenTableByIds(Long[] ids);
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java
new file mode 100644
index 0000000..ab804ac
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java
@@ -0,0 +1,68 @@
+package com.ruoyi.project.tool.gen.service;
+
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.common.utils.text.Convert;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper;
+
+/**
+ * 涓氬姟瀛楁 鏈嶅姟灞傚疄鐜�
+ *
+ * @author ruoyi
+ */
+@Service
+public class GenTableColumnServiceImpl implements IGenTableColumnService
+{
+ @Autowired
+ private GenTableColumnMapper genTableColumnMapper;
+
+ /**
+ * 鏌ヨ涓氬姟瀛楁鍒楄〃
+ *
+ * @param genTableColumn 涓氬姟瀛楁缂栧彿
+ * @return 涓氬姟瀛楁闆嗗悎
+ */
+ @Override
+ public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
+ {
+ return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
+ }
+
+ /**
+ * 鏂板涓氬姟瀛楁
+ *
+ * @param genTableColumn 涓氬姟瀛楁淇℃伅
+ * @return 缁撴灉
+ */
+ @Override
+ public int insertGenTableColumn(GenTableColumn genTableColumn)
+ {
+ return genTableColumnMapper.insertGenTableColumn(genTableColumn);
+ }
+
+ /**
+ * 淇敼涓氬姟瀛楁
+ *
+ * @param genTableColumn 涓氬姟瀛楁淇℃伅
+ * @return 缁撴灉
+ */
+ @Override
+ public int updateGenTableColumn(GenTableColumn genTableColumn)
+ {
+ return genTableColumnMapper.updateGenTableColumn(genTableColumn);
+ }
+
+ /**
+ * 鍒犻櫎涓氬姟瀛楁瀵硅薄
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
+ * @return 缁撴灉
+ */
+ @Override
+ public int deleteGenTableColumnByIds(String ids)
+ {
+ return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java
new file mode 100644
index 0000000..09d1e89
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java
@@ -0,0 +1,340 @@
+package com.ruoyi.project.tool.gen.service;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+import org.apache.commons.io.IOUtils;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.constant.GenConstants;
+import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.project.tool.gen.domain.GenTable;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper;
+import com.ruoyi.project.tool.gen.mapper.GenTableMapper;
+import com.ruoyi.project.tool.gen.util.GenUtils;
+import com.ruoyi.project.tool.gen.util.VelocityInitializer;
+import com.ruoyi.project.tool.gen.util.VelocityUtils;
+
+/**
+ * 涓氬姟 鏈嶅姟灞傚疄鐜�
+ *
+ * @author ruoyi
+ */
+@Service
+public class GenTableServiceImpl implements IGenTableService
+{
+ private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
+
+ @Autowired
+ private GenTableMapper genTableMapper;
+
+ @Autowired
+ private GenTableColumnMapper genTableColumnMapper;
+
+ /**
+ * 鏌ヨ涓氬姟淇℃伅
+ *
+ * @param id 涓氬姟ID
+ * @return 涓氬姟淇℃伅
+ */
+ @Override
+ public GenTable selectGenTableById(Long id)
+ {
+ GenTable genTable = genTableMapper.selectGenTableById(id);
+ setTableFromOptions(genTable);
+ return genTable;
+ }
+
+ /**
+ * 鏌ヨ涓氬姟鍒楄〃
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 涓氬姟闆嗗悎
+ */
+ @Override
+ public List<GenTable> selectGenTableList(GenTable genTable)
+ {
+ return genTableMapper.selectGenTableList(genTable);
+ }
+
+ /**
+ * 鏌ヨ鎹簱鍒楄〃
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 鏁版嵁搴撹〃闆嗗悎
+ */
+ public List<GenTable> selectDbTableList(GenTable genTable)
+ {
+ return genTableMapper.selectDbTableList(genTable);
+ }
+
+ /**
+ * 鏌ヨ鎹簱鍒楄〃
+ *
+ * @param tableNames 琛ㄥ悕绉扮粍
+ * @return 鏁版嵁搴撹〃闆嗗悎
+ */
+ public List<GenTable> selectDbTableListByNames(String[] tableNames)
+ {
+ return genTableMapper.selectDbTableListByNames(tableNames);
+ }
+
+ /**
+ * 淇敼涓氬姟
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 缁撴灉
+ */
+ @Override
+ @Transactional
+ public void updateGenTable(GenTable genTable)
+ {
+ String options = JSON.toJSONString(genTable.getParams());
+ genTable.setOptions(options);
+ int row = genTableMapper.updateGenTable(genTable);
+ if (row > 0)
+ {
+ for (GenTableColumn cenTableColumn : genTable.getColumns())
+ {
+ genTableColumnMapper.updateGenTableColumn(cenTableColumn);
+ }
+ }
+ }
+
+ /**
+ * 鍒犻櫎涓氬姟瀵硅薄
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
+ * @return 缁撴灉
+ */
+ @Override
+ @Transactional
+ public void deleteGenTableByIds(Long[] tableIds)
+ {
+ genTableMapper.deleteGenTableByIds(tableIds);
+ genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
+ }
+
+ /**
+ * 瀵煎叆琛ㄧ粨鏋�
+ *
+ * @param tableList 瀵煎叆琛ㄥ垪琛�
+ */
+ @Override
+ @Transactional
+ public void importGenTable(List<GenTable> tableList)
+ {
+ String operName = SecurityUtils.getUsername();
+ for (GenTable table : tableList)
+ {
+ try
+ {
+ String tableName = table.getTableName();
+ GenUtils.initTable(table, operName);
+ int row = genTableMapper.insertGenTable(table);
+ if (row > 0)
+ {
+ // 淇濆瓨鍒椾俊鎭�
+ List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
+ for (GenTableColumn column : genTableColumns)
+ {
+ GenUtils.initColumnField(column, table);
+ genTableColumnMapper.insertGenTableColumn(column);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("琛ㄥ悕 " + table.getTableName() + " 瀵煎叆澶辫触锛�", e);
+ }
+ }
+ }
+
+ /**
+ * 棰勮浠g爜
+ *
+ * @param tableId 琛ㄧ紪鍙�
+ * @return 棰勮鏁版嵁鍒楄〃
+ */
+ public Map<String, String> previewCode(Long tableId)
+ {
+ Map<String, String> dataMap = new LinkedHashMap<>();
+ // 鏌ヨ琛ㄤ俊鎭�
+ GenTable table = genTableMapper.selectGenTableById(tableId);
+ // 鏌ヨ鍒椾俊鎭�
+ List<GenTableColumn> columns = table.getColumns();
+ setPkColumn(table, columns);
+ VelocityInitializer.initVelocity();
+
+ VelocityContext context = VelocityUtils.prepareContext(table);
+
+ // 鑾峰彇妯℃澘鍒楄〃
+ List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
+ for (String template : templates)
+ {
+ // 娓叉煋妯℃澘
+ StringWriter sw = new StringWriter();
+ Template tpl = Velocity.getTemplate(template, Constants.UTF8);
+ tpl.merge(context, sw);
+ dataMap.put(template, sw.toString());
+ }
+ return dataMap;
+ }
+
+ /**
+ * 鐢熸垚浠g爜
+ *
+ * @param tableName 琛ㄥ悕绉�
+ * @return 鏁版嵁
+ */
+ @Override
+ public byte[] generatorCode(String tableName)
+ {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ ZipOutputStream zip = new ZipOutputStream(outputStream);
+ generatorCode(tableName, zip);
+ IOUtils.closeQuietly(zip);
+ return outputStream.toByteArray();
+ }
+
+ /**
+ * 鎵归噺鐢熸垚浠g爜
+ *
+ * @param tableNames 琛ㄦ暟缁�
+ * @return 鏁版嵁
+ */
+ @Override
+ public byte[] generatorCode(String[] tableNames)
+ {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ ZipOutputStream zip = new ZipOutputStream(outputStream);
+ for (String tableName : tableNames)
+ {
+ generatorCode(tableName, zip);
+ }
+ IOUtils.closeQuietly(zip);
+ return outputStream.toByteArray();
+ }
+
+ /**
+ * 鏌ヨ琛ㄤ俊鎭苟鐢熸垚浠g爜
+ */
+ private void generatorCode(String tableName, ZipOutputStream zip)
+ {
+ // 鏌ヨ琛ㄤ俊鎭�
+ GenTable table = genTableMapper.selectGenTableByName(tableName);
+ // 鏌ヨ鍒椾俊鎭�
+ List<GenTableColumn> columns = table.getColumns();
+ setPkColumn(table, columns);
+
+ VelocityInitializer.initVelocity();
+
+ VelocityContext context = VelocityUtils.prepareContext(table);
+
+ // 鑾峰彇妯℃澘鍒楄〃
+ List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
+ for (String template : templates)
+ {
+ // 娓叉煋妯℃澘
+ StringWriter sw = new StringWriter();
+ Template tpl = Velocity.getTemplate(template, Constants.UTF8);
+ tpl.merge(context, sw);
+ try
+ {
+ // 娣诲姞鍒皕ip
+ zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
+ IOUtils.write(sw.toString(), zip, Constants.UTF8);
+ IOUtils.closeQuietly(sw);
+ zip.closeEntry();
+ }
+ catch (IOException e)
+ {
+ log.error("娓叉煋妯℃澘澶辫触锛岃〃鍚嶏細" + table.getTableName(), e);
+ }
+ }
+ }
+
+ /**
+ * 淇敼淇濆瓨鍙傛暟鏍¢獙
+ *
+ * @param genTable 涓氬姟淇℃伅
+ */
+ public void validateEdit(GenTable genTable)
+ {
+ if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
+ {
+ String options = JSON.toJSONString(genTable.getParams());
+ JSONObject paramsObj = JSONObject.parseObject(options);
+ if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
+ {
+ throw new CustomException("鏍戠紪鐮佸瓧娈典笉鑳戒负绌�");
+ }
+ else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
+ {
+ throw new CustomException("鏍戠埗缂栫爜瀛楁涓嶈兘涓虹┖");
+ }
+ else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
+ {
+ throw new CustomException("鏍戝悕绉板瓧娈典笉鑳戒负绌�");
+ }
+ }
+ }
+
+ /**
+ * 璁剧疆涓婚敭鍒椾俊鎭�
+ *
+ * @param genTable 涓氬姟琛ㄤ俊鎭�
+ * @param columns 涓氬姟瀛楁鍒楄〃
+ */
+ public void setPkColumn(GenTable table, List<GenTableColumn> columns)
+ {
+ for (GenTableColumn column : columns)
+ {
+ if (column.isPk())
+ {
+ table.setPkColumn(column);
+ break;
+ }
+ }
+ if (StringUtils.isNull(table.getPkColumn()))
+ {
+ table.setPkColumn(columns.get(0));
+ }
+ }
+
+ /**
+ * 璁剧疆浠g爜鐢熸垚鍏朵粬閫夐」鍊�
+ *
+ * @param genTable 璁剧疆鍚庣殑鐢熸垚瀵硅薄
+ */
+ public void setTableFromOptions(GenTable genTable)
+ {
+ JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
+ if (StringUtils.isNotNull(paramsObj))
+ {
+ String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
+ String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
+ String treeName = paramsObj.getString(GenConstants.TREE_NAME);
+ genTable.setTreeCode(treeCode);
+ genTable.setTreeParentCode(treeParentCode);
+ genTable.setTreeName(treeName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java
new file mode 100644
index 0000000..d74c3e7
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java
@@ -0,0 +1,44 @@
+package com.ruoyi.project.tool.gen.service;
+
+import java.util.List;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+
+/**
+ * 涓氬姟瀛楁 鏈嶅姟灞�
+ *
+ * @author ruoyi
+ */
+public interface IGenTableColumnService
+{
+ /**
+ * 鏌ヨ涓氬姟瀛楁鍒楄〃
+ *
+ * @param genTableColumn 涓氬姟瀛楁缂栧彿
+ * @return 涓氬姟瀛楁闆嗗悎
+ */
+ public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
+
+ /**
+ * 鏂板涓氬姟瀛楁
+ *
+ * @param genTableColumn 涓氬姟瀛楁淇℃伅
+ * @return 缁撴灉
+ */
+ public int insertGenTableColumn(GenTableColumn genTableColumn);
+
+ /**
+ * 淇敼涓氬姟瀛楁
+ *
+ * @param genTableColumn 涓氬姟瀛楁淇℃伅
+ * @return 缁撴灉
+ */
+ public int updateGenTableColumn(GenTableColumn genTableColumn);
+
+ /**
+ * 鍒犻櫎涓氬姟瀛楁淇℃伅
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
+ * @return 缁撴灉
+ */
+ public int deleteGenTableColumnByIds(String ids);
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java
new file mode 100644
index 0000000..73093fe
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java
@@ -0,0 +1,99 @@
+package com.ruoyi.project.tool.gen.service;
+
+import java.util.List;
+import java.util.Map;
+import com.ruoyi.project.tool.gen.domain.GenTable;
+
+/**
+ * 涓氬姟 鏈嶅姟灞�
+ *
+ * @author ruoyi
+ */
+public interface IGenTableService
+{
+ /**
+ * 鏌ヨ涓氬姟鍒楄〃
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 涓氬姟闆嗗悎
+ */
+ public List<GenTable> selectGenTableList(GenTable genTable);
+
+ /**
+ * 鏌ヨ鎹簱鍒楄〃
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 鏁版嵁搴撹〃闆嗗悎
+ */
+ public List<GenTable> selectDbTableList(GenTable genTable);
+
+ /**
+ * 鏌ヨ鎹簱鍒楄〃
+ *
+ * @param tableNames 琛ㄥ悕绉扮粍
+ * @return 鏁版嵁搴撹〃闆嗗悎
+ */
+ public List<GenTable> selectDbTableListByNames(String[] tableNames);
+
+ /**
+ * 鏌ヨ涓氬姟淇℃伅
+ *
+ * @param id 涓氬姟ID
+ * @return 涓氬姟淇℃伅
+ */
+ public GenTable selectGenTableById(Long id);
+
+ /**
+ * 淇敼涓氬姟
+ *
+ * @param genTable 涓氬姟淇℃伅
+ * @return 缁撴灉
+ */
+ public void updateGenTable(GenTable genTable);
+
+ /**
+ * 鍒犻櫎涓氬姟淇℃伅
+ *
+ * @param tableIds 闇�瑕佸垹闄ょ殑琛ㄦ暟鎹甀D
+ * @return 缁撴灉
+ */
+ public void deleteGenTableByIds(Long[] tableIds);
+
+ /**
+ * 瀵煎叆琛ㄧ粨鏋�
+ *
+ * @param tableList 瀵煎叆琛ㄥ垪琛�
+ */
+ public void importGenTable(List<GenTable> tableList);
+
+ /**
+ * 棰勮浠g爜
+ *
+ * @param tableId 琛ㄧ紪鍙�
+ * @return 棰勮鏁版嵁鍒楄〃
+ */
+ public Map<String, String> previewCode(Long tableId);
+
+ /**
+ * 鐢熸垚浠g爜
+ *
+ * @param tableName 琛ㄥ悕绉�
+ * @return 鏁版嵁
+ */
+ public byte[] generatorCode(String tableName);
+
+ /**
+ * 鎵归噺鐢熸垚浠g爜
+ *
+ * @param tableNames 琛ㄦ暟缁�
+ * @return 鏁版嵁
+ */
+ public byte[] generatorCode(String[] tableNames);
+
+ /**
+ * 淇敼淇濆瓨鍙傛暟鏍¢獙
+ *
+ * @param genTable 涓氬姟淇℃伅
+ */
+ public void validateEdit(GenTable genTable);
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
new file mode 100644
index 0000000..5904013
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
@@ -0,0 +1,238 @@
+package com.ruoyi.project.tool.gen.util;
+
+import java.util.Arrays;
+import org.apache.commons.lang3.RegExUtils;
+import com.ruoyi.common.constant.GenConstants;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.config.GenConfig;
+import com.ruoyi.project.tool.gen.domain.GenTable;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+
+/**
+ * 浠g爜鐢熸垚鍣� 宸ュ叿绫�
+ *
+ * @author ruoyi
+ */
+public class GenUtils
+{
+ /**
+ * 鍒濆鍖栬〃淇℃伅
+ */
+ public static void initTable(GenTable genTable, String operName)
+ {
+ genTable.setClassName(convertClassName(genTable.getTableName()));
+ genTable.setPackageName(GenConfig.getPackageName());
+ genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
+ genTable.setBusinessName(getBusinessName(genTable.getTableName()));
+ genTable.setFunctionName(replaceText(genTable.getTableComment()));
+ genTable.setFunctionAuthor(GenConfig.getAuthor());
+ genTable.setCreateBy(operName);
+ }
+
+ /**
+ * 鍒濆鍖栧垪灞炴�у瓧娈�
+ */
+ public static void initColumnField(GenTableColumn column, GenTable table)
+ {
+ String dataType = getDbType(column.getColumnType());
+ String columnName = column.getColumnName();
+ column.setTableId(table.getTableId());
+ column.setCreateBy(table.getCreateBy());
+ // 璁剧疆java瀛楁鍚�
+ column.setJavaField(StringUtils.toCamelCase(columnName));
+
+ if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType))
+ {
+ column.setJavaType(GenConstants.TYPE_STRING);
+ // 瀛楃涓查暱搴﹁秴杩�500璁剧疆涓烘枃鏈煙
+ Integer columnLength = getColumnLength(column.getColumnType());
+ String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
+ column.setHtmlType(htmlType);
+ }
+ else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
+ {
+ column.setJavaType(GenConstants.TYPE_DATE);
+ column.setHtmlType(GenConstants.HTML_DATETIME);
+ }
+ else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType))
+ {
+ column.setHtmlType(GenConstants.HTML_INPUT);
+
+ // 濡傛灉鏄诞鐐瑰瀷
+ String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
+ if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
+ {
+ column.setJavaType(GenConstants.TYPE_DOUBLE);
+ }
+ // 濡傛灉鏄暣褰�
+ else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
+ {
+ column.setJavaType(GenConstants.TYPE_INTEGER);
+ }
+ // 闀挎暣褰�
+ else
+ {
+ column.setJavaType(GenConstants.TYPE_LONG);
+ }
+ }
+
+ // 鎻掑叆瀛楁锛堥粯璁ゆ墍鏈夊瓧娈甸兘闇�瑕佹彃鍏ワ級
+ column.setIsInsert(GenConstants.REQUIRE);
+
+ // 缂栬緫瀛楁
+ if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
+ {
+ column.setIsEdit(GenConstants.REQUIRE);
+ }
+ // 鍒楄〃瀛楁
+ if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
+ {
+ column.setIsList(GenConstants.REQUIRE);
+ }
+ // 鏌ヨ瀛楁
+ if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
+ {
+ column.setIsQuery(GenConstants.REQUIRE);
+ }
+
+ // 鏌ヨ瀛楁绫诲瀷
+ if (StringUtils.endsWithIgnoreCase(columnName, "name"))
+ {
+ column.setQueryType(GenConstants.QUERY_LIKE);
+ }
+ // 鐘舵�佸瓧娈佃缃崟閫夋
+ if (StringUtils.endsWithIgnoreCase(columnName, "status"))
+ {
+ column.setHtmlType(GenConstants.HTML_RADIO);
+ }
+ // 绫诲瀷&鎬у埆瀛楁璁剧疆涓嬫媺妗�
+ else if (StringUtils.endsWithIgnoreCase(columnName, "type")
+ || StringUtils.endsWithIgnoreCase(columnName, "sex"))
+ {
+ column.setHtmlType(GenConstants.HTML_SELECT);
+ }
+ }
+
+ /**
+ * 鏍¢獙鏁扮粍鏄惁鍖呭惈鎸囧畾鍊�
+ *
+ * @param arr 鏁扮粍
+ * @param targetValue 鍊�
+ * @return 鏄惁鍖呭惈
+ */
+ public static boolean arraysContains(String[] arr, String targetValue)
+ {
+ return Arrays.asList(arr).contains(targetValue);
+ }
+
+ /**
+ * 鑾峰彇妯″潡鍚�
+ *
+ * @param packageName 鍖呭悕
+ * @return 妯″潡鍚�
+ */
+ public static String getModuleName(String packageName)
+ {
+ int lastIndex = packageName.lastIndexOf(".");
+ int nameLength = packageName.length();
+ String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
+ return moduleName;
+ }
+
+ /**
+ * 鑾峰彇涓氬姟鍚�
+ *
+ * @param tableName 琛ㄥ悕
+ * @return 涓氬姟鍚�
+ */
+ public static String getBusinessName(String tableName)
+ {
+ int lastIndex = tableName.lastIndexOf("_");
+ int nameLength = tableName.length();
+ String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
+ return businessName;
+ }
+
+ /**
+ * 琛ㄥ悕杞崲鎴怞ava绫诲悕
+ *
+ * @param tableName 琛ㄥ悕绉�
+ * @return 绫诲悕
+ */
+ public static String convertClassName(String tableName)
+ {
+ boolean autoRemovePre = GenConfig.getAutoRemovePre();
+ String tablePrefix = GenConfig.getTablePrefix();
+ if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
+ {
+ String[] searchList = StringUtils.split(tablePrefix, ",");
+ String[] replacementList = emptyList(searchList.length);
+ tableName = StringUtils.replaceEach(tableName, searchList, replacementList);
+ }
+ return StringUtils.convertToCamelCase(tableName);
+ }
+
+ /**
+ * 鍏抽敭瀛楁浛鎹�
+ *
+ * @param name 闇�瑕佽鏇挎崲鐨勫悕瀛�
+ * @return 鏇挎崲鍚庣殑鍚嶅瓧
+ */
+ public static String replaceText(String text)
+ {
+ return RegExUtils.replaceAll(text, "(?:琛▅鑻ヤ緷)", "");
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁搴撶被鍨嬪瓧娈�
+ *
+ * @param columnType 鍒楃被鍨�
+ * @return 鎴彇鍚庣殑鍒楃被鍨�
+ */
+ public static String getDbType(String columnType)
+ {
+ if (StringUtils.indexOf(columnType, "(") > 0)
+ {
+ return StringUtils.substringBefore(columnType, "(");
+ }
+ else
+ {
+ return columnType;
+ }
+ }
+
+ /**
+ * 鑾峰彇瀛楁闀垮害
+ *
+ * @param columnType 鍒楃被鍨�
+ * @return 鎴彇鍚庣殑鍒楃被鍨�
+ */
+ public static Integer getColumnLength(String columnType)
+ {
+ if (StringUtils.indexOf(columnType, "(") > 0)
+ {
+ String length = StringUtils.substringBetween(columnType, "(", ")");
+ return Integer.valueOf(length);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * 鑾峰彇绌烘暟缁勫垪琛�
+ *
+ * @param length 闀垮害
+ * @return 鏁扮粍淇℃伅
+ */
+ public static String[] emptyList(int length)
+ {
+ String[] values = new String[length];
+ for (int i = 0; i < length; i++)
+ {
+ values[i] = StringUtils.EMPTY;
+ }
+ return values;
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java
new file mode 100644
index 0000000..7f932fc
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java
@@ -0,0 +1,35 @@
+package com.ruoyi.project.tool.gen.util;
+
+import java.util.Properties;
+import org.apache.velocity.app.Velocity;
+import com.ruoyi.common.constant.Constants;
+
+/**
+ * VelocityEngine宸ュ巶
+ *
+ * @author RuoYi
+ */
+public class VelocityInitializer
+{
+ /**
+ * 鍒濆鍖杤m鏂规硶
+ */
+ public static void initVelocity()
+ {
+ Properties p = new Properties();
+ try
+ {
+ // 鍔犺浇classpath鐩綍涓嬬殑vm鏂囦欢
+ p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ // 瀹氫箟瀛楃闆�
+ p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8);
+ p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
+ // 鍒濆鍖朧elocity寮曟搸锛屾寚瀹氶厤缃甈roperties
+ Velocity.init(p);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java
new file mode 100644
index 0000000..52d209b
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java
@@ -0,0 +1,281 @@
+package com.ruoyi.project.tool.gen.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import org.apache.velocity.VelocityContext;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.constant.GenConstants;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.project.tool.gen.domain.GenTable;
+import com.ruoyi.project.tool.gen.domain.GenTableColumn;
+
+public class VelocityUtils
+{
+ /** 椤圭洰绌洪棿璺緞 */
+ private static final String PROJECT_PATH = "main/java";
+
+ /** mybatis绌洪棿璺緞 */
+ private static final String MYBATIS_PATH = "main/resources/mybatis";
+
+ /**
+ * 璁剧疆妯℃澘鍙橀噺淇℃伅
+ *
+ * @return 妯℃澘鍒楄〃
+ */
+ public static VelocityContext prepareContext(GenTable genTable)
+ {
+ String moduleName = genTable.getModuleName();
+ String businessName = genTable.getBusinessName();
+ String packageName = genTable.getPackageName();
+ String tplCategory = genTable.getTplCategory();
+ String functionName = genTable.getFunctionName();
+
+ VelocityContext velocityContext = new VelocityContext();
+ velocityContext.put("tplCategory", genTable.getTplCategory());
+ velocityContext.put("tableName", genTable.getTableName());
+ velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "銆愯濉啓鍔熻兘鍚嶇О銆�");
+ velocityContext.put("ClassName", genTable.getClassName());
+ velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
+ velocityContext.put("moduleName", genTable.getModuleName());
+ velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
+ velocityContext.put("businessName", genTable.getBusinessName());
+ velocityContext.put("basePackage", getPackagePrefix(packageName));
+ velocityContext.put("packageName", packageName);
+ velocityContext.put("author", genTable.getFunctionAuthor());
+ velocityContext.put("datetime", DateUtils.getDate());
+ velocityContext.put("pkColumn", genTable.getPkColumn());
+ velocityContext.put("importList", getImportList(genTable.getColumns()));
+ velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
+ velocityContext.put("columns", genTable.getColumns());
+ velocityContext.put("table", genTable);
+ if (GenConstants.TPL_TREE.equals(tplCategory))
+ {
+ setTreeVelocityContext(velocityContext, genTable);
+ }
+ return velocityContext;
+ }
+
+ public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
+ {
+ String options = genTable.getOptions();
+ JSONObject paramsObj = JSONObject.parseObject(options);
+ String treeCode = getTreecode(paramsObj);
+ String treeParentCode = getTreeParentCode(paramsObj);
+ String treeName = getTreeName(paramsObj);
+
+ context.put("treeCode", treeCode);
+ context.put("treeParentCode", treeParentCode);
+ context.put("treeName", treeName);
+ context.put("expandColumn", getExpandColumn(genTable));
+ if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
+ {
+ context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
+ }
+ if (paramsObj.containsKey(GenConstants.TREE_NAME))
+ {
+ context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
+ }
+ }
+
+ /**
+ * 鑾峰彇妯℃澘淇℃伅
+ *
+ * @return 妯℃澘鍒楄〃
+ */
+ public static List<String> getTemplateList(String tplCategory)
+ {
+ List<String> templates = new ArrayList<String>();
+ templates.add("vm/java/domain.java.vm");
+ templates.add("vm/java/mapper.java.vm");
+ templates.add("vm/java/service.java.vm");
+ templates.add("vm/java/serviceImpl.java.vm");
+ templates.add("vm/java/controller.java.vm");
+ templates.add("vm/xml/mapper.xml.vm");
+ templates.add("vm/sql/sql.vm");
+ templates.add("vm/js/api.js.vm");
+ templates.add("vm/vue/index.vue.vm");
+ return templates;
+ }
+
+ /**
+ * 鑾峰彇鏂囦欢鍚�
+ */
+ public static String getFileName(String template, GenTable genTable)
+ {
+ // 鏂囦欢鍚嶇О
+ String fileName = "";
+ // 鍖呰矾寰�
+ String packageName = genTable.getPackageName();
+ // 妯″潡鍚�
+ String moduleName = genTable.getModuleName();
+ // 澶у啓绫诲悕
+ String className = genTable.getClassName();
+ // 涓氬姟鍚嶇О
+ String businessName = genTable.getBusinessName();
+
+ String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
+ String mybatisPath = MYBATIS_PATH + "/" + moduleName;
+ String vuePath = "vue";
+
+ if (template.contains("domain.java.vm"))
+ {
+ fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
+ }
+ else if (template.contains("mapper.java.vm"))
+ {
+ fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
+ }
+ else if (template.contains("service.java.vm"))
+ {
+ fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
+ }
+ else if (template.contains("serviceImpl.java.vm"))
+ {
+ fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
+ }
+ else if (template.contains("controller.java.vm"))
+ {
+ fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
+ }
+ else if (template.contains("mapper.xml.vm"))
+ {
+ fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
+ }
+ else if (template.contains("sql.vm"))
+ {
+ fileName = businessName + "Menu.sql";
+ }
+ else if (template.contains("js.vm"))
+ {
+ fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
+ }
+ else if (template.contains("vue.vm"))
+ {
+ fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
+ }
+ return fileName;
+ }
+
+ /**
+ * 鑾峰彇鍖呭墠缂�
+ *
+ * @param packageName 鍖呭悕绉�
+ * @return 鍖呭墠缂�鍚嶇О
+ */
+ public static String getPackagePrefix(String packageName)
+ {
+ int lastIndex = packageName.lastIndexOf(".");
+ String basePackage = StringUtils.substring(packageName, 0, lastIndex);
+ return basePackage;
+ }
+
+ /**
+ * 鏍规嵁鍒楃被鍨嬭幏鍙栧鍏ュ寘
+ *
+ * @param column 鍒楅泦鍚�
+ * @return 杩斿洖闇�瑕佸鍏ョ殑鍖呭垪琛�
+ */
+ public static HashSet<String> getImportList(List<GenTableColumn> columns)
+ {
+ HashSet<String> importList = new HashSet<String>();
+ for (GenTableColumn column : columns)
+ {
+ if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
+ {
+ importList.add("java.util.Date");
+ }
+ else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
+ {
+ importList.add("java.math.BigDecimal");
+ }
+ }
+ return importList;
+ }
+
+ /**
+ * 鑾峰彇鏉冮檺鍓嶇紑
+ *
+ * @param moduleName 妯″潡鍚嶇О
+ * @param businessName 涓氬姟鍚嶇О
+ * @return 杩斿洖鏉冮檺鍓嶇紑
+ */
+ public static String getPermissionPrefix(String moduleName, String businessName)
+ {
+ return StringUtils.format("{}:{}", moduleName, businessName);
+
+ }
+
+ /**
+ * 鑾峰彇鏍戠紪鐮�
+ *
+ * @param options 鐢熸垚鍏朵粬閫夐」
+ * @return 鏍戠紪鐮�
+ */
+ public static String getTreecode(JSONObject paramsObj)
+ {
+ if (paramsObj.containsKey(GenConstants.TREE_CODE))
+ {
+ return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
+ }
+ return "";
+ }
+
+ /**
+ * 鑾峰彇鏍戠埗缂栫爜
+ *
+ * @param options 鐢熸垚鍏朵粬閫夐」
+ * @return 鏍戠埗缂栫爜
+ */
+ public static String getTreeParentCode(JSONObject paramsObj)
+ {
+ if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
+ {
+ return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
+ }
+ return "";
+ }
+
+ /**
+ * 鑾峰彇鏍戝悕绉�
+ *
+ * @param options 鐢熸垚鍏朵粬閫夐」
+ * @return 鏍戝悕绉�
+ */
+ public static String getTreeName(JSONObject paramsObj)
+ {
+ if (paramsObj.containsKey(GenConstants.TREE_NAME))
+ {
+ return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
+ }
+ return "";
+ }
+
+ /**
+ * 鑾峰彇闇�瑕佸湪鍝竴鍒椾笂闈㈡樉绀哄睍寮�鎸夐挳
+ *
+ * @param genTable 涓氬姟琛ㄥ璞�
+ * @return 灞曞紑鎸夐挳鍒楀簭鍙�
+ */
+ public static int getExpandColumn(GenTable genTable)
+ {
+ String options = genTable.getOptions();
+ JSONObject paramsObj = JSONObject.parseObject(options);
+ String treeName = paramsObj.getString(GenConstants.TREE_NAME);
+ int num = 0;
+ for (GenTableColumn column : genTable.getColumns())
+ {
+ if (column.isList())
+ {
+ num++;
+ String columnName = column.getColumnName();
+ if (columnName.equals(treeName))
+ {
+ break;
+ }
+ }
+ }
+ return num;
+ }
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/application.yml b/ruoyi/src/main/resources/application.yml
index a1f653d..b81d058 100644
--- a/ruoyi/src/main/resources/application.yml
+++ b/ruoyi/src/main/resources/application.yml
@@ -3,7 +3,7 @@
# 鍚嶇О
name: RuoYi
# 鐗堟湰
- version: 1.1.0
+ version: 2.0.0
# 鐗堟潈骞翠唤
copyrightYear: 2019
# 瀹炰緥婕旂ず寮�鍏�
@@ -106,4 +106,15 @@
# 鎺掗櫎閾炬帴锛堝涓敤閫楀彿鍒嗛殧锛�
excludes: /system/notice/*
# 鍖归厤閾炬帴
- urlPatterns: /system/*,/monitor/*,/tool/*
\ No newline at end of file
+ urlPatterns: /system/*,/monitor/*,/tool/*
+
+# 浠g爜鐢熸垚
+gen:
+ # 浣滆��
+ author: ruoyi
+ # 榛樿鐢熸垚鍖呰矾寰� system 闇�鏀规垚鑷繁鐨勬ā鍧楀悕绉� 濡� system monitor tool
+ packageName: com.ruoyi.project.system
+ # 鑷姩鍘婚櫎琛ㄥ墠缂�锛岄粯璁ゆ槸true
+ autoRemovePre: false
+ # 琛ㄥ墠缂�锛堢敓鎴愮被鍚嶄笉浼氬寘鍚〃鍓嶇紑锛屽涓敤閫楀彿鍒嗛殧锛�
+ tablePrefix: sys_
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml b/ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml
index c5521a4..d62a0c4 100644
--- a/ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml
+++ b/ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml
@@ -33,11 +33,11 @@
<if test="userName != null and userName != ''">
AND user_name like concat('%', #{userName}, '%')
</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- and date_format(login_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ and date_format(login_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- and date_format(login_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ and date_format(login_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
</where>
</select>
diff --git a/ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml b/ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml
index c6e12c4..96b74b3 100644
--- a/ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml
+++ b/ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml
@@ -54,11 +54,11 @@
<if test="operName != null and operName != ''">
AND oper_name like concat('%', #{operName}, '%')
</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ and date_format(oper_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ and date_format(oper_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
</where>
</select>
diff --git a/ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml b/ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml
index 5cfb1f3..daf736a 100644
--- a/ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml
+++ b/ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml
@@ -50,11 +50,11 @@
<if test="configKey != null and configKey != ''">
AND config_key like concat('%', #{configKey}, '%')
</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
</where>
</select>
diff --git a/ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml b/ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml
index 2c3f74e..378e961 100644
--- a/ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml
+++ b/ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml
@@ -32,11 +32,11 @@
<if test="dictType != null and dictType != ''">
AND dict_type like concat('%', #{dictType}, '%')
</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
</where>
</select>
diff --git a/ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml b/ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml
index 182c6c7..f5281b9 100644
--- a/ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml
+++ b/ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml
@@ -40,11 +40,11 @@
<if test="roleKey != null and roleKey != ''">
AND r.role_key like concat('%', #{roleKey}, '%')
</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ and date_format(r.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ and date_format(r.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<!-- 鏁版嵁鑼冨洿杩囨护 -->
${dataScope}
diff --git a/ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml b/ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml
index 85d1786..25dd072 100644
--- a/ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml
+++ b/ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml
@@ -67,11 +67,11 @@
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ AND date_format(u.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ AND date_format(u.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) ))
diff --git a/ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml b/ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml
new file mode 100644
index 0000000..c936fe0
--- /dev/null
+++ b/ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper">
+
+ <resultMap type="GenTableColumn" id="GenTableColumnResult">
+ <id property="columnId" column="column_id" />
+ <result property="tableId" column="table_id" />
+ <result property="columnName" column="column_name" />
+ <result property="columnComment" column="column_comment" />
+ <result property="columnType" column="column_type" />
+ <result property="javaType" column="java_type" />
+ <result property="javaField" column="java_field" />
+ <result property="isPk" column="is_pk" />
+ <result property="isIncrement" column="is_increment" />
+ <result property="isRequired" column="is_required" />
+ <result property="isInsert" column="is_insert" />
+ <result property="isEdit" column="is_edit" />
+ <result property="isList" column="is_list" />
+ <result property="isQuery" column="is_query" />
+ <result property="queryType" column="query_type" />
+ <result property="htmlType" column="html_type" />
+ <result property="dictType" column="dict_type" />
+ <result property="sort" column="sort" />
+ <result property="createBy" column="create_by" />
+ <result property="createTime" column="create_time" />
+ <result property="updateBy" column="update_by" />
+ <result property="updateTime" column="update_time" />
+ </resultMap>
+
+ <sql id="selectGenTableColumnVo">
+ select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
+ </sql>
+
+ <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult">
+ <include refid="selectGenTableColumnVo"/>
+ where table_id = #{tableId}
+ order by sort
+ </select>
+
+ <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
+ select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
+ from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
+ order by ordinal_position
+ </select>
+
+ <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
+ insert into gen_table_column (
+ <if test="tableId != null and tableId != ''">table_id,</if>
+ <if test="columnName != null and columnName != ''">column_name,</if>
+ <if test="columnComment != null and columnComment != ''">column_comment,</if>
+ <if test="columnType != null and columnType != ''">column_type,</if>
+ <if test="javaType != null and javaType != ''">java_type,</if>
+ <if test="javaField != null and javaField != ''">java_field,</if>
+ <if test="isPk != null and isPk != ''">is_pk,</if>
+ <if test="isIncrement != null and isIncrement != ''">is_increment,</if>
+ <if test="isRequired != null and isRequired != ''">is_required,</if>
+ <if test="isInsert != null and isInsert != ''">is_insert,</if>
+ <if test="isEdit != null and isEdit != ''">is_edit,</if>
+ <if test="isList != null and isList != ''">is_list,</if>
+ <if test="isQuery != null and isQuery != ''">is_query,</if>
+ <if test="queryType != null and queryType != ''">query_type,</if>
+ <if test="htmlType != null and htmlType != ''">html_type,</if>
+ <if test="dictType != null and dictType != ''">dict_type,</if>
+ <if test="sort != null">sort,</if>
+ <if test="createBy != null and createBy != ''">create_by,</if>
+ create_time
+ )values(
+ <if test="tableId != null and tableId != ''">#{tableId},</if>
+ <if test="columnName != null and columnName != ''">#{columnName},</if>
+ <if test="columnComment != null and columnComment != ''">#{columnComment},</if>
+ <if test="columnType != null and columnType != ''">#{columnType},</if>
+ <if test="javaType != null and javaType != ''">#{javaType},</if>
+ <if test="javaField != null and javaField != ''">#{javaField},</if>
+ <if test="isPk != null and isPk != ''">#{isPk},</if>
+ <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
+ <if test="isRequired != null and isRequired != ''">#{isRequired},</if>
+ <if test="isInsert != null and isInsert != ''">#{isInsert},</if>
+ <if test="isEdit != null and isEdit != ''">#{isEdit},</if>
+ <if test="isList != null and isList != ''">#{isList},</if>
+ <if test="isQuery != null and isQuery != ''">#{isQuery},</if>
+ <if test="queryType != null and queryType != ''">#{queryType},</if>
+ <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
+ <if test="dictType != null and dictType != ''">#{dictType},</if>
+ <if test="sort != null">#{sort},</if>
+ <if test="createBy != null and createBy != ''">#{createBy},</if>
+ sysdate()
+ )
+ </insert>
+
+ <update id="updateGenTableColumn" parameterType="GenTableColumn">
+ update gen_table_column
+ <set>
+ column_comment = #{columnComment},
+ java_type = #{javaType},
+ java_field = #{javaField},
+ is_insert = #{isInsert},
+ is_edit = #{isEdit},
+ is_list = #{isList},
+ is_query = #{isQuery},
+ is_required = #{isRequired},
+ query_type = #{queryType},
+ html_type = #{htmlType},
+ dict_type = #{dictType},
+ sort = #{sort},
+ update_by = #{updateBy},
+ update_time = sysdate()
+ </set>
+ where column_id = #{columnId}
+ </update>
+
+ <delete id="deleteGenTableColumnByIds" parameterType="Long">
+ delete from gen_table_column where table_id in
+ <foreach collection="array" item="tableId" open="(" separator="," close=")">
+ #{tableId}
+ </foreach>
+ </delete>
+
+</mapper>
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml b/ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml
new file mode 100644
index 0000000..25e64f8
--- /dev/null
+++ b/ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.project.tool.gen.mapper.GenTableMapper">
+
+ <resultMap type="GenTable" id="GenTableResult">
+ <id property="tableId" column="table_id" />
+ <result property="tableName" column="table_name" />
+ <result property="tableComment" column="table_comment" />
+ <result property="className" column="class_name" />
+ <result property="tplCategory" column="tpl_category" />
+ <result property="packageName" column="package_name" />
+ <result property="moduleName" column="module_name" />
+ <result property="businessName" column="business_name" />
+ <result property="functionName" column="function_name" />
+ <result property="functionAuthor" column="function_author" />
+ <result property="options" column="options" />
+ <result property="createBy" column="create_by" />
+ <result property="createTime" column="create_time" />
+ <result property="updateBy" column="update_by" />
+ <result property="updateTime" column="update_time" />
+ <result property="remark" column="remark" />
+ <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
+ </resultMap>
+
+ <resultMap type="GenTableColumn" id="GenTableColumnResult">
+ <id property="columnId" column="column_id" />
+ <result property="tableId" column="table_id" />
+ <result property="columnName" column="column_name" />
+ <result property="columnComment" column="column_comment" />
+ <result property="columnType" column="column_type" />
+ <result property="javaType" column="java_type" />
+ <result property="javaField" column="java_field" />
+ <result property="isPk" column="is_pk" />
+ <result property="isIncrement" column="is_increment" />
+ <result property="isRequired" column="is_required" />
+ <result property="isInsert" column="is_insert" />
+ <result property="isEdit" column="is_edit" />
+ <result property="isList" column="is_list" />
+ <result property="isQuery" column="is_query" />
+ <result property="queryType" column="query_type" />
+ <result property="htmlType" column="html_type" />
+ <result property="dictType" column="dict_type" />
+ <result property="sort" column="sort" />
+ <result property="createBy" column="create_by" />
+ <result property="createTime" column="create_time" />
+ <result property="updateBy" column="update_by" />
+ <result property="updateTime" column="update_time" />
+ </resultMap>
+
+ <sql id="selectGenTableVo">
+ select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table
+ </sql>
+
+ <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
+ <include refid="selectGenTableVo"/>
+ <where>
+ <if test="tableName != null and tableName != ''">
+ AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
+ </if>
+ <if test="tableComment != null and tableComment != ''">
+ AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
+ </if>
+<!-- <if test="beginTime != null and beginTime != ''">寮�濮嬫椂闂存绱� -->
+<!-- AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d') -->
+<!-- </if> -->
+<!-- <if test="endTime != null and endTime != ''">缁撴潫鏃堕棿妫�绱� -->
+<!-- AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') -->
+<!-- </if> -->
+ </where>
+ </select>
+
+ <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
+ select table_name, table_comment, create_time, update_time from information_schema.tables
+ where table_schema = (select database())
+ AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
+ AND table_name NOT IN (select table_name from gen_table)
+ <if test="tableName != null and tableName != ''">
+ AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
+ </if>
+ <if test="tableComment != null and tableComment != ''">
+ AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
+ </if>
+ <if test="beginTime != null and beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
+ </if>
+ <if test="endTime != null and endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
+ </if>
+ </select>
+
+ <select id="selectDbTableListByNames" resultMap="GenTableResult">
+ select table_name, table_comment, create_time, update_time from information_schema.tables
+ where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
+ and table_name in
+ <foreach collection="array" item="name" open="(" separator="," close=")">
+ #{name}
+ </foreach>
+ </select>
+
+ <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
+ select table_name, table_comment, create_time, update_time from information_schema.tables
+ where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
+ and table_name = #{tableName}
+ </select>
+
+ <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
+ SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
+ c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
+ FROM gen_table t
+ LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+ where t.table_id = #{tableId}
+ </select>
+
+ <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
+ SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
+ c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
+ FROM gen_table t
+ LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+ where t.table_name = #{tableName}
+ </select>
+
+ <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
+ insert into gen_table (
+ <if test="tableName != null">table_name,</if>
+ <if test="tableComment != null and tableComment != ''">table_comment,</if>
+ <if test="className != null and className != ''">class_name,</if>
+ <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
+ <if test="packageName != null and packageName != ''">package_name,</if>
+ <if test="moduleName != null and moduleName != ''">module_name,</if>
+ <if test="businessName != null and businessName != ''">business_name,</if>
+ <if test="functionName != null and functionName != ''">function_name,</if>
+ <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
+ <if test="remark != null and remark != ''">remark,</if>
+ <if test="createBy != null and createBy != ''">create_by,</if>
+ create_time
+ )values(
+ <if test="tableName != null">#{tableName},</if>
+ <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
+ <if test="className != null and className != ''">#{className},</if>
+ <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
+ <if test="packageName != null and packageName != ''">#{packageName},</if>
+ <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
+ <if test="businessName != null and businessName != ''">#{businessName},</if>
+ <if test="functionName != null and functionName != ''">#{functionName},</if>
+ <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
+ <if test="remark != null and remark != ''">#{remark},</if>
+ <if test="createBy != null and createBy != ''">#{createBy},</if>
+ sysdate()
+ )
+ </insert>
+
+ <update id="updateGenTable" parameterType="GenTable">
+ update gen_table
+ <set>
+ <if test="tableName != null">table_name = #{tableName},</if>
+ <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
+ <if test="className != null and className != ''">class_name = #{className},</if>
+ <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
+ <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
+ <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
+ <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
+ <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
+ <if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
+ <if test="options != null and options != ''">options = #{options},</if>
+ <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ <if test="remark != null">remark = #{remark},</if>
+ update_time = sysdate()
+ </set>
+ where table_id = #{tableId}
+ </update>
+
+ <delete id="deleteGenTableByIds" parameterType="Long">
+ delete from gen_table where table_id in
+ <foreach collection="array" item="tableId" open="(" separator="," close=")">
+ #{tableId}
+ </foreach>
+ </delete>
+
+</mapper>
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/vm/java/controller.java.vm b/ruoyi/src/main/resources/vm/java/controller.java.vm
new file mode 100644
index 0000000..cd6f9be
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/java/controller.java.vm
@@ -0,0 +1,103 @@
+package ${packageName}.controller;
+
+import java.util.List;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import ${packageName}.domain.${ClassName};
+import ${packageName}.service.I${ClassName}Service;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.page.TableDataInfo;
+
+/**
+ * ${functionName}Controller
+ *
+ * @author ${author}
+ * @date ${datetime}
+ */
+@RestController
+@RequestMapping("/${moduleName}/${businessName}")
+public class ${ClassName}Controller extends BaseController
+{
+ @Autowired
+ private I${ClassName}Service ${className}Service;
+
+ /**
+ * 鏌ヨ${functionName}鍒楄〃
+ */
+ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(${ClassName} ${className})
+ {
+ startPage();
+ List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
+ return getDataTable(list);
+ }
+
+ /**
+ * 瀵煎嚭${functionName}鍒楄〃
+ */
+ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
+ @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
+ @GetMapping("/export")
+ public AjaxResult export(${ClassName} ${className})
+ {
+ List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
+ ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
+ return util.exportExcel(list, "${businessName}");
+ }
+
+ /**
+ * 鑾峰彇${functionName}璇︾粏淇℃伅
+ */
+ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
+ @GetMapping(value = "/{${pkColumn.javaField}}")
+ public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
+ {
+ return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
+ }
+
+ /**
+ * 鏂板${functionName}
+ */
+ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
+ @Log(title = "${functionName}", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody ${ClassName} ${className})
+ {
+ return toAjax(${className}Service.insert${ClassName}(${className}));
+ }
+
+ /**
+ * 淇敼${functionName}
+ */
+ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
+ @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody ${ClassName} ${className})
+ {
+ return toAjax(${className}Service.update${ClassName}(${className}));
+ }
+
+ /**
+ * 鍒犻櫎${functionName}
+ */
+ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
+ @Log(title = "${functionName}", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{${pkColumn.javaField}s}")
+ public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
+ {
+ return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
+ }
+}
diff --git a/ruoyi/src/main/resources/vm/java/domain.java.vm b/ruoyi/src/main/resources/vm/java/domain.java.vm
new file mode 100644
index 0000000..ee49071
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/java/domain.java.vm
@@ -0,0 +1,76 @@
+package ${packageName}.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import com.ruoyi.framework.web.domain.BaseEntity;
+#foreach ($import in $importList)
+import ${import};
+#end
+
+/**
+ * ${functionName}瀵硅薄 ${tableName}
+ *
+ * @author ${author}
+ * @date ${datetime}
+ */
+#set($Entity="BaseEntity")
+public class ${ClassName} extends ${Entity}
+{
+ private static final long serialVersionUID = 1L;
+
+#foreach ($column in $columns)
+#if(!$table.isSuperColumn($column.javaField))
+ /** $column.columnComment */
+#if($column.list)
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#if($parentheseIndex != -1)
+ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+#elseif($column.javaType == 'Date')
+ @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
+#else
+ @Excel(name = "${comment}")
+#end
+#end
+ private $column.javaType $column.javaField;
+
+#end
+#end
+#foreach ($column in $columns)
+#if(!$table.isSuperColumn($column.javaField))
+#if($column.javaField.substring(1,2).matches("[A-Z]"))
+#set($AttrName=$column.javaField)
+#else
+#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+#end
+ public void set${AttrName}($column.javaType $column.javaField)
+ {
+ this.$column.javaField = $column.javaField;
+ }
+
+ public $column.javaType get${AttrName}()
+ {
+ return $column.javaField;
+ }
+#end
+#end
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+#foreach ($column in $columns)
+#if($column.javaField.substring(1,2).matches("[A-Z]"))
+#set($AttrName=$column.javaField)
+#else
+#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+#end
+ .append("${column.javaField}", get${AttrName}())
+#end
+ .toString();
+ }
+}
diff --git a/ruoyi/src/main/resources/vm/java/mapper.java.vm b/ruoyi/src/main/resources/vm/java/mapper.java.vm
new file mode 100644
index 0000000..9297d0e
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/java/mapper.java.vm
@@ -0,0 +1,61 @@
+package ${packageName}.mapper;
+
+import ${packageName}.domain.${ClassName};
+import java.util.List;
+
+/**
+ * ${functionName}Mapper鎺ュ彛
+ *
+ * @author ${author}
+ * @date ${datetime}
+ */
+public interface ${ClassName}Mapper
+{
+ /**
+ * 鏌ヨ${functionName}
+ *
+ * @param ${pkColumn.javaField} ${functionName}ID
+ * @return ${functionName}
+ */
+ public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
+
+ /**
+ * 鏌ヨ${functionName}鍒楄〃
+ *
+ * @param ${className} ${functionName}
+ * @return ${functionName}闆嗗悎
+ */
+ public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
+
+ /**
+ * 鏂板${functionName}
+ *
+ * @param ${className} ${functionName}
+ * @return 缁撴灉
+ */
+ public int insert${ClassName}(${ClassName} ${className});
+
+ /**
+ * 淇敼${functionName}
+ *
+ * @param ${className} ${functionName}
+ * @return 缁撴灉
+ */
+ public int update${ClassName}(${ClassName} ${className});
+
+ /**
+ * 鍒犻櫎${functionName}
+ *
+ * @param ${pkColumn.javaField} ${functionName}ID
+ * @return 缁撴灉
+ */
+ public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
+
+ /**
+ * 鎵归噺鍒犻櫎${functionName}
+ *
+ * @param ${pkColumn.javaField}s 闇�瑕佸垹闄ょ殑鏁版嵁ID
+ * @return 缁撴灉
+ */
+ public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
+}
diff --git a/ruoyi/src/main/resources/vm/java/service.java.vm b/ruoyi/src/main/resources/vm/java/service.java.vm
new file mode 100644
index 0000000..27b0ebd
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/java/service.java.vm
@@ -0,0 +1,61 @@
+package ${packageName}.service;
+
+import ${packageName}.domain.${ClassName};
+import java.util.List;
+
+/**
+ * ${functionName}Service鎺ュ彛
+ *
+ * @author ${author}
+ * @date ${datetime}
+ */
+public interface I${ClassName}Service
+{
+ /**
+ * 鏌ヨ${functionName}
+ *
+ * @param ${pkColumn.javaField} ${functionName}ID
+ * @return ${functionName}
+ */
+ public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
+
+ /**
+ * 鏌ヨ${functionName}鍒楄〃
+ *
+ * @param ${className} ${functionName}
+ * @return ${functionName}闆嗗悎
+ */
+ public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
+
+ /**
+ * 鏂板${functionName}
+ *
+ * @param ${className} ${functionName}
+ * @return 缁撴灉
+ */
+ public int insert${ClassName}(${ClassName} ${className});
+
+ /**
+ * 淇敼${functionName}
+ *
+ * @param ${className} ${functionName}
+ * @return 缁撴灉
+ */
+ public int update${ClassName}(${ClassName} ${className});
+
+ /**
+ * 鎵归噺鍒犻櫎${functionName}
+ *
+ * @param ${pkColumn.javaField}s 闇�瑕佸垹闄ょ殑${functionName}ID
+ * @return 缁撴灉
+ */
+ public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
+
+ /**
+ * 鍒犻櫎${functionName}淇℃伅
+ *
+ * @param ${pkColumn.javaField} ${functionName}ID
+ * @return 缁撴灉
+ */
+ public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
+}
diff --git a/ruoyi/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi/src/main/resources/vm/java/serviceImpl.java.vm
new file mode 100644
index 0000000..05a3de8
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/java/serviceImpl.java.vm
@@ -0,0 +1,109 @@
+package ${packageName}.service.impl;
+
+import java.util.List;
+#foreach ($column in $columns)
+#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
+import com.ruoyi.common.utils.DateUtils;
+#break
+#end
+#end
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import ${packageName}.mapper.${ClassName}Mapper;
+import ${packageName}.domain.${ClassName};
+import ${packageName}.service.I${ClassName}Service;
+
+/**
+ * ${functionName}Service涓氬姟灞傚鐞�
+ *
+ * @author ${author}
+ * @date ${datetime}
+ */
+@Service
+public class ${ClassName}ServiceImpl implements I${ClassName}Service
+{
+ @Autowired
+ private ${ClassName}Mapper ${className}Mapper;
+
+ /**
+ * 鏌ヨ${functionName}
+ *
+ * @param ${pkColumn.javaField} ${functionName}ID
+ * @return ${functionName}
+ */
+ @Override
+ public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
+ {
+ return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField});
+ }
+
+ /**
+ * 鏌ヨ${functionName}鍒楄〃
+ *
+ * @param ${className} ${functionName}
+ * @return ${functionName}
+ */
+ @Override
+ public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
+ {
+ return ${className}Mapper.select${ClassName}List(${className});
+ }
+
+ /**
+ * 鏂板${functionName}
+ *
+ * @param ${className} ${functionName}
+ * @return 缁撴灉
+ */
+ @Override
+ public int insert${ClassName}(${ClassName} ${className})
+ {
+#foreach ($column in $columns)
+#if($column.javaField == 'createTime')
+ ${className}.setCreateTime(DateUtils.getNowDate());
+#end
+#end
+ return ${className}Mapper.insert${ClassName}(${className});
+ }
+
+ /**
+ * 淇敼${functionName}
+ *
+ * @param ${className} ${functionName}
+ * @return 缁撴灉
+ */
+ @Override
+ public int update${ClassName}(${ClassName} ${className})
+ {
+#foreach ($column in $columns)
+#if($column.javaField == 'updateTime')
+ ${className}.setUpdateTime(DateUtils.getNowDate());
+#end
+#end
+ return ${className}Mapper.update${ClassName}(${className});
+ }
+
+ /**
+ * 鎵归噺鍒犻櫎${functionName}
+ *
+ * @param ${pkColumn.javaField}s 闇�瑕佸垹闄ょ殑${functionName}ID
+ * @return 缁撴灉
+ */
+ @Override
+ public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
+ {
+ return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s);
+ }
+
+ /**
+ * 鍒犻櫎${functionName}淇℃伅
+ *
+ * @param ${pkColumn.javaField} ${functionName}ID
+ * @return 缁撴灉
+ */
+ @Override
+ public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
+ {
+ return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
+ }
+}
diff --git a/ruoyi/src/main/resources/vm/js/api.js.vm b/ruoyi/src/main/resources/vm/js/api.js.vm
new file mode 100644
index 0000000..cd2403c
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/js/api.js.vm
@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 鏌ヨ${functionName}鍒楄〃
+export function list${BusinessName}(query) {
+ return request({
+ url: '/${moduleName}/${businessName}/list',
+ method: 'get',
+ params: query
+ })
+}
+
+// 鏌ヨ${functionName}璇︾粏
+export function get${BusinessName}(${pkColumn.javaField}) {
+ return request({
+ url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
+ method: 'get'
+ })
+}
+
+// 鏂板${functionName}
+export function add${BusinessName}(data) {
+ return request({
+ url: '/${moduleName}/${businessName}',
+ method: 'post',
+ data: data
+ })
+}
+
+// 淇敼${functionName}
+export function update${BusinessName}(data) {
+ return request({
+ url: '/${moduleName}/${businessName}',
+ method: 'put',
+ data: data
+ })
+}
+
+// 鍒犻櫎${functionName}
+export function del${BusinessName}(${pkColumn.javaField}) {
+ return request({
+ url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
+ method: 'delete'
+ })
+}
+
+// 瀵煎嚭${functionName}
+export function export${BusinessName}(query) {
+ return request({
+ url: '/${moduleName}/${businessName}/export',
+ method: 'get',
+ params: query
+ })
+}
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/vm/sql/sql.vm b/ruoyi/src/main/resources/vm/sql/sql.vm
new file mode 100644
index 0000000..2b6cfdd
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/sql/sql.vm
@@ -0,0 +1,22 @@
+-- 鑿滃崟 SQL
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('${functionName}', '3', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '${permissionPrefix}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}鑿滃崟');
+
+-- 鎸夐挳鐖惰彍鍗旾D
+SELECT @parentId := LAST_INSERT_ID();
+
+-- 鎸夐挳 SQL
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('${functionName}鏌ヨ', @parentId, '1', '#', '', 1, 'F', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('${functionName}鏂板', @parentId, '2', '#', '', 1, 'F', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('${functionName}淇敼', @parentId, '3', '#', '', 1, 'F', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('${functionName}鍒犻櫎', @parentId, '4', '#', '', 1, 'F', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('${functionName}瀵煎嚭', @parentId, '5', '#', '', 1, 'F', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/vm/vue/index.vue.vm b/ruoyi/src/main/resources/vm/vue/index.vue.vm
new file mode 100644
index 0000000..a2dbed5
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/vue/index.vue.vm
@@ -0,0 +1,440 @@
+<template>
+ <div class="app-container">
+ <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
+#foreach($column in $columns)
+#if($column.query)
+#set($dictType=$column.dictType)
+#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#if($column.htmlType == "input")
+ <el-form-item label="${comment}" prop="${column.javaField}">
+ <el-input
+ v-model="queryParams.${column.javaField}"
+ placeholder="璇疯緭鍏�${comment}"
+ clearable
+ size="small"
+ @keyup.enter.native="handleQuery"
+ />
+ </el-form-item>
+#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
+ <el-form-item label="${comment}" prop="${column.javaField}">
+ <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable size="small">
+ <el-option
+ v-for="dict in ${column.javaField}Options"
+ :key="dict.dictValue"
+ :label="dict.dictLabel"
+ :value="dict.dictValue"
+ />
+ </el-select>
+ </el-form-item>
+#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
+ <el-form-item label="${comment}" prop="${column.javaField}">
+ <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable size="small">
+ <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" />
+ </el-select>
+ </el-form-item>
+#elseif($column.htmlType == "datetime")
+ <el-form-item label="${comment}" prop="${column.javaField}">
+ <el-date-picker clearable size="small" style="width: 200px"
+ v-model="queryParams.${column.javaField}"
+ type="date"
+ value-format="yyyy-MM-dd"
+ placeholder="閫夋嫨${comment}">
+ </el-date-picker>
+ </el-form-item>
+ <el-form-item>
+#end
+#end
+#end
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
+
+ <el-row :gutter="10" class="mb8">
+ <el-col :span="1.5">
+ <el-button
+ type="primary"
+ icon="el-icon-plus"
+ size="mini"
+ @click="handleAdd"
+ v-hasPermi="['${moduleName}:${businessName}:add']"
+ >鏂板</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="success"
+ icon="el-icon-edit"
+ size="mini"
+ :disabled="single"
+ @click="handleUpdate"
+ v-hasPermi="['${moduleName}:${businessName}:edit']"
+ >淇敼</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="danger"
+ icon="el-icon-delete"
+ size="mini"
+ :disabled="multiple"
+ @click="handleDelete"
+ v-hasPermi="['${moduleName}:${businessName}:remove']"
+ >鍒犻櫎</el-button>
+ </el-col>
+ <el-col :span="1.5">
+ <el-button
+ type="warning"
+ icon="el-icon-download"
+ size="mini"
+ @click="handleExport"
+ v-hasPermi="['${moduleName}:${businessName}:export']"
+ >瀵煎嚭</el-button>
+ </el-col>
+ </el-row>
+
+ <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="55" align="center" />
+#foreach($column in $columns)
+#set($javaField=$column.javaField)
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#if($column.pk)
+ <el-table-column label="${comment}" align="center" prop="${javaField}" />
+#elseif($column.list && $column.htmlType == "datetime")
+ <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
+ <template slot-scope="scope">
+ <span>{{ parseTime(scope.row.${javaField}) }}</span>
+ </template>
+ </el-table-column>
+#elseif($column.list && "" != $column.dictType)
+ <el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
+#elseif($column.list && "" != $javaField)
+ <el-table-column label="${comment}" align="center" prop="${javaField}" />
+#end
+#end
+ <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
+ <template slot-scope="scope">
+ <el-button
+ size="mini"
+ type="text"
+ icon="el-icon-edit"
+ @click="handleUpdate(scope.row)"
+ v-hasPermi="['${moduleName}:${businessName}:edit']"
+ >淇敼</el-button>
+ <el-button
+ size="mini"
+ type="text"
+ icon="el-icon-delete"
+ @click="handleDelete(scope.row)"
+ v-hasPermi="['${moduleName}:${businessName}:remove']"
+ >鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <pagination
+ v-show="total>0"
+ :total="total"
+ :page.sync="queryParams.pageNum"
+ :limit.sync="queryParams.pageSize"
+ @pagination="getList"
+ />
+
+ <!-- 娣诲姞鎴栦慨鏀�${functionName}瀵硅瘽妗� -->
+ <el-dialog :title="title" :visible.sync="open" width="500px">
+ <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+#foreach($column in $columns)
+#set($field=$column.javaField)
+#if($column.insert && !$column.pk)
+#if(($column.usableColumn) || (!$column.superColumn))
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#set($dictType=$column.dictType)
+#if($column.htmlType == "input")
+ <el-form-item label="${comment}" prop="${field}">
+ <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" />
+ </el-form-item>
+#elseif($column.htmlType == "select" && "" != $dictType)
+ <el-form-item label="${comment}">
+ <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}">
+ <el-option
+ v-for="dict in ${field}Options"
+ :key="dict.dictValue"
+ :label="dict.dictLabel"
+ :value="dict.dictValue"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+#elseif($column.htmlType == "select" && $dictType)
+ <el-form-item label="${comment}">
+ <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}">
+ <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" />
+ </el-select>
+ </el-form-item>
+#elseif($column.htmlType == "radio" && "" != $dictType)
+ <el-form-item label="${comment}">
+ <el-radio-group v-model="form.${field}">
+ <el-radio
+ v-for="dict in ${field}Options"
+ :key="dict.dictValue"
+ :label="dict.dictValue"
+ >{{dict.dictLabel}}</el-radio>
+ </el-radio-group>
+ </el-form-item>
+#elseif($column.htmlType == "radio" && $dictType)
+ <el-form-item label="${comment}">
+ <el-radio-group v-model="form.${field}">
+ <el-radio label="1">璇烽�夋嫨瀛楀吀鐢熸垚</el-radio>
+ </el-radio-group>
+ </el-form-item>
+#elseif($column.htmlType == "datetime")
+ <el-form-item label="${comment}" prop="${field}">
+ <el-date-picker clearable size="small" style="width: 200px"
+ v-model="form.${field}"
+ type="date"
+ value-format="yyyy-MM-dd"
+ placeholder="閫夋嫨${comment}">
+ </el-date-picker>
+ </el-form-item>
+#elseif($column.htmlType == "textarea")
+ <el-form-item label="${comment}" prop="${field}">
+ <el-input v-model="form.${field}" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" />
+ </el-form-item>
+ </el-form>
+#end
+#end
+#end
+#end
+ </el-form>
+ <div slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
+ <el-button @click="cancel">鍙� 娑�</el-button>
+ </div>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
+
+export default {
+ data() {
+ return {
+ // 閬僵灞�
+ loading: true,
+ // 閫変腑鏁扮粍
+ ids: [],
+ // 闈炲崟涓鐢�
+ single: true,
+ // 闈炲涓鐢�
+ multiple: true,
+ // 鎬绘潯鏁�
+ total: 0,
+ // ${functionName}琛ㄦ牸鏁版嵁
+ ${businessName}List: [],
+ // 寮瑰嚭灞傛爣棰�
+ title: "",
+ // 鏄惁鏄剧ず寮瑰嚭灞�
+ open: false,
+#foreach ($column in $columns)
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#if(${column.dictType} != '')
+ // $comment瀛楀吀
+ ${column.javaField}Options: []#if($velocityCount != $columns.size()),#end
+
+#end
+#end
+ // 鏌ヨ鍙傛暟
+ queryParams: {
+ pageNum: 1,
+ pageSize: 10,
+#foreach ($column in $columns)
+#if($column.query)
+ $column.javaField: undefined#if($velocityCount != $columns.size()),#end
+
+#end
+#end
+ },
+ // 琛ㄥ崟鍙傛暟
+ form: {},
+ // 琛ㄥ崟鏍¢獙
+ rules: {
+#foreach ($column in $columns)
+#if($column.required)
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#set($comment=$column.columnComment)
+ studentName: [
+ { required: true, message: "$comment涓嶈兘涓虹┖", trigger: "blur" }
+ ]#if($velocityCount != $columns.size()),#end
+#end
+#end
+ }
+ };
+ },
+ created() {
+ this.getList();
+#foreach ($column in $columns)
+#if(${column.dictType} != '')
+ this.getDicts("${column.dictType}").then(response => {
+ this.${column.javaField}Options = response.data;
+ });
+#end
+#end
+ },
+ methods: {
+ /** 鏌ヨ${functionName}鍒楄〃 */
+ getList() {
+ this.loading = true;
+ list${BusinessName}(this.queryParams).then(response => {
+ this.${businessName}List = response.rows;
+ this.total = response.total;
+ this.loading = false;
+ });
+ },
+#foreach ($column in $columns)
+#if(${column.dictType} != '')
+#set($parentheseIndex=$column.columnComment.indexOf("锛�"))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+ // $comment瀛楀吀缈昏瘧
+ ${column.javaField}Format(row, column) {
+ return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField});
+ },
+#end
+#end
+ // 鍙栨秷鎸夐挳
+ cancel() {
+ this.open = false;
+ this.reset();
+ },
+ // 琛ㄥ崟閲嶇疆
+ reset() {
+ this.form = {
+#foreach ($column in $columns)
+#if($column.htmlType == "radio")
+ $column.javaField: "0"#if($velocityCount != $columns.size()),#end
+
+#else
+ $column.javaField: undefined#if($velocityCount != $columns.size()),#end
+
+#end
+#end
+ };
+ this.resetForm("form");
+ },
+ /** 鎼滅储鎸夐挳鎿嶄綔 */
+ handleQuery() {
+ this.queryParams.pageNum = 1;
+ this.getList();
+ },
+ /** 閲嶇疆鎸夐挳鎿嶄綔 */
+ resetQuery() {
+ this.resetForm("queryForm");
+ this.handleQuery();
+ },
+ // 澶氶�夋閫変腑鏁版嵁
+ handleSelectionChange(selection) {
+ this.ids = selection.map(item => item.${pkColumn.javaField})
+ this.single = selection.length!=1
+ this.multiple = !selection.length
+ },
+ /** 鏂板鎸夐挳鎿嶄綔 */
+ handleAdd() {
+ this.reset();
+ this.open = true;
+ this.title = "娣诲姞${functionName}";
+ },
+ /** 淇敼鎸夐挳鎿嶄綔 */
+ handleUpdate(row) {
+ this.reset();
+ const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
+ get${BusinessName}(${pkColumn.javaField}).then(response => {
+ this.form = response.data;
+ this.open = true;
+ this.title = "淇敼${functionName}";
+ });
+ },
+ /** 鎻愪氦鎸夐挳 */
+ submitForm: function() {
+ this.#[[$]]#refs["form"].validate(valid => {
+ if (valid) {
+ if (this.form.${pkColumn.javaField} != undefined) {
+ update${BusinessName}(this.form).then(response => {
+ if (response.code === 200) {
+ this.msgSuccess("淇敼鎴愬姛");
+ this.open = false;
+ this.getList();
+ } else {
+ this.msgError(response.msg);
+ }
+ });
+ } else {
+ add${BusinessName}(this.form).then(response => {
+ if (response.code === 200) {
+ this.msgSuccess("鏂板鎴愬姛");
+ this.open = false;
+ this.getList();
+ } else {
+ this.msgError(response.msg);
+ }
+ });
+ }
+ }
+ });
+ },
+ /** 鍒犻櫎鎸夐挳鎿嶄綔 */
+ handleDelete(row) {
+ const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
+ this.$confirm('鏄惁纭鍒犻櫎${functionName}缂栧彿涓�"' + ${pkColumn.javaField}s + '"鐨勬暟鎹」?', "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ }).then(function() {
+ return del${BusinessName}(${pkColumn.javaField}s);
+ }).then(() => {
+ this.getList();
+ this.msgSuccess("鍒犻櫎鎴愬姛");
+ }).catch(function() {});
+ },
+ /** 瀵煎嚭鎸夐挳鎿嶄綔 */
+ handleExport() {
+ const queryParams = this.queryParams;
+ this.$confirm('鏄惁纭瀵煎嚭鎵�鏈�${functionName}鏁版嵁椤�?', "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ }).then(function() {
+ return export${BusinessName}(queryParams);
+ }).then(response => {
+ this.download(response.msg);
+ }).catch(function() {});
+ }
+ }
+};
+</script>
\ No newline at end of file
diff --git a/ruoyi/src/main/resources/vm/xml/mapper.xml.vm b/ruoyi/src/main/resources/vm/xml/mapper.xml.vm
new file mode 100644
index 0000000..ef9d682
--- /dev/null
+++ b/ruoyi/src/main/resources/vm/xml/mapper.xml.vm
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
+
+ <resultMap type="${ClassName}" id="${ClassName}Result">
+#foreach ($column in $columns)
+ <result property="${column.javaField}" column="${column.columnName}" />
+#end
+ </resultMap>
+
+ <sql id="select${ClassName}Vo">
+ select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
+ </sql>
+
+ <select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
+ <include refid="select${ClassName}Vo"/>
+ <where>
+#foreach($column in $columns)
+#set($queryType=$column.queryType)
+#set($javaField=$column.javaField)
+#set($javaType=$column.javaType)
+#set($columnName=$column.columnName)
+#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+#if($column.query)
+#if($column.queryType == "EQ")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
+#elseif($queryType == "NE")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
+#elseif($queryType == "GT")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
+#elseif($queryType == "GTE")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
+#elseif($queryType == "LT")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
+#elseif($queryType == "LTE")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
+#elseif($queryType == "LIKE")
+ <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
+#elseif($queryType == "BETWEEN")
+ <if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
+#end
+#end
+#end
+ </where>
+ </select>
+
+ <select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}Result">
+ <include refid="select${ClassName}Vo"/>
+ where ${pkColumn.columnName} = #{${pkColumn.javaField}}
+ </select>
+
+ <insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
+ insert into ${tableName}
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+#foreach($column in $columns)
+#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
+ <if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">$column.columnName,</if>
+#end
+#end
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+#foreach($column in $columns)
+#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
+ <if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">#{$column.javaField},</if>
+#end
+#end
+ </trim>
+ </insert>
+
+ <update id="update${ClassName}" parameterType="${ClassName}">
+ update ${tableName}
+ <trim prefix="SET" suffixOverrides=",">
+#foreach($column in $columns)
+#if($column.columnName != $pkColumn.columnName)
+ <if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
+#end
+#end
+ </trim>
+ where ${pkColumn.columnName} = #{${pkColumn.javaField}}
+ </update>
+
+ <delete id="delete${ClassName}ById" parameterType="${pkColumn.javaType}">
+ delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
+ </delete>
+
+ <delete id="delete${ClassName}ByIds" parameterType="String">
+ delete from ${tableName} where ${pkColumn.columnName} in
+ <foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
+ #{${pkColumn.javaField}}
+ </foreach>
+ </delete>
+
+</mapper>
\ No newline at end of file
--
Gitblit v1.9.3