diff --git a/README.md b/README.md index a859b1d9..fd9c93bf 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,10 @@ https://www.oschina.net/project/top_cn_2019#ruoyi + + + + diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index d6f08df0..ceb331e2 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 80a6cfab..4b45a355 100644 --- a/ruoyi-ui/src/api/system/dict/type.js +++ b/ruoyi-ui/src/api/system/dict/type.js @@ -51,3 +51,11 @@ export function exportType(query) { 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 3b1170e7..45c09ebb 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 listUser(query) { // 查询用户详细 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 00000000..21b9b832 --- /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' + }) +} + +// 修改代码生成信息 +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 + }) +} +// 预览生成代码 +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 9e0cdc37..77307e57 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 526d755c..47ddd61d 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -26,17 +26,6 @@ import Layout from '@/layout' // 公共路由 export const constantRoutes = [ - { - path: '/redirect', - component: Layout, - hidden: true, - children: [ - { - path: '/redirect/:path*', - component: () => import('@/views/redirect') - } - ] - }, { path: '/login', component: () => import('@/views/login'), @@ -74,7 +63,7 @@ export const constantRoutes = [ { path: 'profile', component: () => import('@/views/system/user/profile/index'), - name: '个人中心', + name: 'Profile', meta: { title: '个人中心', icon: 'user' } } ] @@ -87,10 +76,23 @@ export const constantRoutes = [ { 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 db97dcc5..602fdd6c 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -9,21 +9,21 @@ const baseURL = process.env.VUE_APP_BASE_API 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 @@ export function parseTime(time, pattern) { 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 resetForm(refName) { // 添加日期范围 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 @@ export function sprintf(str) { 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 00000000..3a868146 --- /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) + }) +} +/** + * 解析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 }) + // //从response的headers中获取filename, 后端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 6ab35b26..9e8e1e75 100644 --- a/ruoyi-ui/src/views/monitor/druid/index.vue +++ b/ruoyi-ui/src/views/monitor/druid/index.vue @@ -5,6 +5,7 @@ diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue index b84fac5c..354f7e05 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 735c3b9b..bcefdb87 100644 --- a/ruoyi-ui/src/views/system/dept/index.vue +++ b/ruoyi-ui/src/views/system/dept/index.vue @@ -143,6 +143,7 @@ import Treeselect from "@riophae/vue-treeselect"; 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 649e302f..dcb8cb70 100644 --- a/ruoyi-ui/src/views/system/dict/data.vue +++ b/ruoyi-ui/src/views/system/dict/data.vue @@ -159,6 +159,7 @@ import { listData, getData, delData, addData, updateData, exportData } from "@/a 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 2dd211f4..44ca109b 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 eda8d21d..b1a5cdb1 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -179,6 +179,7 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css"; 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 caedc503..404bec3e 100644 --- a/ruoyi-ui/src/views/system/notice/index.vue +++ b/ruoyi-ui/src/views/system/notice/index.vue @@ -176,6 +176,7 @@ import { listNotice, getNotice, delNotice, addNotice, updateNotice, exportNotice 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 5c4f28fd..ffd3f42b 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 05379c22..497fed64 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 menuTreeselect, roleMenuTreeselect } from "@/api/system/m 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 760036b9..00c36457 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -290,12 +290,11 @@ - - 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 00000000..f3e87172 --- /dev/null +++ b/ruoyi-ui/src/views/tool/gen/basicInfoForm.vue @@ -0,0 +1,61 @@ + + 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 00000000..3897aa46 --- /dev/null +++ b/ruoyi-ui/src/views/tool/gen/editTable.vue @@ -0,0 +1,204 @@ + + 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 00000000..7b9a32a6 --- /dev/null +++ b/ruoyi-ui/src/views/tool/gen/genInfoForm.vue @@ -0,0 +1,154 @@ + + 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 00000000..e4418708 --- /dev/null +++ b/ruoyi-ui/src/views/tool/gen/importTable.vue @@ -0,0 +1,114 @@ + + + diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue index c0c06736..0c159a0f 100644 --- a/ruoyi-ui/src/views/tool/gen/index.vue +++ b/ruoyi-ui/src/views/tool/gen/index.vue @@ -1,5 +1,287 @@ \ No newline at end of file + + + \ 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 00484e28..624b59a2 100644 --- a/ruoyi-ui/src/views/tool/swagger/index.vue +++ b/ruoyi-ui/src/views/tool/swagger/index.vue @@ -5,6 +5,7 @@ \ 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 00000000..ef9d682b --- /dev/null +++ b/ruoyi/src/main/resources/vm/xml/mapper.xml.vm @@ -0,0 +1,95 @@ + + + + + +#foreach ($column in $columns) + +#end + + + + select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName} + + + + + + + + insert into ${tableName} + +#foreach($column in $columns) +#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) + $column.columnName, +#end +#end + + +#foreach($column in $columns) +#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) + #{$column.javaField}, +#end +#end + + + + + update ${tableName} + +#foreach($column in $columns) +#if($column.columnName != $pkColumn.columnName) + $column.columnName = #{$column.javaField}, +#end +#end + + where ${pkColumn.columnName} = #{${pkColumn.javaField}} + + + + delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}} + + + + delete from ${tableName} where ${pkColumn.columnName} in + + #{${pkColumn.javaField}} + + + + \ No newline at end of file