♻️ Refactoring code. pigx-codegen 适配最新V5 UI
This commit is contained in:
1 parent
3c047a59de
commit
e6838a19e1
93 files changed
+3219
-2736
No files matched your search
@@ -0,0 +1,25 @@
|
||||
# 数据源
|
||||
spring:
|
||||
redis:
|
||||
host: pigx-redis
|
||||
database: 9 #避免和微服务 PIGX 冲突
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://pigx-mysql:3306/pigxx_boot_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
|
||||
web:
|
||||
resources:
|
||||
static-locations: classpath:/static/,classpath:/views/
|
||||
|
||||
# 租户表维护
|
||||
pigx:
|
||||
tenant:
|
||||
column: tenant_id
|
||||
tables:
|
||||
- gen_datasource_conf
|
||||
- gen_form_conf
|
||||
- gen_template
|
||||
- gen_group
|
||||
@@ -1,70 +0,0 @@
|
||||
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
|
||||
mainPath=com.pig4cloud.pigx
|
||||
#\u5305\u540D
|
||||
package=com.pig4cloud.pigx
|
||||
moduleName=generator
|
||||
#\u4F5C\u8005
|
||||
author=pigx code generator
|
||||
#\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00)
|
||||
tablePrefix=tb_
|
||||
# hidden columns in Swagger Models
|
||||
hiddenColumn=tenant_id
|
||||
|
||||
#MYSQL \u7C7B\u578B\u8F6C\u6362
|
||||
tinyint=Integer
|
||||
smallint=Integer
|
||||
mediumint=Integer
|
||||
int=Integer
|
||||
integer=Integer
|
||||
bigint=Long
|
||||
float=Float
|
||||
double=Double
|
||||
decimal=BigDecimal
|
||||
bit=Boolean
|
||||
char=String
|
||||
varchar=String
|
||||
tinytext=String
|
||||
text=String
|
||||
mediumtext=String
|
||||
longtext=String
|
||||
date=LocalDateTime
|
||||
datetime=LocalDateTime
|
||||
timestamp=LocalDateTime
|
||||
|
||||
# PG \u7C7B\u578B\u8F6C\u5316\u89C4\u5219
|
||||
int2=Integer
|
||||
int4=Integer
|
||||
int8=Long
|
||||
bpchar=String
|
||||
float4=Float
|
||||
float8=Float
|
||||
|
||||
#ORACLE \u7279\u6B8A\u7C7B\u578B\u8F6C\u6362\u89C4\u5219
|
||||
INT=Integer
|
||||
INTEGER=Integer
|
||||
LONG=LONG
|
||||
NUMBER=Integer
|
||||
BINARY_INTEGER=Integer
|
||||
FLOAT=Float
|
||||
BINARY_FLOAT=Float
|
||||
DOUBLE=Double
|
||||
BINARY_DOUBLE=Double
|
||||
DECIMAL=BigDecimal
|
||||
CHAR=String
|
||||
VARCHAR=String
|
||||
VARCHAR2=String
|
||||
NVARCHAR=String
|
||||
NVARCHAR2=String
|
||||
DATE=LocalDateTime
|
||||
DATETIME=LocalDateTime
|
||||
TIMESTAMP=LocalDateTime
|
||||
CLOB=String
|
||||
BLOB=String
|
||||
|
||||
# MSSQL \u7C7B\u578B
|
||||
nvarchar=String
|
||||
nchar=String
|
||||
datetime2=LocalDateTime
|
||||
|
||||
#\u8FBE\u68A6
|
||||
BIGINT=Long
|
||||
@@ -80,7 +80,7 @@
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<root level="debug">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
var MAGIC_EDITOR_CONFIG = {
|
||||
title: '接口低代码设计平台',
|
||||
theme: 'dark',
|
||||
defaultExpand: true,
|
||||
checkUpdate: false,
|
||||
jdbcDrivers: ['com.mysql.cj.jdbc.Driver', 'com.mysql.jdbc.Driver', 'oracle.jdbc.driver.OracleDriver', 'org.postgresql.Driver', 'com.microsoft.sqlserver.jdbc.SQLServerDriver'],
|
||||
blockClose: true, // 是否阻止离开页面
|
||||
autoSave: true,
|
||||
decorationTimeout: 10000,
|
||||
logMaxRows: Infinity,
|
||||
editorFontFamily: 'JetBrainsMono, Consolas, "Courier New",monospace, 微软雅黑',
|
||||
editorFontSize: 14,
|
||||
fontLigatures: true,
|
||||
header: {
|
||||
skin: true, document: true, repo: true, qqGroup: true
|
||||
},
|
||||
request: {
|
||||
beforeSend: function (config) {
|
||||
let tenant_id = new URL(window.location.href).searchParams.get("tenant_id");
|
||||
config.headers["TENANT-ID"] = tenant_id === null ? 1 : tenant_id
|
||||
|
||||
let access_token = new URL(window.location.href).searchParams.get("access_token");
|
||||
if (access_token !== null) {
|
||||
config.headers["Authorization"] = `Bearer ${access_token}`
|
||||
}
|
||||
return config;
|
||||
}, onError: function (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
},
|
||||
response: {
|
||||
onSuccess: function (resp) {
|
||||
if (resp.data.code === -1) {
|
||||
window.location.href = '/'
|
||||
}
|
||||
return resp;
|
||||
}, onError: function (err) {
|
||||
console.log('请求失败', err)
|
||||
return Promise.reject(err)
|
||||
},
|
||||
},
|
||||
themes: {
|
||||
editor: {
|
||||
base: 'vs-dark',
|
||||
rules: [{foreground: 'A9B7C6'}, {
|
||||
token: 'keywords',
|
||||
foreground: 'CC7832',
|
||||
fontStyle: 'bold'
|
||||
}, {token: 'keyword', foreground: 'CC7832', fontStyle: 'bold'}, {
|
||||
token: 'number',
|
||||
foreground: '6897BB'
|
||||
}, {token: 'string', foreground: '6A8759', fontStyle: 'bold'}, {
|
||||
token: 'string.sql',
|
||||
foreground: '6A8759'
|
||||
}, {token: 'tag.sql', foreground: 'E8BF6A'}, {
|
||||
token: 'attribute.name.sql',
|
||||
foreground: 'BABABA'
|
||||
}, {token: 'attribute.value.sql', foreground: '6A8759'}, {
|
||||
token: 'predefined.sql',
|
||||
foreground: 'A9B7C6',
|
||||
fontStyle: 'italic'
|
||||
}, {token: 'predefined.magicscript', foreground: 'A9B7C6', fontStyle: 'italic'}, {
|
||||
token: 'key',
|
||||
foreground: '9876AA'
|
||||
}, {token: 'string.key.json', foreground: '9876AA'}, {
|
||||
token: 'string.value.json',
|
||||
foreground: '6A8759'
|
||||
}, {token: 'keyword.json', foreground: '6897BB'}, {
|
||||
token: 'operator.sql',
|
||||
foreground: 'CC7832',
|
||||
fontStyle: 'bold'
|
||||
}, {token: 'string.invalid', foreground: '008000', background: 'FFCCCC'}, {
|
||||
token: 'string.escape.invalid',
|
||||
foreground: '008000',
|
||||
background: 'FFCCCC'
|
||||
}, {token: 'string.escape', foreground: '000080', fontStyle: 'bold'}, {
|
||||
token: 'comment',
|
||||
foreground: '808080',
|
||||
fontStyle: 'italic'
|
||||
}, {token: 'comment.doc', foreground: '629755', fontStyle: 'italic'}, {
|
||||
token: 'comment.todo',
|
||||
foreground: 'A8C023',
|
||||
fontStyle: 'italic'
|
||||
}, {token: 'string.escape', foreground: 'CC7832'}],
|
||||
colors: {
|
||||
'editor.background': '#2B2B2B', 'editorLineNumber.foreground': '#999999', //行号的颜色
|
||||
'editorGutter.background': '#313335', //行号背景色
|
||||
'editor.lineHighlightBackground': '#323232', //光标所在行的颜色
|
||||
'dropdown.background': '#3C3F41', //右键菜单
|
||||
'dropdown.foreground': '#BBBBBB', //右键菜单文字颜色
|
||||
'list.activeSelectionBackground': '#4B6EAF', //右键菜单悬浮背景色
|
||||
'list.activeSelectionForeground': '#FFFFFF', //右键菜单悬浮文字颜色
|
||||
'editorSuggestWidget.selectedBackground': '#113A5C' //代码提示选中行的背景色
|
||||
}
|
||||
}, styles: {
|
||||
'main-background-color': '#3C3F41', // 主要背景色
|
||||
'main-border-color': '#323232', // 主要边框色
|
||||
'main-color': '#bbb', // 主要文字颜色
|
||||
'main-selected-background-color': '#323232', // 主要选中背景色
|
||||
'main-hover-background-color': '#353739', // 主要悬浮背景色
|
||||
'main-hover-icon-background-color': '#4C5052', // 主要悬浮图标背景色
|
||||
'main-selected-color': '#fff', // 主要选中文字颜色
|
||||
'main-icon-color': '#AFB1B3', // 主要图标颜色
|
||||
|
||||
'header-title-color': '#bbb', // 顶部名字颜色
|
||||
'header-version-color': '#999', // 顶部版本号颜色
|
||||
'header-default-color': '#AFB1B3', // 顶部其它文字颜色
|
||||
|
||||
'empty-background-color': '#282828', // 中间空的背景颜色
|
||||
'empty-key-color': '#489DF6', // 中间空的快捷键文字颜色
|
||||
'empty-color': '#A0A0A0', // 中间空的文字颜色
|
||||
|
||||
'button-hover-background-color': '#365880', // 按钮悬浮背景颜色
|
||||
'button-hover-border-color': '#43688C', // 按钮悬浮边框颜色
|
||||
'button-background-color': '#4C5052', // 按钮背景颜色
|
||||
'button-border-color': '#5E6060', // 按钮边框颜色
|
||||
'button-disabled-color': '#5a5a5a', // 按钮禁用时的颜色
|
||||
|
||||
'navbar-body-background-color': '#3C3F41', // 导航条内容背景颜色
|
||||
'navbar-body-border-color': '#555555', //导航条内边框颜色
|
||||
'resource-label-color': '#bbb', // 资源树形菜单label颜色
|
||||
'resource-span-color': '#787878', // 资源树形菜单span颜色
|
||||
|
||||
'tree-hover-background-color': '#0d293e', // 树形菜单悬浮背景色
|
||||
'tree-icon-color': '#aeb9c0', // 树形菜单图标颜色
|
||||
|
||||
'table-border-color': '#646464', // 表格边框颜色
|
||||
|
||||
'input-border-color': '#646464', // input边框颜色
|
||||
'input-foucs-color': '#3D6185', // input focus边框颜色
|
||||
'input-background-color': '#45494A', // input背景颜色
|
||||
|
||||
'select-background-color': '#3C3F41', // select背景颜色
|
||||
'select-hover-background-color': '#3C3F41', // select悬浮背景色
|
||||
'select-option-background-color': '#3C3F41', // select选项背景色
|
||||
'select-option-hover-background-color': '#4B6EAF', // select选项悬浮背景色
|
||||
'select-option-border-color': '#808080', // select选项边框色
|
||||
|
||||
// 数据类型颜色
|
||||
'data-type-default-color': '#a9b7c6',
|
||||
'data-type-string-color': '#6a8759',
|
||||
'data-type-integer-color': '#6897bb',
|
||||
'data-type-byte-color': '#6897bb',
|
||||
'data-type-long-color': '#6897bb',
|
||||
'data-type-float-color': '#6897bb',
|
||||
'data-type-double-color': '#6897bb',
|
||||
'data-type-short-color': '#6897bb',
|
||||
'data-type-number-color': '#6897bb',
|
||||
'data-type-boolean-color': '#cc7832',
|
||||
'data-type-class-color': '#9876aa',
|
||||
'data-type-key-color': '#FF8E8E',
|
||||
|
||||
|
||||
'run-log-background-color': '#2b2b2b', // 运行日志背景颜色
|
||||
// 日志级别颜色
|
||||
'log-level-info': '#ABC023',
|
||||
'log-level-error': '#CC666E',
|
||||
'log-level-debug': '#299999',
|
||||
'log-level-warn': 'unset',
|
||||
'log-level-trace': '#5394EC',
|
||||
'log-color-cyan': '#009191',
|
||||
'log-color-link': '#287BDE',
|
||||
|
||||
'todo-color': '#A8C023',
|
||||
|
||||
'debug-line-background-color': '#2D6099', // 调试时,断点行背景颜色
|
||||
'breakpoints-background-color': '#C75450', // 断点圆圈背景颜色
|
||||
'breakpoint-line-background-color': '#3a2323', // 断点所在行的背景颜色
|
||||
|
||||
'select-inputable-background-color': '#45494a', // select输入框背景颜色
|
||||
'select-inputable-border': 'transparent',
|
||||
|
||||
'tab-selected-background-color': '#4E5254', // tab 选中时的背景颜色
|
||||
|
||||
'message-em-color': '#68dd9a', // 消息 em 颜色
|
||||
|
||||
'checkbox-background-color': '#43494A',
|
||||
'checkbox-border-color': '#6B6B6B',
|
||||
'checkbox-text-color': '#bbb',
|
||||
'checkbox-selected-background-color': '#43494A',
|
||||
'checkbox-selected-border-color': '#6B6B6B',
|
||||
|
||||
'toolbox-list-label-color': '#bbb',
|
||||
'toolbox-list-span-color': '#787878',
|
||||
'toolbox-border-color': '#323232',
|
||||
'toolbox-list-hover-background': '#0D293E',
|
||||
'toolbox-border-right-color': '#555555',
|
||||
'footer-border-color': '#323232',
|
||||
'tab-bar-border-color': '#323232',
|
||||
'dialog-border-color': '#282828',
|
||||
'dialog-shadow-color': '#151515',
|
||||
'table-col-border-color': '#333638',
|
||||
'table-row-border-color': '#333638',
|
||||
'table-hover-background': '#4B6EAF',
|
||||
'debug-line-background': '#2D6099',
|
||||
'breakpoints-background': '#C75450',
|
||||
'breakpoint-line-background': '#3a2323',
|
||||
'table-even-background': '#414547',
|
||||
'button-disabled-background': '#5A5A5A',
|
||||
'toolbox-list-header-icon-color': '#AFB1B3',
|
||||
'log-error-color': '#CC666E',
|
||||
'text-string-color': '#6A8759',
|
||||
'text-number-color': '#6897BB',
|
||||
'text-boolean-color': '#CC7832',
|
||||
'text-property-color': '#9876aa',
|
||||
'text-key-color': '#9876aa',
|
||||
'suggest-hover-background': '#113A5C',
|
||||
'suggest-hover-color': '#fff',
|
||||
'statusbar-em-color': '#68dd9a',
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
magic-api:
|
||||
prod: true #生产模式鉴权
|
||||
show-url: false
|
||||
banner: false
|
||||
web: /api/designer
|
||||
editor-config: classpath:./magic/magic-editor-config.js
|
||||
sql-column-case: camel
|
||||
@@ -1,11 +0,0 @@
|
||||
<?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.pig4cloud.pigx.codegen.mapper.GenDynamicMapper">
|
||||
|
||||
<!-- 动态SQL查询 -->
|
||||
<select id="dynamicQuerySql" parameterType="String" resultType="java.util.LinkedHashMap">
|
||||
${value}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Executable → Regular
+16
-10
@@ -21,15 +21,21 @@
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="${package}.${moduleName}.mapper.${className}Mapper">
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GenFieldTypeMapper">
|
||||
|
||||
<resultMap id="${classname}Map" type="${package}.${moduleName}.entity.${className}">
|
||||
#foreach($column in $columns)
|
||||
#if($column.lowerAttrName==$pk.lowerAttrName)
|
||||
<id property="${pk.lowerAttrName}" column="${pk.columnName}"/>
|
||||
#else
|
||||
<result property="${column.lowerAttrName}" column="${column.columnName}"/>
|
||||
#end
|
||||
#end
|
||||
</resultMap>
|
||||
<resultMap id="fieldTypeMap" type="com.pig4cloud.pigx.codegen.entity.GenFieldType">
|
||||
<id property="id" column="id"/>
|
||||
<result property="columnType" column="column_type"/>
|
||||
<result property="attrType" column="attr_type"/>
|
||||
<result property="packageName" column="package_name"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getPackageByTableId" resultType="String">
|
||||
select t1.package_name
|
||||
from gen_field_type t1,
|
||||
gen_table_column t2
|
||||
where t1.attr_type = t2.attr_type
|
||||
and t2.ds_name = #{dsName} and t2.table_name = #{tableName}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.pig4cloud.pigx.codegen.mapper.GenGroupMapper">
|
||||
|
||||
<resultMap id="genGroupMap" type="com.pig4cloud.pigx.codegen.util.vo.GroupVo">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="groupName" column="group_name"/>
|
||||
<result property="groupDesc" column="group_desc"/>
|
||||
<collection property="templateList" ofType="com.pig4cloud.pigx.codegen.entity.GenTemplateEntity"
|
||||
select="com.pig4cloud.pigx.codegen.mapper.GenTemplateMapper.listTemplateById" column="group_id">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getGroupVoById" resultMap="genGroupMap">
|
||||
SELECT
|
||||
g.id as group_id ,
|
||||
g.group_name ,
|
||||
g.group_desc
|
||||
FROM
|
||||
gen_group g
|
||||
WHERE g.id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~
|
||||
~ Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without
|
||||
~ modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ Redistributions of source code must retain the above copyright notice,
|
||||
~ this list of conditions and the following disclaimer.
|
||||
~ Redistributions in binary form must reproduce the above copyright
|
||||
~ notice, this list of conditions and the following disclaimer in the
|
||||
~ documentation and/or other materials provided with the distribution.
|
||||
~ Neither the name of the pig4cloud.com developer nor the names of its
|
||||
~ contributors may be used to endorse or promote products derived from
|
||||
~ this software without specific prior written permission.
|
||||
~ Author: lengleng (wangiegie@gmail.com)
|
||||
~
|
||||
-->
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.codegen.mapper.GenTableMapper">
|
||||
|
||||
<resultMap id="tableMap" type="com.pig4cloud.pigx.codegen.entity.GenTable">
|
||||
<id property="id" column="id"/>
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result property="className" column="class_name"/>
|
||||
<result property="tableComment" column="table_comment"/>
|
||||
<result property="author" column="author"/>
|
||||
<result property="email" column="email"/>
|
||||
<result property="packageName" column="package_name"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="generatorType" column="generator_type"/>
|
||||
<result property="backendPath" column="backend_path"/>
|
||||
<result property="frontendPath" column="frontend_path"/>
|
||||
<result property="moduleName" column="module_name"/>
|
||||
<result property="functionName" column="function_name"/>
|
||||
<result property="formLayout" column="form_layout"/>
|
||||
<result property="datasourceId" column="datasource_id"/>
|
||||
<result property="baseclassId" column="baseclass_id"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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.pig4cloud.pigx.codegen.mapper.GenTemplateGroupMapper">
|
||||
|
||||
<resultMap id="genTemplateGroupMap" type="com.pig4cloud.pigx.codegen.entity.GenTemplateGroupEntity">
|
||||
<id property="groupId" column="group_id"/>
|
||||
<id property="templateId" column="template_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.pig4cloud.pigx.codegen.mapper.GenTemplateMapper">
|
||||
|
||||
<resultMap id="genTemplateMap" type="com.pig4cloud.pigx.codegen.entity.GenTemplateEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="templateName" column="template_name"/>
|
||||
<result property="generatorPath" column="generator_path"/>
|
||||
<result property="templateDesc" column="template_desc"/>
|
||||
<result property="templateCode" column="template_code"/>
|
||||
</resultMap>
|
||||
<select id="listTemplateById" resultType="com.pig4cloud.pigx.codegen.entity.GenTemplateEntity">
|
||||
SELECT
|
||||
t.id as id,t.template_name,t.generator_path,t.template_desc,t.template_code
|
||||
FROM gen_template t ,
|
||||
gen_template_group tg
|
||||
WHERE t.id = tg.template_id
|
||||
AND t.del_flag = '0'
|
||||
and tg.group_id = #{groupId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -22,7 +22,6 @@
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="queryColumn">
|
||||
SELECT
|
||||
column_name columnName,
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/${pathName}" )
|
||||
@Tag(description = "${pathName}", name = "${comments}管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ${className}Controller {
|
||||
|
||||
private final ${className}Service ${classname}Service;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param ${classname} ${comments}
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_view')" )
|
||||
public R get${className}Page(Page page, ${className} ${classname}) {
|
||||
return R.ok(${classname}Service.page(page, Wrappers.query(${classname})));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询${comments}
|
||||
* @param ${pk.lowerAttrName} id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{${pk.lowerAttrName}}" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_view')" )
|
||||
public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return R.ok(${classname}Service.getById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${comments}
|
||||
* @param ${classname} ${comments}
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增${comments}", description = "新增${comments}")
|
||||
@SysLog("新增${comments}" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" )
|
||||
public R save(@RequestBody ${className} ${classname}) {
|
||||
return R.ok(${classname}Service.save(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${comments}
|
||||
* @param ${classname} ${comments}
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改${comments}", description = "修改${comments}")
|
||||
@SysLog("修改${comments}" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" )
|
||||
public R updateById(@RequestBody ${className} ${classname}) {
|
||||
return R.ok(${classname}Service.updateById(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除${comments}
|
||||
* @param ${pk.lowerAttrName} id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除${comments}", description = "通过id删除${comments}")
|
||||
@SysLog("通过id删除${comments}" )
|
||||
@DeleteMapping("/{${pk.lowerAttrName}}" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" )
|
||||
public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return R.ok(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param ${classname} 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_export')" )
|
||||
public List<${className}> export(${className} ${classname}) {
|
||||
return ${classname}Service.list(Wrappers.query(${classname}));
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "${comments}")
|
||||
public class ${className} extends Model<${className}> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
#if($column.columnName == $pk.columnName)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
#end
|
||||
#if($column.columnName == 'del_flag')
|
||||
@TableLogic
|
||||
#end
|
||||
@Schema(description="$column.comments"#if($column.hidden),hidden=$column.hidden#end)
|
||||
private $column.attrType $column.lowerAttrName;
|
||||
|
||||
#end
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.mapper;
|
||||
|
||||
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${className}Mapper extends PigxBaseMapper<${className}> {
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${className}Service extends IService<${className}> {
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
package ${package}.${moduleName}.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.mapper.${className}Mapper;
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service {
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
import request from '@/router/axios'
|
||||
|
||||
export function fetchList(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
export const tableOption = {
|
||||
"border": true,
|
||||
"index": true,
|
||||
"indexLabel": "序号",
|
||||
"stripe": true,
|
||||
"menuAlign": "center",
|
||||
"align": "center",
|
||||
"searchMenuSpan": 6,
|
||||
"column": [
|
||||
#foreach ($column in $columns)
|
||||
{
|
||||
"type": "input",
|
||||
"label": "$column.comments",
|
||||
"prop": "$column.lowerAttrName",
|
||||
"span": 12
|
||||
}#if($foreach.hasNext),#end
|
||||
#end
|
||||
]
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
<!--
|
||||
- Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions are met:
|
||||
-
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
- this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
- notice, this list of conditions and the following disclaimer in the
|
||||
- documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of the pig4cloud.com developer nor the names of its
|
||||
- contributors may be used to endorse or promote products derived from
|
||||
- this software without specific prior written permission.
|
||||
- Author: lengleng (wangiegie@gmail.com)
|
||||
-->
|
||||
<template>
|
||||
<div class="execution">
|
||||
<basic-container>
|
||||
<avue-crud
|
||||
ref="crud"
|
||||
:page.sync="page"
|
||||
:data="tableData"
|
||||
:permission="permissionList"
|
||||
:table-loading="tableLoading"
|
||||
:option="tableOption"
|
||||
@on-load="getList"
|
||||
@search-change="searchChange"
|
||||
@refresh-change="refreshChange"
|
||||
@size-change="sizeChange"
|
||||
@current-change="currentChange"
|
||||
@row-update="handleUpdate"
|
||||
@row-save="handleSave"
|
||||
@row-del="handleDel">
|
||||
<template slot="menuLeft">
|
||||
<el-button
|
||||
v-if="permissions.${moduleName}_${pathName}_export"
|
||||
class="filter-item"
|
||||
plain
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-download"
|
||||
@click="exportExcel">导出
|
||||
</el-button>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</basic-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList, addObj, putObj, delObj } from '@/api/${pathName}'
|
||||
import { tableOption } from '@/const/crud/${pathName}'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: '${pathName}',
|
||||
data() {
|
||||
return {
|
||||
searchForm: {},
|
||||
tableData: [],
|
||||
page: {
|
||||
total: 0, // 总页数
|
||||
currentPage: 1, // 当前页数
|
||||
pageSize: 20 // 每页显示多少条
|
||||
},
|
||||
tableLoading: false,
|
||||
tableOption: tableOption
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permissions']),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.vaildData(this.permissions.${moduleName}_${pathName}_add, false),
|
||||
delBtn: this.vaildData(this.permissions.${moduleName}_${pathName}_del, false),
|
||||
editBtn: this.vaildData(this.permissions.${moduleName}_${pathName}_edit, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 列表查询
|
||||
getList(page, params) {
|
||||
this.tableLoading = true
|
||||
fetchList(Object.assign({
|
||||
current: page.currentPage,
|
||||
size: page.pageSize
|
||||
}, params, this.searchForm)).then(response => {
|
||||
this.tableData = response.data.data.records
|
||||
this.page.total = response.data.data.total
|
||||
this.tableLoading = false
|
||||
}).catch(() => {
|
||||
this.tableLoading = false
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
handleDel: function(row, index) {
|
||||
this.$confirm('是否确认删除ID为' + row.$pk.lowerAttrName, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
return delObj(row.$pk.lowerAttrName)
|
||||
}).then(data => {
|
||||
this.$message.success('删除成功')
|
||||
this.getList(this.page)
|
||||
})
|
||||
},
|
||||
// 更新
|
||||
handleUpdate: function(row, index, done, loading) {
|
||||
putObj(row).then(data => {
|
||||
this.$message.success('修改成功')
|
||||
done()
|
||||
this.getList(this.page)
|
||||
}).catch(() => {
|
||||
loading()
|
||||
})
|
||||
},
|
||||
// 保存
|
||||
handleSave: function(row, done, loading) {
|
||||
addObj(row).then(data => {
|
||||
this.$message.success('添加成功')
|
||||
done()
|
||||
this.getList(this.page)
|
||||
}).catch(() => {
|
||||
loading()
|
||||
})
|
||||
},
|
||||
// 每页条数改变事件
|
||||
sizeChange(pageSize) {
|
||||
this.page.pageSize = pageSize
|
||||
},
|
||||
// 当前页发生改变事件
|
||||
currentChange(current) {
|
||||
this.page.currentPage = current
|
||||
},
|
||||
// 查询事件
|
||||
searchChange(form, done) {
|
||||
this.searchForm = form
|
||||
this.page.currentPage = 1
|
||||
this.getList(this.page, form)
|
||||
done()
|
||||
},
|
||||
// 刷新事件
|
||||
refreshChange() {
|
||||
this.getList(this.page)
|
||||
},
|
||||
// 导出excel
|
||||
exportExcel() {
|
||||
this.downBlobFile('/${moduleName}/${pathName}/export', this.searchForm, '${pathName}.xlsx')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"project": {
|
||||
"packageName": "com.pig4cloud.pigx",
|
||||
"version": "1.0.0",
|
||||
"backendPath": "pigx",
|
||||
"frontendPath": "pigx-ui"
|
||||
},
|
||||
"developer": {
|
||||
"author": "pig",
|
||||
"email": "sw@mail.pigx.vip"
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
import request from '@/router/axios'
|
||||
|
||||
export function fetchList(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
<el-form-item label="${column.comments}" prop="${column.lowerAttrName}">
|
||||
<el-input v-model="dataForm.${column.lowerAttrName}" placeholder="${column.comments}"></el-input>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()" v-if="canSubmit">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getObj, addObj, putObj } from '@/api/${pathName}'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
canSubmit: false,
|
||||
dataForm: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == $pk.columnName)
|
||||
${column.lowerAttrName}: 0,
|
||||
#else
|
||||
${column.lowerAttrName}: ''#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
dataRule: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
${column.lowerAttrName}: [
|
||||
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.${pk.lowerAttrName} = id || 0
|
||||
this.visible = true
|
||||
this.canSubmit = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.${pk.lowerAttrName}) {
|
||||
getObj(this.dataForm.${pk.lowerAttrName}).then(response => {
|
||||
this.dataForm = response.data.data
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
#[[this.$refs['dataForm'].validate((valid) => {]]#
|
||||
if (valid) {
|
||||
this.canSubmit = false
|
||||
if (this.dataForm.${pk.lowerAttrName}) {
|
||||
putObj(this.dataForm).then(data => {
|
||||
this.$notify.success('修改成功')
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
this.canSubmit = true
|
||||
})
|
||||
} else {
|
||||
addObj(this.dataForm).then(data => {
|
||||
this.$notify.success('添加成功')
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
this.canSubmit = true
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,132 +0,0 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<basic-container>
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_add" icon="el-icon-plus" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_export" icon="el-icon-download" type="primary" plain @click="exportExcel()">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="avue-crud">
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading">
|
||||
#foreach($column in $columns)
|
||||
<el-table-column
|
||||
prop="${column.lowerAttrName}"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="${column.comments}">
|
||||
</el-table-column>
|
||||
#end
|
||||
<el-table-column
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_edit" type="text" size="small" icon="el-icon-edit" @click="addOrUpdateHandle(scope.row.${pk.lowerAttrName})">修改</el-button>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_del" type="text" size="small" icon="el-icon-delete" @click="deleteHandle(scope.row.${pk.lowerAttrName})">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="avue-crud__pagination">
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
background
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
</div>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></table-form>
|
||||
</basic-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList, delObj } from '@/api/${pathName}'
|
||||
import TableForm from './${pathName}-form'
|
||||
import { mapGetters } from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
searchForm: {},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
TableForm
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permissions'])
|
||||
},
|
||||
created() {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true
|
||||
fetchList(Object.assign({
|
||||
current: this.pageIndex,
|
||||
size: this.pageSize
|
||||
})).then(response => {
|
||||
this.dataList = response.data.data.records
|
||||
this.totalPage = response.data.data.total
|
||||
})
|
||||
this.dataListLoading = false
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle(val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle(val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle(id) {
|
||||
this.addOrUpdateVisible = true
|
||||
#[[this.$nextTick(() => {]]#
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle(id) {
|
||||
this.$confirm('是否确认删除ID为' + id, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
return delObj(id)
|
||||
}).then(data => {
|
||||
this.$message.success('删除成功')
|
||||
this.getDataList()
|
||||
})
|
||||
},
|
||||
// 导出excel
|
||||
exportExcel() {
|
||||
this.downBlobFile('/${moduleName}/${pathName}/export', this.searchForm, '${pathName}.xlsx')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,6 +0,0 @@
|
||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||
import response;
|
||||
import log;
|
||||
|
||||
var dbId = new DefaultIdentifierGenerator().nextId(null)
|
||||
return db.${dsName}.table("${tableName}").primary("$pk.columnName", dbId).save(body)
|
||||
@@ -1,21 +0,0 @@
|
||||
import response;
|
||||
|
||||
// 判断是否逻辑删除
|
||||
var logicFlag = false
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == "del_flag")
|
||||
logicFlag = true
|
||||
#end
|
||||
#end
|
||||
|
||||
var result;
|
||||
if(logicFlag){
|
||||
result = db.${dsName}.table("${tableName}").primary("$pk.columnName").update({
|
||||
"$pk.columnName": id,
|
||||
del_flag: 1
|
||||
})
|
||||
}else{
|
||||
result = db.${dsName}.table("${tableName}").where().eq("$pk.columnName", id).delete()
|
||||
}
|
||||
|
||||
return response.json(result)
|
||||
@@ -1,4 +0,0 @@
|
||||
import response;
|
||||
|
||||
// 执行DSL 分页输出结果
|
||||
return response.text("$pk.lowerAttrName")
|
||||
@@ -1,24 +0,0 @@
|
||||
import request;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import response;
|
||||
|
||||
// 基础查询语句
|
||||
var queryDsl = db.${dsName}.table("${tableName}")
|
||||
|
||||
// 判断是否逻辑删除
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == "del_flag")
|
||||
queryDsl = queryDsl.where().eq("del_flag", 0)
|
||||
#end
|
||||
#end
|
||||
|
||||
// 模糊查询
|
||||
if (query != null) {
|
||||
var jsonObj = JSONUtil.parseObj(query)
|
||||
for (key in jsonObj.keySet()) {
|
||||
queryDsl.like(key, "%" + jsonObj.get(key) + "%")
|
||||
}
|
||||
}
|
||||
|
||||
// 执行DSL 分页输出结果
|
||||
return response.json(queryDsl.page())
|
||||
@@ -1,5 +0,0 @@
|
||||
import response;
|
||||
|
||||
var data = db.${dsName}.table("${tableName}").primary("$pk.columnName").update(body)
|
||||
|
||||
return response.json(data)
|
||||
@@ -1,25 +0,0 @@
|
||||
-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点-1 , 默认租户 1
|
||||
#set($menuId=${dateTool.getSystemTime()})
|
||||
|
||||
-- 菜单SQL
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `path`, `permission`, `menu_type`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${menuId}, '-1', '/${moduleName}/${pathName}/index', '', '0', 'icon-bangzhushouji', '0', null , '8', null , '${comments}管理', 1);
|
||||
|
||||
-- 按钮父菜单ID
|
||||
set @parentId = @@identity;
|
||||
|
||||
-- 菜单对应按钮SQL
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,1)},${menuId}, '${moduleName}_${pathName}_view', '1', null, '1', '0', null, '0', null, '${comments}查看', 1);
|
||||
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,2)},${menuId}, '${moduleName}_${pathName}_add', '1', null, '1', '0', null, '1', null, '${comments}新增', 1);
|
||||
|
||||
insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,3)},${menuId}, '${moduleName}_${pathName}_edit', '1', null, '1', '0', null, '2', null, '${comments}修改', 1);
|
||||
|
||||
insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,4)},${menuId}, '${moduleName}_${pathName}_del', '1', null, '1', '0', null, '3', null, '${comments}删除', 1);
|
||||
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,5)},${menuId}, '${moduleName}_${pathName}_export', '1', null, '1', '0', null, '3', null, '导入导出', 1);
|
||||
@@ -1,18 +0,0 @@
|
||||
// 以下内容请复制到http.api.js中
|
||||
pigx${className}: {
|
||||
// 分页
|
||||
#[[fetchList: (params={}) => vm.$u.get]]#('/${moduleName}/${pathName}/page',params),
|
||||
|
||||
// 新增
|
||||
#[[addObj: (obj={}) => vm.$u.post]]#('/${moduleName}/${pathName}', obj),
|
||||
|
||||
// 修改
|
||||
#[[putObj: (obj={}) => vm.$u.put]]#('/${moduleName}/${pathName}',obj),
|
||||
|
||||
// 删除
|
||||
#[[delObj: (params) => vm.$u.delete]]#('/${moduleName}/${pathName}/'+params.id),
|
||||
|
||||
// 查询
|
||||
#[[getObj: (params) => vm.$u.get]]#('/${moduleName}/${pathName}/' + params.id)
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
<u-form-item label="${column.comments}" prop="${column.lowerAttrName}" label-width="180">
|
||||
<u-input v-model="model.${column.lowerAttrName}" placeholder="${column.comments}"></u-input>
|
||||
</u-form-item>
|
||||
#end
|
||||
#end
|
||||
</u-form>
|
||||
<view class="form-footer">
|
||||
<u-button class="btn" type="primary" @click="submit">提交</u-button>
|
||||
<u-button class="btn" type="default" @click="cancel">关闭</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
type:'',
|
||||
model: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == $pk.columnName)
|
||||
${column.lowerAttrName}: 0,
|
||||
#else
|
||||
${column.lowerAttrName}: ''#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
rules: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
${column.lowerAttrName}: [
|
||||
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(params) {
|
||||
if(params&¶ms.id!= "undefined"){
|
||||
this.type = 'edit'
|
||||
#[[this.$u.api]]#.pigx${className}.getObj(params).then(res => {
|
||||
this.model = res.data;
|
||||
});
|
||||
}else{
|
||||
this.type = 'add'
|
||||
this.model = {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
#[[this.$refs.uForm.validate(async valid => {]]#
|
||||
if (valid) {
|
||||
if(this.type==='edit'){
|
||||
await #[[this.$u.api]]#.pigx${className}.putObj(this.model)
|
||||
}else{
|
||||
await #[[this.$u.api]]#.pigx${className}.addObj(this.model)
|
||||
}
|
||||
setTimeout(() => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
ccontent: this.type === 'edit' ? '修改成功' : '添加成功',
|
||||
showCancel: false,
|
||||
success: function() {
|
||||
uni.setStorageSync('refreshList', true);
|
||||
uni.navigateTo({
|
||||
url: '/pages/${moduleName}/${pathName}/${pathName}-index'
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 200)
|
||||
} else {
|
||||
#[[this.$u.toast('您填写的信息有误,请根据提示修正。')]]#
|
||||
}
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
|
||||
<u-cell-group class="list" :border="false">
|
||||
<u-card :title="item.${pk.lowerAttrName}" v-for="(item, index) in list" :key="item.${pk.lowerAttrName}"
|
||||
:index="item.${pk.lowerAttrName}" @click="cardClick(item.${pk.lowerAttrName})">
|
||||
<view class="" slot="body">
|
||||
#foreach($column in $columns)
|
||||
<view class="row-list">
|
||||
<span class="span-lable">${column.comments}: </span>{{item.${column.lowerAttrName}}}
|
||||
</view>
|
||||
#end
|
||||
</view>
|
||||
<view class="card-foot" slot="foot">
|
||||
<u-button type="primary" size="medium" @click="cardClick(item.${pk.lowerAttrName})">编辑</u-button>
|
||||
<u-button size="medium" @click="del(item.${pk.lowerAttrName})">删除</u-button>
|
||||
</view>
|
||||
</u-card>
|
||||
</u-cell-group>
|
||||
<view class="loadmore" @click="loadMore">
|
||||
<u-loadmore :status="loadStatus"></u-loadmore>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="btn-plus" @click="cardClick()">
|
||||
<u-icon name="plus-circle-fill" size="90" color="#3d87ff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keywords: '',
|
||||
query: {
|
||||
current: 1,
|
||||
size: 20
|
||||
},
|
||||
list: [],
|
||||
count: 0,
|
||||
loadStatus: 'loadmore',
|
||||
options: [{
|
||||
text: '删除',
|
||||
style: {
|
||||
background: '#dd524d'
|
||||
}
|
||||
}]
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.loadList();
|
||||
},
|
||||
onShow() {
|
||||
if (uni.getStorageSync('refreshList') === true) {
|
||||
uni.removeStorageSync('refreshList');
|
||||
this.search('');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cardClick(id) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/${moduleName}/${pathName}/${pathName}-form?id='+id
|
||||
})
|
||||
},
|
||||
loadMore() {
|
||||
this.loadStatus = "loading";
|
||||
setTimeout(() => {
|
||||
this.query.current += 1;
|
||||
this.loadList();
|
||||
}, 100);
|
||||
},
|
||||
loadList() {
|
||||
#[[this.$u.api]]#.pigx${className}.fetchList(this.query).then(res => {
|
||||
if (!res.data.records || res.data.records.length == 0) {
|
||||
this.loadStatus = "nomore";
|
||||
return;
|
||||
}
|
||||
this.list = this.list.concat(res.data.records);
|
||||
this.total = res.data.total;
|
||||
this.query.current = res.data.current;
|
||||
this.query.size = res.data.size;
|
||||
this.loadStatus = "loadmore";
|
||||
});
|
||||
},
|
||||
del(id) {
|
||||
let self = this;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认要删除该数据吗?',
|
||||
showCancel: true,
|
||||
success: function(res2) {
|
||||
if (res2.confirm) {
|
||||
#[[self.$u.api]]#.pigx${className}.delObj({id:id}).then(res => {
|
||||
#[[self.$u.toast('删除成功');]]#
|
||||
self.query.current = 1
|
||||
self.list = []
|
||||
self.loadList()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,17 +0,0 @@
|
||||
// 以下内容请复制到pages.json
|
||||
"pages": [
|
||||
|
||||
/**${comments}**/
|
||||
{
|
||||
"path": "pages/${moduleName}/${pathName}/${pathName}-index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "${comments}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/${moduleName}/${pathName}/${pathName}-form",
|
||||
"style": {
|
||||
"navigationBarTitleText": "${comments}详情"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user