已修改40个文件
已添加34个文件
已重命名1个文件
已删除1个文件
| | |
| | | <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> |
| | |
| | | {
|
| | | "name": "ruoyi",
|
| | | "version": "1.1.0",
|
| | | "version": "2.0.0",
|
| | | "description": "è¥ä¾ç®¡çç³»ç»",
|
| | | "author": "è¥ä¾",
|
| | | "license": "MIT",
|
| | |
| | | params: query
|
| | | })
|
| | | }
|
| | |
|
| | | // è·ååå
¸éæ©æ¡å表
|
| | | export function optionselect() {
|
| | | return request({
|
| | | url: '/system/dict/type/optionselect',
|
| | | method: 'get'
|
| | | })
|
| | | } |
| | |
| | | import request from '@/utils/request'
|
| | | import { praseStrEmpty } from "@/utils/ruoyi";
|
| | |
|
| | | // æ¥è¯¢ç¨æ·å表
|
| | | export function listUser(query) {
|
| | |
| | | // æ¥è¯¢ç¨æ·è¯¦ç»
|
| | | export function getUser(userId) {
|
| | | return request({
|
| | | url: '/system/user/' + userId,
|
| | | url: '/system/user/' + praseStrEmpty(userId),
|
| | | method: 'get'
|
| | | })
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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'
|
| | | })
|
| | | }
|
| | |
|
| | |
| | | margin-left: 20px;
|
| | | }
|
| | |
|
| | | .el-dialog {
|
| | | margin-top: 6vh !important;
|
| | | }
|
| | |
|
| | | .el-table .el-table__header-wrapper th {
|
| | | word-break: break-word;
|
| | | background-color: #f8f8f9;
|
| | |
| | | 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;
|
| | |
| | | // å
Œ
±è·¯ç±
|
| | | 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
|
| | |
| | | {
|
| | | path: 'profile',
|
| | | component: () => import('@/views/system/user/profile/index'),
|
| | | name: '个人ä¸å¿',
|
| | | name: 'Profile',
|
| | | meta: { title: '个人ä¸å¿', icon: 'user' }
|
| | | }
|
| | | ]
|
| | |
| | | {
|
| | | 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: 'ä¿®æ¹çæé
ç½®' }
|
| | | }
|
| | | ]
|
| | | }
|
| | | ]
|
| | |
|
| | |
| | | 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(),
|
| | |
| | | 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();
|
| | | }
|
| | | }
|
| | |
| | | // æ·»å æ¥æèå´
|
| | | 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;
|
| | | }
|
| | |
| | | return arg;
|
| | | });
|
| | | return flag ? str : '';
|
| | | }
|
| | |
|
| | | // 转æ¢å符串ï¼undefined,nullç转å为""
|
| | | export function praseStrEmpty(str) {
|
| | | if (!str || str == "undefined" || str == "null") {
|
| | | return "";
|
| | | }
|
| | | return str;
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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)
|
| | | }
|
| | |
| | | </template>
|
| | | <script>
|
| | | export default {
|
| | | name: "Druid",
|
| | | data() {
|
| | | return {
|
| | | src: process.env.VUE_APP_BASE_API + "/druid/index.html",
|
| | |
| | | import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor";
|
| | |
|
| | | export default {
|
| | | name: "Logininfor",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import { list, forceLogout } from "@/api/monitor/online";
|
| | |
|
| | | export default {
|
| | | name: "Online",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog";
|
| | |
|
| | | export default {
|
| | | name: "Operlog",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import { getServer } from "@/api/monitor/server";
|
| | |
|
| | | export default {
|
| | | name: "Server",
|
| | | data() {
|
| | | return {
|
| | | // å è½½å±ä¿¡æ¯
|
| | |
| | | import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig } from "@/api/system/config";
|
| | |
|
| | | export default {
|
| | | name: "Config",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
| | |
|
| | | export default {
|
| | | name: "Dept",
|
| | | components: { Treeselect },
|
| | | data() {
|
| | | return {
|
| | |
| | | import { listType, getType } from "@/api/system/dict/type";
|
| | |
|
| | | export default {
|
| | | name: "Data",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import { listType, getType, delType, addType, updateType, exportType } from "@/api/system/dict/type";
|
| | |
|
| | | export default {
|
| | | name: "Dict",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import IconSelect from "@/components/IconSelect";
|
| | |
|
| | | export default {
|
| | | name: "Menu",
|
| | | components: { Treeselect, IconSelect },
|
| | | data() {
|
| | | return {
|
| | |
| | | import Editor from '@/components/Editor';
|
| | |
|
| | | export default {
|
| | | name: "Notice",
|
| | | components: {
|
| | | Editor
|
| | | },
|
| | |
| | | import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post";
|
| | |
|
| | | export default {
|
| | | name: "Post",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
|
| | |
|
| | | export default {
|
| | | name: "Role",
|
| | | data() {
|
| | | return {
|
| | | // é®ç½©å±
|
| | |
| | | <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 {
|
| | |
| | | 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" ? "å¯ç¨" : "åç¨";
|
| | |
| | | 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;
|
| | |
| | | }
|
| | | };
|
| | | </script>
|
| | |
|
| | | <style rel="stylesheet/scss" lang="scss">
|
| | | .avatar-uploader-icon {
|
| | | font-size: 28px;
|
| | | width: 120px;
|
| | | height: 120px;
|
| | | line-height: 120px;
|
| | | text-align: center;
|
| | | }
|
| | | </style>
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <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>
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <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>
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <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="çæå¨åªä¸ªjavaå
ä¸ï¼ä¾å¦ 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="å¯ç解为åç³»ç»åï¼ä¾å¦ 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="å¯ç解为åè½è±æåï¼ä¾å¦ 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>
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <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>
|
| | |
| | | <template>
|
| | | <div class="app-container">
|
| | | 代ç çæ
|
| | | <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']"
|
| | | >çæä»£ç </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> |
| | | </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: "代ç é¢è§",
|
| | | 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();
|
| | | },
|
| | | /** çæä»£ç æä½ */
|
| | | 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> |
| | |
| | | </template>
|
| | | <script>
|
| | | export default {
|
| | | name: "Swagger",
|
| | | data() {
|
| | | return {
|
| | | src: process.env.VUE_APP_BASE_API + "/swagger-ui.html",
|
| | |
| | |
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <version>1.1</version>
|
| | | <version>2.0.0</version>
|
| | | <packaging>jar</packaging>
|
| | |
|
| | | <name>ruoyi</name>
|
| | |
| | | <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>
|
| | |
| | | <artifactId>poi-ooxml</artifactId>
|
| | | <version>${poi.version}</version>
|
| | | </dependency>
|
| | | <!--velocity代ç çæä½¿ç¨æ¨¡æ¿ -->
|
| | | <dependency>
|
| | | <groupId>org.apache.velocity</groupId>
|
| | | <artifactId>velocity</artifactId>
|
| | | <version>${velocity.version}</version>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
ÎļþÃû´Ó ruoyi/sql/ry_20191120.sql ÐÞ¸Ä |
| | |
| | | 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', 'é¢è§ä»£ç ', '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', 'çæä»£ç ', '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', '导å
¥ä»£ç ', '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', 'é¢è§ä»£ç ', '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', 'çæä»£ç ', '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_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é¨é¨
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.constant;
|
| | |
|
| | | /**
|
| | | * 代ç çæéç¨å¸¸é
|
| | | * |
| | | * @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";
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºCharset对象
|
| | | * |
| | | * @param charset å符éï¼ä¸ºç©ºåè¿åé»è®¤å符é
|
| | | * @return Charset
|
| | | */
|
| | | public static Charset charset(String charset)
|
| | | {
|
| | | return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢å符串çå符éç¼ç
|
| | | * |
| | | * @param source å符串
|
| | | * @param srcCharset æºå符éï¼é»è®¤ISO-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 æºå符éï¼é»è®¤ISO-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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºbyte<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºbyte<br>
|
| | | * 妿ç»å®çå¼ä¸º<code>null</code>ï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Byte toByte(Object value)
|
| | | {
|
| | | return toByte(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºShort<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºShort<br>
|
| | | * 妿ç»å®çå¼ä¸º<code>null</code>ï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Short toShort(Object value)
|
| | | {
|
| | | return toShort(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºNumber<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºNumber<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Number toNumber(Object value)
|
| | | {
|
| | | return toNumber(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºint<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºint<br>
|
| | | * 妿ç»å®çå¼ä¸º<code>null</code>ï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Integer toInt(Object value)
|
| | | {
|
| | | return toInt(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºIntegeræ°ç»<br>
|
| | | * |
| | | * @param str 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Integer[] toIntArray(String str)
|
| | | {
|
| | | return toIntArray(",", str);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºLongæ°ç»<br>
|
| | | * |
| | | * @param str 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Long[] toLongArray(String str)
|
| | | {
|
| | | return toLongArray(",", str);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºIntegeræ°ç»<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;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºLongæ°ç»<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;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºStringæ°ç»<br>
|
| | | * |
| | | * @param str 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static String[] toStrArray(String str)
|
| | | {
|
| | | return toStrArray(",", str);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºStringæ°ç»<br>
|
| | | * |
| | | * @param split åé符
|
| | | * @param split 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static String[] toStrArray(String split, String str)
|
| | | {
|
| | | return str.split(split);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºlong<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºlong<br>
|
| | | * 妿ç»å®çå¼ä¸º<code>null</code>ï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Long toLong(Object value)
|
| | | {
|
| | | return toLong(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºdouble<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºdouble<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Double toDouble(Object value)
|
| | | {
|
| | | return toDouble(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºFloat<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºFloat<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Float toFloat(Object value)
|
| | | {
|
| | | return toFloat(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºboolean<br>
|
| | | * Stringæ¯æçå¼ä¸ºï¼trueãfalseãyesãokãnoï¼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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºboolean<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static Boolean toBool(Object value)
|
| | | {
|
| | | return toBool(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºEnum对象<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<br>
|
| | | * |
| | | * @param clazz EnumçClass
|
| | | * @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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºEnum对象<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * |
| | | * @param clazz EnumçClass
|
| | | * @param value å¼
|
| | | * @return Enum
|
| | | */
|
| | | public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value)
|
| | | {
|
| | | return toEnum(clazz, value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºBigInteger<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºBigInteger<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<code>null</code><br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static BigInteger toBigInteger(Object value)
|
| | | {
|
| | | return toBigInteger(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºBigDecimal<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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºBigDecimal<br>
|
| | | * 妿ç»å®çå¼ä¸ºç©ºï¼æè
转æ¢å¤±è´¥ï¼è¿åé»è®¤å¼<br>
|
| | | * 转æ¢å¤±è´¥ä¸ä¼æ¥é
|
| | | * |
| | | * @param value 被转æ¢çå¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public static BigDecimal toBigDecimal(Object value)
|
| | | {
|
| | | return toBigDecimal(value, null);
|
| | | }
|
| | |
|
| | | /**
|
| | | * å°å¯¹è±¡è½¬ä¸ºå符串<br>
|
| | | * 1ãByteæ°ç»åByteBufferä¼è¢«è½¬æ¢ä¸ºå¯¹åºåç¬¦ä¸²çæ°ç» 2ã对象æ°ç»ä¼è°ç¨Arrays.toStringæ¹æ³
|
| | | * |
| | | * @param obj 对象
|
| | | * @return å符串
|
| | | */
|
| | | public static String utf8Str(Object obj)
|
| | | {
|
| | | return str(obj, CharsetKit.CHARSET_UTF_8);
|
| | | }
|
| | |
|
| | | /**
|
| | | * å°å¯¹è±¡è½¬ä¸ºå符串<br>
|
| | | * 1ãByteæ°ç»åByteBufferä¼è¢«è½¬æ¢ä¸ºå¯¹åºåç¬¦ä¸²çæ°ç» 2ã对象æ°ç»ä¼è°ç¨Arrays.toStringæ¹æ³
|
| | | * |
| | | * @param obj 对象
|
| | | * @param charsetName å符é
|
| | | * @return å符串
|
| | | */
|
| | | public static String str(Object obj, String charsetName)
|
| | | {
|
| | | return str(obj, Charset.forName(charsetName));
|
| | | }
|
| | |
|
| | | /**
|
| | | * å°å¯¹è±¡è½¬ä¸ºå符串<br>
|
| | | * 1ãByteæ°ç»åByteBufferä¼è¢«è½¬æ¢ä¸ºå¯¹åºåç¬¦ä¸²çæ°ç» 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();
|
| | | }
|
| | |
|
| | | /**
|
| | | * å°byteæ°ç»è½¬ä¸ºå符串
|
| | | * |
| | | * @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));
|
| | | }
|
| | |
|
| | | /**
|
| | | * è§£ç åèç
|
| | | * |
| | | * @param data å符串
|
| | | * @param charset å符éï¼å¦ææ¤å段为空ï¼åè§£ç çç»æåå³äºå¹³å°
|
| | | * @return è§£ç åçå符串
|
| | | */
|
| | | 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("^æ´$", "é¶å
æ´");
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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>
|
| | | * é常使ç¨ï¼format("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
|
| | | {
|
| | | // æ£å¸¸å ä½ç¬¦
|
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.config;
|
| | |
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | /**
|
| | | * 读å代ç çæç¸å
³é
ç½®
|
| | | * |
| | | * @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;
|
| | | }
|
| | | }
|
| | |
| | | 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;
|
| | |
|
| | |
| | | /** æ°æ®æé */
|
| | | private String dataScope;
|
| | |
|
| | | /** 请æ±åæ° */
|
| | | /** å¼å§æ¶é´ */
|
| | | @JsonIgnore
|
| | | private String params;
|
| | | private String beginTime;
|
| | |
|
| | | /** ç»ææ¶é´ */
|
| | | @JsonIgnore
|
| | | private String endTime;
|
| | |
|
| | | /** 请æ±åæ° */
|
| | | private Map<String, Object> params;
|
| | |
|
| | | public String getSearchValue()
|
| | | {
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | /**
|
| | | * æ ¹æ®åæ°é®åæ¥è¯¢åæ°å¼
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:config:query')")
|
| | | @GetMapping(value = "/configKey/{configKey}")
|
| | | public AjaxResult getConfigKey(@PathVariable String configKey)
|
| | | {
|
| | |
| | | /**
|
| | | * è·åé¨é¨ä¸ææ å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')")
|
| | | @GetMapping("/treeselect")
|
| | | public AjaxResult treeselect(SysDept dept)
|
| | | {
|
| | |
| | | /**
|
| | | * å 载对åºè§è²é¨é¨å表æ
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')")
|
| | | @GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
| | | public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
| | | {
|
| | |
| | | /**
|
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ®ä¿¡æ¯
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')")
|
| | | @GetMapping(value = "/dictType/{dictType}")
|
| | | public AjaxResult dictType(@PathVariable String dictType)
|
| | | {
|
| | |
| | | {
|
| | | return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·ååå
¸éæ©æ¡å表
|
| | | */
|
| | | @GetMapping("/optionselect")
|
| | | public AjaxResult optionselect()
|
| | | {
|
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
| | | return AjaxResult.success(dictTypes);
|
| | | }
|
| | | }
|
| | |
| | | /**
|
| | | * è·åèå䏿æ å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:query')")
|
| | | @GetMapping("/treeselect")
|
| | | public AjaxResult treeselect(SysMenu dept)
|
| | | {
|
| | |
| | | /**
|
| | | * å 载对åºè§è²èåå表æ
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:query')")
|
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
| | | {
|
| | |
| | | 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;
|
| | |
| | | * æ ¹æ®ç¨æ·ç¼å·è·å详ç»ä¿¡æ¯
|
| | | */
|
| | | @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;
|
| | | }
|
| | |
|
| | |
| | | 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()))
|
| | | {
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | |
|
| | | /**
|
| | | * 代ç çæ æä½å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/tool/gen")
|
| | | public class GenController extends BaseController
|
| | | {
|
| | |
|
| | | @Autowired
|
| | | private IGenTableService genTableService;
|
| | |
|
| | | @Autowired
|
| | | private IGenTableColumnService genTableColumnService;
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ä»£ç çæå表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo genList(GenTable genTable)
|
| | | {
|
| | | startPage();
|
| | | List<GenTable> list = genTableService.selectGenTableList(genTable);
|
| | | return getDataTable(list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹ä»£ç çæä¸å¡
|
| | | */
|
| | | @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 = "代ç çæ", 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();
|
| | | }
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹ä¿å代ç çæä¸å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
|
| | | @Log(title = "代ç çæ", 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 = "代ç çæ", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{tableIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] tableIds)
|
| | | {
|
| | | genTableService.deleteGenTableByIds(tableIds);
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | /**
|
| | | * é¢è§ä»£ç
|
| | | */
|
| | | @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);
|
| | | }
|
| | |
|
| | | /**
|
| | | * çæä»£ç
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
| | | @Log(title = "代ç çæ", 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);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¹éçæä»£ç
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
| | | @Log(title = "代ç çæ", 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());
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | |
|
| | | /**
|
| | | * 代ç çæä¸å¡å段表 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;
|
| | |
|
| | | /** æ¥è¯¢æ¹å¼ï¼EQçäºãNEä¸çäºãGT大äºãLTå°äºãLIKE模ç³ãBETWEENèå´ï¼ */
|
| | | private String queryType;
|
| | |
|
| | | /** æ¾ç¤ºç±»åï¼inputææ¬æ¡ãtextareaææ¬åãselect䏿æ¡ãcheckboxå¤éæ¡ãradioåéæ¡ãdatetimeæ¥ææ§ä»¶ï¼ */
|
| | | 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;
|
| | | }
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢è¡¨IDä¸å¡ä¿¡æ¯
|
| | | * |
| | | * @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);
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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));
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * é¢è§ä»£ç
|
| | | * |
| | | * @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;
|
| | | }
|
| | |
|
| | | /**
|
| | | * çæä»£ç
|
| | | * |
| | | * @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();
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¹éçæä»£ç
|
| | | * |
| | | * @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();
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢è¡¨ä¿¡æ¯å¹¶çæä»£ç
|
| | | */
|
| | | 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
|
| | | {
|
| | | // æ·»å å°zip
|
| | | 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));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置代ç çæå
¶ä»é项å¼
|
| | | * |
| | | * @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);
|
| | | }
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 éè¦å é¤çè¡¨æ°æ®ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public void deleteGenTableByIds(Long[] tableIds);
|
| | |
|
| | | /**
|
| | | * 导å
¥è¡¨ç»æ
|
| | | * |
| | | * @param tableList 导å
¥è¡¨å表
|
| | | */
|
| | | public void importGenTable(List<GenTable> tableList);
|
| | |
|
| | | /**
|
| | | * é¢è§ä»£ç
|
| | | * |
| | | * @param tableId 表ç¼å·
|
| | | * @return é¢è§æ°æ®å表
|
| | | */
|
| | | public Map<String, String> previewCode(Long tableId);
|
| | |
|
| | | /**
|
| | | * çæä»£ç
|
| | | * |
| | | * @param tableName 表åç§°
|
| | | * @return æ°æ®
|
| | | */
|
| | | public byte[] generatorCode(String tableName);
|
| | |
|
| | | /**
|
| | | * æ¹éçæä»£ç
|
| | | * |
| | | * @param tableNames 表æ°ç»
|
| | | * @return æ°æ®
|
| | | */
|
| | | public byte[] generatorCode(String[] tableNames);
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹ä¿ååæ°æ ¡éª
|
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯
|
| | | */
|
| | | public void validateEdit(GenTable genTable);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | |
|
| | | /**
|
| | | * 代ç çæå¨ å·¥å
·ç±»
|
| | | * |
| | | * @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;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 表åè½¬æ¢æJavaç±»å
|
| | | * |
| | | * @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;
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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
|
| | | {
|
| | | /**
|
| | | * åå§åvmæ¹æ³
|
| | | */
|
| | | 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);
|
| | | // åå§åVelocityå¼æï¼æå®é
ç½®Properties
|
| | | Velocity.init(p);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw new RuntimeException(e);
|
| | | }
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | | } |
| | |
| | | # åç§°
|
| | | name: RuoYi
|
| | | # çæ¬
|
| | | version: 1.1.0
|
| | | version: 2.0.0
|
| | | # çæå¹´ä»½
|
| | | copyrightYear: 2019
|
| | | # å®ä¾æ¼ç¤ºå¼å
³
|
| | |
| | | # æé¤é¾æ¥ï¼å¤ä¸ªç¨éå·åéï¼
|
| | | excludes: /system/notice/*
|
| | | # å¹é
龿¥
|
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
| | | urlPatterns: /system/*,/monitor/*,/tool/*
|
| | | |
| | | # 代ç çæ
|
| | | gen: |
| | | # ä½è
|
| | | author: ruoyi
|
| | | # é»è®¤çæå
è·¯å¾ system éæ¹æèªå·±ç模ååç§° å¦ system monitor tool
|
| | | packageName: com.ruoyi.project.system
|
| | | # èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯true
|
| | | autoRemovePre: false
|
| | | # 表åç¼ï¼çæç±»åä¸ä¼å
å«è¡¨åç¼ï¼å¤ä¸ªç¨éå·åéï¼
|
| | | tablePrefix: sys_ |
| | |
| | | <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>
|
| | |
| | | <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>
|
| | |
| | | <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>
|
| | |
| | | <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>
|
| | |
| | | <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}
|
| | |
| | | <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) ))
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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));
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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});
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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});
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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
|
| | | })
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | -- èå 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}èå');
|
| | |
|
| | | -- æé®ç¶èåID
|
| | | 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', ''); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |