Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-module-gen
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-module-gen
Commits
ee89a002
提交
ee89a002
authored
11月 08, 2024
作者:
李秋林
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改后端代码生成模板;集成Mybatis-plus;分页规范修改
上级
176304cf
显示空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
201 行增加
和
314 行删除
+201
-314
pom.xml
pom.xml
+9
-0
SfaGenApplication.java
src/main/java/com/sfa/gen/SfaGenApplication.java
+2
-0
MybatisPlusConfig.java
...main/java/com/sfa/gen/config/mysql/MybatisPlusConfig.java
+23
-0
GenController.java
src/main/java/com/sfa/gen/controller/GenController.java
+19
-34
GenTable.java
src/main/java/com/sfa/gen/domain/GenTable.java
+23
-241
GenTableMapper.java
src/main/java/com/sfa/gen/mapper/GenTableMapper.java
+9
-1
GenTableServiceImpl.java
src/main/java/com/sfa/gen/service/GenTableServiceImpl.java
+53
-27
IGenTableService.java
src/main/java/com/sfa/gen/service/IGenTableService.java
+4
-2
GenTableMapper.xml
src/main/resources/mapper/generator/GenTableMapper.xml
+28
-0
controller.java.vm
src/main/resources/vm/java/controller.java.vm
+3
-4
domain.java.vm
src/main/resources/vm/java/domain.java.vm
+6
-1
mapper.java.vm
src/main/resources/vm/java/mapper.java.vm
+6
-1
service.java.vm
src/main/resources/vm/java/service.java.vm
+2
-1
serviceImpl.java.vm
src/main/resources/vm/java/serviceImpl.java.vm
+14
-2
没有找到文件。
pom.xml
浏览文件 @
ee89a002
...
...
@@ -81,6 +81,15 @@
<version>
${druid-spring-boot-starter.version}
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-annotation
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/sfa/gen/SfaGenApplication.java
浏览文件 @
ee89a002
package
com
.
sfa
.
gen
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
com.sfa.common.security.annotation.EnableCustomConfig
;
...
...
@@ -13,6 +14,7 @@ import com.sfa.common.security.annotation.EnableRyFeignClients;
@EnableCustomConfig
@EnableRyFeignClients
@SpringBootApplication
@MapperScan
(
"com.sfa.gen.mapper"
)
public
class
SfaGenApplication
{
public
static
void
main
(
String
[]
args
)
...
...
src/main/java/com/sfa/gen/config/mysql/MybatisPlusConfig.java
0 → 100644
浏览文件 @
ee89a002
package
com
.
sfa
.
gen
.
config
.
mysql
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author : liqiulin
* @date : 2024-04-25 13
* @describe :
*/
@Configuration
public
class
MybatisPlusConfig
{
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
(){
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
interceptor
.
addInnerInterceptor
(
new
PaginationInnerInterceptor
());
return
interceptor
;
}
}
\ No newline at end of file
src/main/java/com/sfa/gen/controller/GenController.java
浏览文件 @
ee89a002
package
com
.
sfa
.
gen
.
controller
;
import
java.io.IOException
;
import
java.util.ArrayList
;
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.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.alibaba.druid.DbType
;
import
com.alibaba.druid.sql.SQLUtils
;
import
com.alibaba.druid.sql.ast.SQLStatement
;
import
com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement
;
import
com.sfa.common.core.text.Convert
;
import
com.sfa.common.core.utils.sql.SqlUtil
;
import
com.sfa.common.core.web.controller.BaseController
;
import
com.sfa.common.core.web.domain.AjaxResult
;
import
com.sfa.common.core.web.
page.TableData
Info
;
import
com.sfa.common.core.web.
domain.Page
Info
;
import
com.sfa.common.log.annotation.Log
;
import
com.sfa.common.log.enums.BusinessType
;
import
com.sfa.common.security.annotation.RequiresPermissions
;
import
com.sfa.common.core.utils.sql.SqlUtil
;
import
com.sfa.gen.domain.GenTable
;
import
com.sfa.gen.domain.GenTableColumn
;
import
com.sfa.gen.service.IGenTableColumnService
;
import
com.sfa.gen.service.IGenTableService
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 代码生成 操作处理
...
...
@@ -55,11 +48,9 @@ public class GenController extends BaseController
*/
@RequiresPermissions
(
"tool:gen:list"
)
@GetMapping
(
"/list"
)
public
TableData
Info
genList
(
GenTable
genTable
)
public
Page
Info
genList
(
GenTable
genTable
)
{
startPage
();
List
<
GenTable
>
list
=
genTableService
.
selectGenTableList
(
genTable
);
return
getDataTable
(
list
);
return
genTableService
.
selectGenTableList
(
genTable
);
}
/**
...
...
@@ -120,24 +111,18 @@ public class GenController extends BaseController
*/
@RequiresPermissions
(
"tool:gen:list"
)
@GetMapping
(
"/db/list"
)
public
TableData
Info
dataList
(
GenTable
genTable
)
public
Page
Info
dataList
(
GenTable
genTable
)
{
startPage
();
List
<
GenTable
>
list
=
genTableService
.
selectDbTableList
(
genTable
);
return
getDataTable
(
list
);
return
genTableService
.
selectDbTableList
(
genTable
);
}
/**
* 查询数据表字段列表
*/
@GetMapping
(
value
=
"/column/{tableId}"
)
public
TableDataInfo
columnList
(
Long
tableId
)
public
List
<
GenTableColumn
>
columnList
(
Long
tableId
)
{
TableDataInfo
dataInfo
=
new
TableDataInfo
();
List
<
GenTableColumn
>
list
=
genTableColumnService
.
selectGenTableColumnListByTableId
(
tableId
);
dataInfo
.
setRows
(
list
);
dataInfo
.
setTotal
(
list
.
size
());
return
dataInfo
;
return
genTableColumnService
.
selectGenTableColumnListByTableId
(
tableId
);
}
/**
...
...
src/main/java/com/sfa/gen/domain/GenTable.java
浏览文件 @
ee89a002
...
...
@@ -3,6 +3,15 @@ package com.sfa.gen.domain;
import
java.util.List
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotBlank
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.sfa.common.core.web.domain.BaseDo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.commons.lang3.ArrayUtils
;
import
com.sfa.common.core.constant.GenConstants
;
import
com.sfa.common.core.utils.StringUtils
;
...
...
@@ -13,11 +22,16 @@ import com.sfa.common.core.web.domain.BaseEntity;
*
* @author ruoyi
*/
public
class
GenTable
extends
BaseEntity
@NoArgsConstructor
@AllArgsConstructor
@Data
@TableName
(
value
=
"gen_table"
)
public
class
GenTable
extends
BaseDo
{
private
static
final
long
serialVersionUID
=
1L
;
/** 编号 */
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
tableId
;
/** 表名称 */
...
...
@@ -71,12 +85,15 @@ public class GenTable extends BaseEntity
private
String
genPath
;
/** 主键信息 */
@TableField
(
exist
=
false
)
private
GenTableColumn
pkColumn
;
/** 子表信息 */
@TableField
(
exist
=
false
)
private
GenTable
subTable
;
/** 表列信息 */
@TableField
(
exist
=
false
)
@Valid
private
List
<
GenTableColumn
>
columns
;
...
...
@@ -84,259 +101,24 @@ public class GenTable extends BaseEntity
private
String
options
;
/** 树编码字段 */
@TableField
(
exist
=
false
)
private
String
treeCode
;
/** 树父编码字段 */
@TableField
(
exist
=
false
)
private
String
treeParentCode
;
/** 树名称字段 */
@TableField
(
exist
=
false
)
private
String
treeName
;
/** 上级菜单ID字段 */
@TableField
(
exist
=
false
)
private
String
parentMenuId
;
/** 上级菜单名称字段 */
@TableField
(
exist
=
false
)
private
String
parentMenuName
;
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
getSubTableName
()
{
return
subTableName
;
}
public
void
setSubTableName
(
String
subTableName
)
{
this
.
subTableName
=
subTableName
;
}
public
String
getSubTableFkName
()
{
return
subTableFkName
;
}
public
void
setSubTableFkName
(
String
subTableFkName
)
{
this
.
subTableFkName
=
subTableFkName
;
}
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
getTplWebType
()
{
return
tplWebType
;
}
public
void
setTplWebType
(
String
tplWebType
)
{
this
.
tplWebType
=
tplWebType
;
}
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
String
getGenType
()
{
return
genType
;
}
public
void
setGenType
(
String
genType
)
{
this
.
genType
=
genType
;
}
public
String
getGenPath
()
{
return
genPath
;
}
public
void
setGenPath
(
String
genPath
)
{
this
.
genPath
=
genPath
;
}
public
GenTableColumn
getPkColumn
()
{
return
pkColumn
;
}
public
void
setPkColumn
(
GenTableColumn
pkColumn
)
{
this
.
pkColumn
=
pkColumn
;
}
public
GenTable
getSubTable
()
{
return
subTable
;
}
public
void
setSubTable
(
GenTable
subTable
)
{
this
.
subTable
=
subTable
;
}
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
String
getParentMenuId
()
{
return
parentMenuId
;
}
public
void
setParentMenuId
(
String
parentMenuId
)
{
this
.
parentMenuId
=
parentMenuId
;
}
public
String
getParentMenuName
()
{
return
parentMenuName
;
}
public
void
setParentMenuName
(
String
parentMenuName
)
{
this
.
parentMenuName
=
parentMenuName
;
}
public
boolean
isSub
()
{
return
isSub
(
this
.
tplCategory
);
...
...
src/main/java/com/sfa/gen/mapper/GenTableMapper.java
浏览文件 @
ee89a002
package
com
.
sfa
.
gen
.
mapper
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.sfa.gen.domain.GenTable
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
/**
...
...
@@ -12,7 +15,7 @@ import org.springframework.stereotype.Repository;
*/
@Repository
@Mapper
public
interface
GenTableMapper
public
interface
GenTableMapper
extends
BaseMapper
<
GenTable
>
{
/**
* 查询业务列表
...
...
@@ -92,4 +95,8 @@ public interface GenTableMapper
* @return 结果
*/
public
int
createTable
(
String
sql
);
List
<
GenTable
>
selectDbTablePage
(
@Param
(
"genTable"
)
GenTable
genTable
,
@Param
(
"skipNum"
)
int
skipNum
,
@Param
(
"pageSize"
)
int
pageSize
);
Integer
selectDbTableCount
(
GenTable
genTable
);
}
\ No newline at end of file
src/main/java/com/sfa/gen/service/GenTableServiceImpl.java
浏览文件 @
ee89a002
package
com
.
sfa
.
gen
.
service
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
org.apache.commons.io.FileUtils
;
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.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.sfa.common.core.constant.Constants
;
import
com.sfa.common.core.constant.GenConstants
;
import
com.sfa.common.core.exception.ServiceException
;
import
com.sfa.common.core.text.CharsetKit
;
import
com.sfa.common.core.utils.StringUtils
;
import
com.sfa.common.core.web.domain.PageInfo
;
import
com.sfa.common.core.web.page.TableSupport
;
import
com.sfa.common.security.utils.SecurityUtils
;
import
com.sfa.gen.domain.GenTable
;
import
com.sfa.gen.domain.GenTableColumn
;
...
...
@@ -36,6 +19,28 @@ import com.sfa.gen.mapper.GenTableMapper;
import
com.sfa.gen.util.GenUtils
;
import
com.sfa.gen.util.VelocityInitializer
;
import
com.sfa.gen.util.VelocityUtils
;
import
org.apache.commons.io.FileUtils
;
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
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
/**
* 业务 服务层实现
...
...
@@ -74,9 +79,23 @@ public class GenTableServiceImpl implements IGenTableService
* @return 业务集合
*/
@Override
public
List
<
GenTable
>
selectGenTableList
(
GenTable
genTable
)
public
PageInfo
selectGenTableList
(
GenTable
genTable
)
{
return
genTableMapper
.
selectGenTableList
(
genTable
);
LambdaQueryWrapper
<
GenTable
>
qw
=
buildWrapper
(
genTable
);
Page
<
GenTable
>
pageR
=
genTableMapper
.
selectPage
(
TableSupport
.
pageI
(),
qw
);
PageInfo
<
GenTable
>
pageInfo
=
new
PageInfo
<>(
pageR
);
return
pageInfo
;
}
private
LambdaQueryWrapper
<
GenTable
>
buildWrapper
(
GenTable
genTable
)
{
LambdaQueryWrapper
<
GenTable
>
qw
=
new
LambdaQueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
genTable
.
getTableName
())){
qw
.
like
(
true
,
GenTable:
:
getTableName
,
genTable
.
getTableName
());
}
if
(
StringUtils
.
isNotBlank
(
genTable
.
getTableComment
())){
qw
.
like
(
true
,
GenTable:
:
getTableComment
,
genTable
.
getTableComment
());
}
return
qw
;
}
/**
...
...
@@ -86,9 +105,14 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据库表集合
*/
@Override
public
List
<
GenTable
>
selectDbTableList
(
GenTable
genTable
)
public
PageInfo
selectDbTableList
(
GenTable
genTable
)
{
return
genTableMapper
.
selectDbTableList
(
genTable
);
PageInfo
<
GenTable
>
pageInfo
=
TableSupport
.
pageInfo
();
List
<
GenTable
>
dos
=
genTableMapper
.
selectDbTablePage
(
genTable
,
pageInfo
.
getSkipNum
(),
pageInfo
.
getPageSize
());
Integer
count
=
genTableMapper
.
selectDbTableCount
(
genTable
);
pageInfo
.
setRows
(
dos
);
pageInfo
.
setTotal
(
count
);
return
pageInfo
;
}
/**
...
...
@@ -124,7 +148,8 @@ public class GenTableServiceImpl implements IGenTableService
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateGenTable
(
GenTable
genTable
)
{
String
options
=
JSON
.
toJSONString
(
genTable
.
getParams
());
// String options = JSON.toJSONString(genTable.getParams());
String
options
=
JSON
.
toJSONString
(
genTable
);
genTable
.
setOptions
(
options
);
int
row
=
genTableMapper
.
updateGenTable
(
genTable
);
if
(
row
>
0
)
...
...
@@ -412,7 +437,8 @@ public class GenTableServiceImpl implements IGenTableService
{
if
(
GenConstants
.
TPL_TREE
.
equals
(
genTable
.
getTplCategory
()))
{
String
options
=
JSON
.
toJSONString
(
genTable
.
getParams
());
// String options = JSON.toJSONString(genTable.getParams());
String
options
=
JSON
.
toJSONString
(
genTable
);
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
)))
{
...
...
src/main/java/com/sfa/gen/service/IGenTableService.java
浏览文件 @
ee89a002
...
...
@@ -2,6 +2,8 @@ package com.sfa.gen.service;
import
java.util.List
;
import
java.util.Map
;
import
com.sfa.common.core.web.domain.PageInfo
;
import
com.sfa.gen.domain.GenTable
;
/**
...
...
@@ -17,7 +19,7 @@ public interface IGenTableService
* @param genTable 业务信息
* @return 业务集合
*/
public
List
<
GenTable
>
selectGenTableList
(
GenTable
genTable
);
public
PageInfo
selectGenTableList
(
GenTable
genTable
);
/**
* 查询据库列表
...
...
@@ -25,7 +27,7 @@ public interface IGenTableService
* @param genTable 业务信息
* @return 数据库表集合
*/
public
List
<
GenTable
>
selectDbTableList
(
GenTable
genTable
);
public
PageInfo
selectDbTableList
(
GenTable
genTable
);
/**
* 查询据库列表
...
...
src/main/resources/mapper/generator/GenTableMapper.xml
浏览文件 @
ee89a002
...
...
@@ -194,5 +194,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{tableId}
</foreach>
</delete>
<select
id=
"selectDbTableCount"
parameterType=
"com.sfa.gen.domain.GenTable"
resultType=
"integer"
>
select count(*) 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>
</select>
<select
id=
"selectDbTablePage"
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=
"genTable.tableName != null and genTable.tableName != ''"
>
AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
</if>
<if
test=
"genTable.tableComment != null and genTable.tableComment != ''"
>
AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
</if>
order by create_time desc
limit #{skipNum},#{pageSize};
</select>
</mapper>
\ No newline at end of file
src/main/resources/vm/java/controller.java.vm
浏览文件 @
ee89a002
...
...
@@ -12,6 +12,7 @@ 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
.
sfa
.
common
.
core
.
web
.
domain
.
PageInfo
;
import
com
.
sfa
.
common
.
log
.
annotation
.
Log
;
import
com
.
sfa
.
common
.
log
.
enums
.
BusinessType
;
import
com
.
sfa
.
common
.
security
.
annotation
.
RequiresPermissions
;
...
...
@@ -44,11 +45,9 @@ public class ${ClassName}Controller extends BaseController
@
RequiresPermissions
(
"${permissionPrefix}:list"
)
@
GetMapping
(
"/list"
)
#
if
($
table
.
crud
||
$
table
.
sub
)
public
TableData
Info
list
(${
ClassName
}
${
className
})
public
Page
Info
list
(${
ClassName
}
${
className
})
{
startPage
();
List
<${
ClassName
}>
list
=
${
className
}
Service
.
select
${
ClassName
}
List
(${
className
});
return
getDataTable
(
list
);
return
${
className
}
Service
.
select
${
ClassName
}
page
(${
className
});
}
#
elseif
($
table
.
tree
)
public
AjaxResult
list
(${
ClassName
}
${
className
})
...
...
src/main/resources/vm/java/domain.java.vm
浏览文件 @
ee89a002
...
...
@@ -3,9 +3,12 @@ package ${packageName}.domain;
#
foreach
($
import
in
$
importList
)
import
${
import
};
#
end
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringBuilder
;
import
org
.
apache
.
commons
.
lang3
.
builder
.
ToStringStyle
;
import
com
.
sfa
.
common
.
core
.
annotation
.
Excel
;
import
java
.
util
.
Date
;
import
lombok
.
Data
;
#
if
($
table
.
crud
||
$
table
.
sub
)
import
com
.
sfa
.
common
.
core
.
web
.
domain
.
BaseEntity
;
#
elseif
($
table
.
tree
)
...
...
@@ -19,10 +22,12 @@ import com.sfa.common.core.web.domain.TreeEntity;
*
@
date
${
datetime
}
*/
#
if
($
table
.
crud
||
$
table
.
sub
)
#
set
($
Entity
=
"Base
Entity
"
)
#
set
($
Entity
=
"Base
Do
"
)
#
elseif
($
table
.
tree
)
#
set
($
Entity
=
"TreeEntity"
)
#
end
@
TableName
(
value
=
"${tableName}"
)
@
Data
public
class
${
ClassName
}
extends
${
Entity
}
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/resources/vm/java/mapper.java.vm
浏览文件 @
ee89a002
package
${
packageName
}.
mapper
;
import
java
.
util
.
List
;
import
com
.
baomidou
.
mybatisplus
.
core
.
mapper
.
BaseMapper
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
import
org
.
springframework
.
stereotype
.
Repository
;
import
${
packageName
}.
domain
.${
ClassName
};
#
if
($
table
.
sub
)
import
${
packageName
}.
domain
.${
subClassName
};
...
...
@@ -12,7 +15,9 @@ import ${packageName}.domain.${subClassName};
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
public
interface
${
ClassName
}
Mapper
@
Repository
@
Mapper
public
interface
${
ClassName
}
Mapper
extends
BaseMapper
<${
ClassName
}>
{
/**
*
查询
${
functionName
}
...
...
src/main/resources/vm/java/service.java.vm
浏览文件 @
ee89a002
package
${
packageName
}.
service
;
import
java
.
util
.
List
;
import
com
.
sfa
.
common
.
core
.
web
.
domain
.
PageInfo
;
import
${
packageName
}.
domain
.${
ClassName
};
/**
...
...
@@ -25,7 +26,7 @@ public interface I${ClassName}Service
*
@
param
${
className
}
${
functionName
}
*
@
return
${
functionName
}
集合
*/
public
List
<${
ClassName
}>
select
${
ClassName
}
List
(${
ClassName
}
${
className
});
public
PageInfo
select
${
ClassName
}
page
(${
ClassName
}
${
className
});
/**
*
新增
${
functionName
}
...
...
src/main/resources/vm/java/serviceImpl.java.vm
浏览文件 @
ee89a002
package
${
packageName
}.
service
.
impl
;
import
java
.
util
.
List
;
import
com
.
baomidou
.
mybatisplus
.
core
.
conditions
.
query
.
LambdaQueryWrapper
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
;
import
com
.
sfa
.
common
.
core
.
web
.
domain
.
PageInfo
;
import
com
.
sfa
.
common
.
core
.
web
.
page
.
TableSupport
;
#
foreach
($
column
in
$
columns
)
#
if
($
column
.
javaField
==
'createTime'
||
$
column
.
javaField
==
'updateTime'
)
import
com
.
sfa
.
common
.
core
.
utils
.
DateUtils
;
...
...
@@ -50,9 +54,17 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
*
@
return
${
functionName
}
*/
@
Override
public
List
<${
ClassName
}>
select
${
ClassName
}
List
(${
ClassName
}
${
className
})
public
List
<${
ClassName
}>
select
${
ClassName
}
page
(${
ClassName
}
${
className
})
{
return
${
className
}
Mapper
.
select
${
ClassName
}
List
(${
className
});
LambdaQueryWrapper
<${
ClassName
}>
qw
=
buildWrapper
(${
className
});
Page
<${
ClassName
}>
pageR
=
${
className
}
Mapper
.
selectPage
(
TableSupport
.
pageI
(),
qw
);
PageInfo
<${
ClassName
}>
pageInfo
=
new
PageInfo
<>(
pageR
);
return
pageInfo
;
}
private
LambdaQueryWrapper
<${
ClassName
}>
buildWrapper
(${
ClassName
}
${
className
})
{
LambdaQueryWrapper
<${
ClassName
}>
qw
=
new
LambdaQueryWrapper
<>();
return
qw
;
}
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论