Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
8d8172b8
Commit
8d8172b8
authored
Nov 17, 2022
by
蒋凌峰
😉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
17918784
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1620 additions
and
803 deletions
+1620
-803
ruoyi-admin/src/main/java/com/ruoyi/web/controller/finance/FncSubjectTypeController.java
...uoyi/web/controller/finance/FncSubjectTypeController.java
+91
-0
ruoyi-admin/src/main/resources/application-druid.yml
ruoyi-admin/src/main/resources/application-druid.yml
+1
-1
ruoyi-common/pom.xml
ruoyi-common/pom.xml
+6
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java
...rc/main/java/com/ruoyi/common/core/domain/BaseEntity.java
+2
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java
...on/src/main/java/com/ruoyi/common/core/page/PagePlus.java
+156
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
...c/main/java/com/ruoyi/common/core/page/TableDataInfo.java
+33
-58
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
...ommon/src/main/java/com/ruoyi/common/utils/PageUtils.java
+127
-7
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
...src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+74
-124
ruoyi-generator/src/main/resources/vm/java/controller.java.vm
...i-generator/src/main/resources/vm/java/controller.java.vm
+58
-75
ruoyi-generator/src/main/resources/vm/js/api.js.vm
ruoyi-generator/src/main/resources/vm/js/api.js.vm
+15
-6
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
+532
-529
ruoyi-system/src/main/java/com/ruoyi/system/domain/FncSubjectType.java
...src/main/java/com/ruoyi/system/domain/FncSubjectType.java
+50
-0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/FncSubjectTypeVo.java
...ain/java/com/ruoyi/system/domain/vo/FncSubjectTypeVo.java
+23
-0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/FncSubjectTypeMapper.java
...in/java/com/ruoyi/system/mapper/FncSubjectTypeMapper.java
+25
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/IFncSubjectTypeService.java
...java/com/ruoyi/system/service/IFncSubjectTypeService.java
+41
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FncSubjectTypeServiceImpl.java
.../ruoyi/system/service/impl/FncSubjectTypeServiceImpl.java
+37
-0
ruoyi-system/src/main/resources/mapper/finance/FncSubjectTypeMapper.xml
...rc/main/resources/mapper/finance/FncSubjectTypeMapper.xml
+40
-0
ruoyi-ui/src/api/finance/subjectType.js
ruoyi-ui/src/api/finance/subjectType.js
+44
-0
ruoyi-ui/src/views/finance/ledger/index.vue
ruoyi-ui/src/views/finance/ledger/index.vue
+3
-3
ruoyi-ui/src/views/finance/subjecttype/index.vue
ruoyi-ui/src/views/finance/subjecttype/index.vue
+262
-0
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/finance/FncSubjectTypeController.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.system.controller
;
import
com.ruoyi.common.annotation.Log
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.system.domain.FncSubjectType
;
import
com.ruoyi.system.domain.vo.FncSubjectTypeVo
;
import
com.ruoyi.system.service.IFncSubjectTypeService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* 科目类别Controller
*
* @author jlf
* @date 2022-11-17
*/
@Api
(
tags
=
"科目类别Controller"
)
@RestController
@RequestMapping
(
"/finance/subjectType"
)
//@RequiredArgsConstructor(onConstructor = @Autowired)
public
class
FncSubjectTypeController
extends
BaseController
{
@Autowired
private
IFncSubjectTypeService
fncSubjectTypeService
;
@ApiOperation
(
"查询科目类别列表"
)
@PreAuthorize
(
"@ss.hasPermi('finance:subjectType:list')"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
<
FncSubjectTypeVo
>
list
(
FncSubjectTypeVo
entity
)
{
return
fncSubjectTypeService
.
queryList
(
entity
);
}
@ApiOperation
(
"查询科目类别所有列表"
)
@GetMapping
(
"/listAll"
)
public
AjaxResult
listAll
(
FncSubjectTypeVo
entity
)
{
return
AjaxResult
.
success
(
"查询成功"
,
fncSubjectTypeService
.
queryAll
(
entity
));
}
@ApiOperation
(
"导出科目类别列表"
)
@PreAuthorize
(
"@ss.hasPermi('finance:subjectType:export')"
)
@Log
(
title
=
"科目类别"
,
businessType
=
BusinessType
.
EXPORT
)
@PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
FncSubjectTypeVo
entity
)
{
List
<
FncSubjectTypeVo
>
list
=
fncSubjectTypeService
.
queryAll
(
entity
);
ExcelUtil
<
FncSubjectTypeVo
>
util
=
new
ExcelUtil
<>(
FncSubjectTypeVo
.
class
);
util
.
exportExcel
(
response
,
list
,
"科目类别数据"
);
}
@ApiOperation
(
"获取科目类别详细信息"
)
@PreAuthorize
(
"@ss.hasPermi('finance:subjectType:query')"
)
@GetMapping
(
value
=
"/getInfo/{subjectTypeId}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"subjectTypeId"
)
Long
subjectTypeId
)
{
return
AjaxResult
.
success
(
"查询成功"
,
fncSubjectTypeService
.
queryById
(
subjectTypeId
));
}
@ApiOperation
(
"新增科目类别"
)
@PreAuthorize
(
"@ss.hasPermi('finance:subjectType:add')"
)
@Log
(
title
=
"科目类别"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"add"
)
public
AjaxResult
add
(
@RequestBody
FncSubjectType
entity
)
{
return
toAjax
(
fncSubjectTypeService
.
save
(
entity
));
}
@ApiOperation
(
"修改科目类别"
)
@PreAuthorize
(
"@ss.hasPermi('finance:subjectType:edit')"
)
@Log
(
title
=
"科目类别"
,
businessType
=
BusinessType
.
UPDATE
)
@PostMapping
(
"edit"
)
public
AjaxResult
edit
(
@RequestBody
FncSubjectType
entity
)
{
return
toAjax
(
fncSubjectTypeService
.
updateById
(
entity
));
}
@ApiOperation
(
"删除科目类别"
)
@PreAuthorize
(
"@ss.hasPermi('finance:subjectType:remove')"
)
@Log
(
title
=
"科目类别"
,
businessType
=
BusinessType
.
DELETE
)
@GetMapping
(
"/remove/{subjectTypeIds}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
subjectTypeIds
)
{
return
toAjax
(
fncSubjectTypeService
.
removeByIds
(
Arrays
.
asList
(
subjectTypeIds
))
?
1
:
0
);
}
}
ruoyi-admin/src/main/resources/application-druid.yml
View file @
8d8172b8
...
@@ -6,7 +6,7 @@ spring:
...
@@ -6,7 +6,7 @@ spring:
druid
:
druid
:
# 主库数据源
# 主库数据源
master
:
master
:
url
:
jdbc:mysql://
192.168.182.130
:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url
:
jdbc:mysql://
localhost
:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username
:
root
username
:
root
password
:
root
password
:
root
# 从库数据源
# 从库数据源
...
...
ruoyi-common/pom.xml
View file @
8d8172b8
...
@@ -146,6 +146,12 @@
...
@@ -146,6 +146,12 @@
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
1.6.2
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</dependencies>
...
...
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java
View file @
8d8172b8
...
@@ -49,6 +49,8 @@ public class BaseEntity implements Serializable {
...
@@ -49,6 +49,8 @@ public class BaseEntity implements Serializable {
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
private
Date
updateTime
;
/**
/**
* 请求参数
* 请求参数
*/
*/
...
...
ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.common.core.page
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
/**
* 分页 Page 增强对象
*
* @param <T> 数据库实体
* @param <K> vo实体
* @author Lion Li
*/
@Data
@Accessors
(
chain
=
true
)
public
class
PagePlus
<
T
,
K
>
implements
IPage
<
T
>
{
/**
* domain实体列表
*/
private
List
<
T
>
records
=
Collections
.
emptyList
();
/**
* vo实体列表
*/
private
List
<
K
>
recordsVo
=
Collections
.
emptyList
();
/**
* 总数
*/
private
long
total
=
0L
;
/**
* 页长度
*/
private
long
size
=
10L
;
/**
* 当前页
*/
private
long
current
=
1L
;
/**
* 排序字段信息
*/
private
List
<
OrderItem
>
orders
=
new
ArrayList
<>();
/**
* 自动优化 COUNT SQL
*/
private
boolean
optimizeCountSql
=
true
;
/**
* 是否进行 count 查询
*/
private
boolean
isSearchCount
=
true
;
/**
* 是否命中count缓存
*/
private
boolean
hitCount
=
false
;
/**
* countId
*/
private
String
countId
;
/**
* 最大limit
*/
private
Long
maxLimit
;
public
PagePlus
()
{
}
public
PagePlus
(
long
current
,
long
size
)
{
this
(
current
,
size
,
0L
);
}
public
PagePlus
(
long
current
,
long
size
,
long
total
)
{
this
(
current
,
size
,
total
,
true
);
}
public
PagePlus
(
long
current
,
long
size
,
boolean
isSearchCount
)
{
this
(
current
,
size
,
0L
,
isSearchCount
);
}
public
PagePlus
(
long
current
,
long
size
,
long
total
,
boolean
isSearchCount
)
{
if
(
current
>
1L
)
{
this
.
current
=
current
;
}
this
.
size
=
size
;
this
.
total
=
total
;
this
.
isSearchCount
=
isSearchCount
;
}
public
static
<
T
,
K
>
PagePlus
<
T
,
K
>
of
(
long
current
,
long
size
)
{
return
of
(
current
,
size
,
0
);
}
public
static
<
T
,
K
>
PagePlus
<
T
,
K
>
of
(
long
current
,
long
size
,
long
total
)
{
return
of
(
current
,
size
,
total
,
true
);
}
public
static
<
T
,
K
>
PagePlus
<
T
,
K
>
of
(
long
current
,
long
size
,
boolean
searchCount
)
{
return
of
(
current
,
size
,
0
,
searchCount
);
}
public
static
<
T
,
K
>
PagePlus
<
T
,
K
>
of
(
long
current
,
long
size
,
long
total
,
boolean
searchCount
)
{
return
new
PagePlus
<>(
current
,
size
,
total
,
searchCount
);
}
@Override
public
String
countId
()
{
return
this
.
getCountId
();
}
@Override
public
Long
maxLimit
()
{
return
this
.
getMaxLimit
();
}
public
PagePlus
<
T
,
K
>
addOrder
(
OrderItem
...
items
)
{
this
.
orders
.
addAll
(
Arrays
.
asList
(
items
));
return
this
;
}
public
PagePlus
<
T
,
K
>
addOrder
(
List
<
OrderItem
>
items
)
{
this
.
orders
.
addAll
(
items
);
return
this
;
}
@Override
public
List
<
OrderItem
>
orders
()
{
return
this
.
getOrders
();
}
@Override
public
boolean
optimizeCountSql
()
{
return
this
.
optimizeCountSql
;
}
@Override
public
long
getPages
()
{
// 解决 github issues/3208
return
IPage
.
super
.
getPages
();
}
}
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
View file @
8d8172b8
package
com.ruoyi.common.core.page
;
package
com.ruoyi.common.core.page
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 表格分页数据对象
* 表格分页数据对象
*
*
* @author
ruoy
i
* @author
Lion L
i
*/
*/
public
class
TableDataInfo
implements
Serializable
{
@Data
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@ApiModel
(
"分页响应对象"
)
public
class
TableDataInfo
<
T
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** 总记录数 */
/**
* 总记录数
*/
@ApiModelProperty
(
"总记录数"
)
private
long
total
;
private
long
total
;
/** 列表数据 */
/**
private
List
<?>
rows
;
* 列表数据
*/
@ApiModelProperty
(
"列表数据"
)
private
List
<
T
>
rows
;
/** 消息状态码 */
/**
* 消息状态码
*/
@ApiModelProperty
(
"消息状态码"
)
private
int
code
;
private
int
code
;
/** 消息内容 */
private
String
msg
;
/**
/**
*
表格数据对象
*
消息内容
*/
*/
public
TableDataInfo
()
@ApiModelProperty
(
"消息内容"
)
{
private
String
msg
;
}
/**
/**
* 分页
* 分页
...
@@ -37,49 +52,9 @@ public class TableDataInfo implements Serializable
...
@@ -37,49 +52,9 @@ public class TableDataInfo implements Serializable
* @param list 列表数据
* @param list 列表数据
* @param total 总记录数
* @param total 总记录数
*/
*/
public
TableDataInfo
(
List
<?>
list
,
int
total
)
public
TableDataInfo
(
List
<
T
>
list
,
long
total
)
{
{
this
.
rows
=
list
;
this
.
rows
=
list
;
this
.
total
=
total
;
this
.
total
=
total
;
}
}
public
long
getTotal
()
{
return
total
;
}
public
void
setTotal
(
long
total
)
{
this
.
total
=
total
;
}
public
List
<?>
getRows
()
{
return
rows
;
}
public
void
setRows
(
List
<?>
rows
)
{
this
.
rows
=
rows
;
}
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
View file @
8d8172b8
package
com.ruoyi.common.utils
;
package
com.ruoyi.common.utils
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpStatus
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.ruoyi.common.core.page.PageDomain
;
import
com.ruoyi.common.core.page.PageDomain
;
import
com.ruoyi.common.core.page.PagePlus
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.core.page.TableSupport
;
import
com.ruoyi.common.core.page.TableSupport
;
import
com.ruoyi.common.utils.sql.SqlUtil
;
import
com.ruoyi.common.utils.sql.SqlUtil
;
import
java.util.List
;
/**
/**
* 分页工具类
* 分页工具类
*
*
* @author ruoyi
* @author ruoyi
*/
*/
public
class
PageUtils
extends
PageHelper
public
class
PageUtils
extends
PageHelper
{
{
/**
/**
* 设置请求分页数据
* 设置请求分页数据
*/
*/
public
static
void
startPage
()
public
static
void
startPage
()
{
{
PageDomain
pageDomain
=
TableSupport
.
buildPageRequest
();
PageDomain
pageDomain
=
TableSupport
.
buildPageRequest
();
Integer
pageNum
=
pageDomain
.
getPageNum
();
Integer
pageNum
=
pageDomain
.
getPageNum
();
Integer
pageSize
=
pageDomain
.
getPageSize
();
Integer
pageSize
=
pageDomain
.
getPageSize
();
...
@@ -28,8 +34,122 @@ public class PageUtils extends PageHelper
...
@@ -28,8 +34,122 @@ public class PageUtils extends PageHelper
/**
/**
* 清理分页的线程变量
* 清理分页的线程变量
*/
*/
public
static
void
clearPage
()
public
static
void
clearPage
()
{
{
PageHelper
.
clearPage
();
PageHelper
.
clearPage
();
}
}
/**
* 当前记录起始索引
*/
public
static
final
String
PAGE_NUM
=
"pageNum"
;
/**
* 每页显示记录数
*/
public
static
final
String
PAGE_SIZE
=
"pageSize"
;
/**
* 排序列
*/
public
static
final
String
ORDER_BY_COLUMN
=
"orderByColumn"
;
/**
* 排序的方向 "desc" 或者 "asc".
*/
public
static
final
String
IS_ASC
=
"isAsc"
;
/**
* 当前记录起始索引 默认值
*/
public
static
final
int
DEFAULT_PAGE_NUM
=
1
;
/**
* 每页显示记录数 默认值 默认查全部
*/
public
static
final
int
DEFAULT_PAGE_SIZE
=
Integer
.
MAX_VALUE
;
/**
* 构建 plus 分页对象
*
* @param <T> domain 实体
* @param <K> vo 实体
* @return 分页对象
*/
public
static
<
T
,
K
>
PagePlus
<
T
,
K
>
buildPagePlus
()
{
Integer
pageNum
=
ServletUtils
.
getParameterToInt
(
PAGE_NUM
,
DEFAULT_PAGE_NUM
);
Integer
pageSize
=
ServletUtils
.
getParameterToInt
(
PAGE_SIZE
,
DEFAULT_PAGE_SIZE
);
String
orderByColumn
=
ServletUtils
.
getParameter
(
ORDER_BY_COLUMN
);
String
isAsc
=
ServletUtils
.
getParameter
(
IS_ASC
);
PagePlus
<
T
,
K
>
page
=
new
PagePlus
<>(
pageNum
,
pageSize
);
if
(
StrUtil
.
isNotBlank
(
orderByColumn
))
{
String
orderBy
=
SqlUtil
.
escapeOrderBySql
(
orderByColumn
);
if
(
"asc"
.
equals
(
isAsc
))
{
page
.
addOrder
(
OrderItem
.
asc
(
orderBy
));
}
else
if
(
"desc"
.
equals
(
isAsc
))
{
page
.
addOrder
(
OrderItem
.
desc
(
orderBy
));
}
}
return
page
;
}
public
static
<
T
>
Page
<
T
>
buildPage
()
{
return
buildPage
(
null
,
null
);
}
/**
* 构建 MP 普通分页对象
*
* @param <T> domain 实体
* @return 分页对象
*/
public
static
<
T
>
Page
<
T
>
buildPage
(
String
defaultOrderByColumn
,
String
defaultIsAsc
)
{
Integer
pageNum
=
ServletUtils
.
getParameterToInt
(
PAGE_NUM
,
DEFAULT_PAGE_NUM
);
Integer
pageSize
=
ServletUtils
.
getParameterToInt
(
PAGE_SIZE
,
DEFAULT_PAGE_SIZE
);
String
orderByColumn
=
ServletUtils
.
getParameter
(
ORDER_BY_COLUMN
,
defaultOrderByColumn
);
String
isAsc
=
ServletUtils
.
getParameter
(
IS_ASC
,
defaultIsAsc
);
// 兼容前端排序类型
if
(
"ascending"
.
equals
(
isAsc
))
{
isAsc
=
"asc"
;
}
else
if
(
"descending"
.
equals
(
isAsc
))
{
isAsc
=
"desc"
;
}
Page
<
T
>
page
=
new
Page
<>(
pageNum
,
pageSize
);
if
(
StrUtil
.
isNotBlank
(
orderByColumn
))
{
String
orderBy
=
SqlUtil
.
escapeOrderBySql
(
orderByColumn
);
orderBy
=
StrUtil
.
toUnderlineCase
(
orderBy
);
if
(
"asc"
.
equals
(
isAsc
))
{
page
.
addOrder
(
OrderItem
.
asc
(
orderBy
));
}
else
if
(
"desc"
.
equals
(
isAsc
))
{
page
.
addOrder
(
OrderItem
.
desc
(
orderBy
));
}
}
return
page
;
}
public
static
<
T
,
K
>
TableDataInfo
<
K
>
buildDataInfo
(
PagePlus
<
T
,
K
>
page
)
{
TableDataInfo
<
K
>
rspData
=
new
TableDataInfo
<>();
rspData
.
setCode
(
HttpStatus
.
HTTP_OK
);
rspData
.
setMsg
(
"查询成功"
);
rspData
.
setRows
(
page
.
getRecordsVo
());
rspData
.
setTotal
(
page
.
getTotal
());
return
rspData
;
}
public
static
<
T
>
TableDataInfo
<
T
>
buildDataInfo
(
Page
<
T
>
page
)
{
TableDataInfo
<
T
>
rspData
=
new
TableDataInfo
<>();
rspData
.
setCode
(
HttpStatus
.
HTTP_OK
);
rspData
.
setMsg
(
"查询成功"
);
rspData
.
setRows
(
page
.
getRecords
());
rspData
.
setTotal
(
page
.
getTotal
());
return
rspData
;
}
public
static
<
T
>
TableDataInfo
<
T
>
buildDataInfo
(
List
<
T
>
list
)
{
TableDataInfo
<
T
>
rspData
=
new
TableDataInfo
<>();
rspData
.
setCode
(
HttpStatus
.
HTTP_OK
);
rspData
.
setMsg
(
"查询成功"
);
rspData
.
setRows
(
list
);
rspData
.
setTotal
(
list
.
size
());
return
rspData
;
}
}
}
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
View file @
8d8172b8
package
com.ruoyi.generator.util
;
package
com.ruoyi.generator.util
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.velocity.VelocityContext
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.ruoyi.common.constant.GenConstants
;
import
com.ruoyi.common.constant.GenConstants
;
...
@@ -12,21 +7,32 @@ import com.ruoyi.common.utils.DateUtils;
...
@@ -12,21 +7,32 @@ import com.ruoyi.common.utils.DateUtils;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTableColumn
;
import
com.ruoyi.generator.domain.GenTableColumn
;
import
org.apache.velocity.VelocityContext
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* 模板处理工具类
* 模板处理工具类
*
*
* @author ruoyi
* @author ruoyi
*/
*/
public
class
VelocityUtils
public
class
VelocityUtils
{
{
/**
/** 项目空间路径 */
* 项目空间路径
*/
private
static
final
String
PROJECT_PATH
=
"main/java"
;
private
static
final
String
PROJECT_PATH
=
"main/java"
;
/** mybatis空间路径 */
/**
* mybatis空间路径
*/
private
static
final
String
MYBATIS_PATH
=
"main/resources/mapper"
;
private
static
final
String
MYBATIS_PATH
=
"main/resources/mapper"
;
/** 默认上级菜单,系统工具 */
/**
* 默认上级菜单,系统工具
*/
private
static
final
String
DEFAULT_PARENT_MENU_ID
=
"3"
;
private
static
final
String
DEFAULT_PARENT_MENU_ID
=
"3"
;
/**
/**
...
@@ -34,8 +40,7 @@ public class VelocityUtils
...
@@ -34,8 +40,7 @@ public class VelocityUtils
*
*
* @return 模板列表
* @return 模板列表
*/
*/
public
static
VelocityContext
prepareContext
(
GenTable
genTable
)
public
static
VelocityContext
prepareContext
(
GenTable
genTable
)
{
{
String
moduleName
=
genTable
.
getModuleName
();
String
moduleName
=
genTable
.
getModuleName
();
String
businessName
=
genTable
.
getBusinessName
();
String
businessName
=
genTable
.
getBusinessName
();
String
packageName
=
genTable
.
getPackageName
();
String
packageName
=
genTable
.
getPackageName
();
...
@@ -62,27 +67,23 @@ public class VelocityUtils
...
@@ -62,27 +67,23 @@ public class VelocityUtils
velocityContext
.
put
(
"table"
,
genTable
);
velocityContext
.
put
(
"table"
,
genTable
);
velocityContext
.
put
(
"dicts"
,
getDicts
(
genTable
));
velocityContext
.
put
(
"dicts"
,
getDicts
(
genTable
));
setMenuVelocityContext
(
velocityContext
,
genTable
);
setMenuVelocityContext
(
velocityContext
,
genTable
);
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
{
{
setTreeVelocityContext
(
velocityContext
,
genTable
);
setTreeVelocityContext
(
velocityContext
,
genTable
);
}
}
if
(
GenConstants
.
TPL_SUB
.
equals
(
tplCategory
))
if
(
GenConstants
.
TPL_SUB
.
equals
(
tplCategory
))
{
{
setSubVelocityContext
(
velocityContext
,
genTable
);
setSubVelocityContext
(
velocityContext
,
genTable
);
}
}
return
velocityContext
;
return
velocityContext
;
}
}
public
static
void
setMenuVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
public
static
void
setMenuVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
{
String
options
=
genTable
.
getOptions
();
String
options
=
genTable
.
getOptions
();
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
String
parentMenuId
=
getParentMenuId
(
paramsObj
);
String
parentMenuId
=
getParentMenuId
(
paramsObj
);
context
.
put
(
"parentMenuId"
,
parentMenuId
);
context
.
put
(
"parentMenuId"
,
parentMenuId
);
}
}
public
static
void
setTreeVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
public
static
void
setTreeVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
{
String
options
=
genTable
.
getOptions
();
String
options
=
genTable
.
getOptions
();
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
String
treeCode
=
getTreecode
(
paramsObj
);
String
treeCode
=
getTreecode
(
paramsObj
);
...
@@ -93,18 +94,15 @@ public class VelocityUtils
...
@@ -93,18 +94,15 @@ public class VelocityUtils
context
.
put
(
"treeParentCode"
,
treeParentCode
);
context
.
put
(
"treeParentCode"
,
treeParentCode
);
context
.
put
(
"treeName"
,
treeName
);
context
.
put
(
"treeName"
,
treeName
);
context
.
put
(
"expandColumn"
,
getExpandColumn
(
genTable
));
context
.
put
(
"expandColumn"
,
getExpandColumn
(
genTable
));
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_PARENT_CODE
))
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_PARENT_CODE
))
{
{
context
.
put
(
"tree_parent_code"
,
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
context
.
put
(
"tree_parent_code"
,
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
}
}
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_NAME
))
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_NAME
))
{
{
context
.
put
(
"tree_name"
,
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
context
.
put
(
"tree_name"
,
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
}
}
}
}
public
static
void
setSubVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
public
static
void
setSubVelocityContext
(
VelocityContext
context
,
GenTable
genTable
)
{
{
GenTable
subTable
=
genTable
.
getSubTable
();
GenTable
subTable
=
genTable
.
getSubTable
();
String
subTableName
=
genTable
.
getSubTableName
();
String
subTableName
=
genTable
.
getSubTableName
();
String
subTableFkName
=
genTable
.
getSubTableFkName
();
String
subTableFkName
=
genTable
.
getSubTableFkName
();
...
@@ -126,10 +124,10 @@ public class VelocityUtils
...
@@ -126,10 +124,10 @@ public class VelocityUtils
*
*
* @return 模板列表
* @return 模板列表
*/
*/
public
static
List
<
String
>
getTemplateList
(
String
tplCategory
)
public
static
List
<
String
>
getTemplateList
(
String
tplCategory
)
{
{
List
<
String
>
templates
=
new
ArrayList
<
String
>();
List
<
String
>
templates
=
new
ArrayList
<
String
>();
templates
.
add
(
"vm/java/domain.java.vm"
);
templates
.
add
(
"vm/java/domain.java.vm"
);
templates
.
add
(
"vm/java/vo.java.vm"
);
templates
.
add
(
"vm/java/mapper.java.vm"
);
templates
.
add
(
"vm/java/mapper.java.vm"
);
templates
.
add
(
"vm/java/service.java.vm"
);
templates
.
add
(
"vm/java/service.java.vm"
);
templates
.
add
(
"vm/java/serviceImpl.java.vm"
);
templates
.
add
(
"vm/java/serviceImpl.java.vm"
);
...
@@ -137,16 +135,11 @@ public class VelocityUtils
...
@@ -137,16 +135,11 @@ public class VelocityUtils
templates
.
add
(
"vm/xml/mapper.xml.vm"
);
templates
.
add
(
"vm/xml/mapper.xml.vm"
);
templates
.
add
(
"vm/sql/sql.vm"
);
templates
.
add
(
"vm/sql/sql.vm"
);
templates
.
add
(
"vm/js/api.js.vm"
);
templates
.
add
(
"vm/js/api.js.vm"
);
if
(
GenConstants
.
TPL_CRUD
.
equals
(
tplCategory
))
if
(
GenConstants
.
TPL_CRUD
.
equals
(
tplCategory
))
{
{
templates
.
add
(
"vm/vue/index.vue.vm"
);
templates
.
add
(
"vm/vue/index.vue.vm"
);
}
}
else
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
{
else
if
(
GenConstants
.
TPL_TREE
.
equals
(
tplCategory
))
{
templates
.
add
(
"vm/vue/index-tree.vue.vm"
);
templates
.
add
(
"vm/vue/index-tree.vue.vm"
);
}
}
else
if
(
GenConstants
.
TPL_SUB
.
equals
(
tplCategory
))
{
else
if
(
GenConstants
.
TPL_SUB
.
equals
(
tplCategory
))
{
templates
.
add
(
"vm/vue/index.vue.vm"
);
templates
.
add
(
"vm/vue/index.vue.vm"
);
templates
.
add
(
"vm/java/sub-domain.java.vm"
);
templates
.
add
(
"vm/java/sub-domain.java.vm"
);
}
}
...
@@ -156,8 +149,7 @@ public class VelocityUtils
...
@@ -156,8 +149,7 @@ public class VelocityUtils
/**
/**
* 获取文件名
* 获取文件名
*/
*/
public
static
String
getFileName
(
String
template
,
GenTable
genTable
)
public
static
String
getFileName
(
String
template
,
GenTable
genTable
)
{
{
// 文件名称
// 文件名称
String
fileName
=
""
;
String
fileName
=
""
;
// 包路径
// 包路径
...
@@ -173,48 +165,31 @@ public class VelocityUtils
...
@@ -173,48 +165,31 @@ public class VelocityUtils
String
mybatisPath
=
MYBATIS_PATH
+
"/"
+
moduleName
;
String
mybatisPath
=
MYBATIS_PATH
+
"/"
+
moduleName
;
String
vuePath
=
"vue"
;
String
vuePath
=
"vue"
;
if
(
template
.
contains
(
"domain.java.vm"
))
if
(
template
.
contains
(
"domain.java.vm"
))
{
{
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
className
);
}
}
if
(
template
.
contains
(
"sub-domain.java.vm"
)
&&
StringUtils
.
equals
(
GenConstants
.
TPL_SUB
,
genTable
.
getTplCategory
()))
if
(
template
.
contains
(
"vo.java.vm"
))
{
{
fileName
=
StringUtils
.
format
(
"{}/vo/{}.java"
,
javaPath
,
className
+
"Vo"
);
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
genTable
.
getSubTable
().
getClassName
());
}
}
else
if
(
template
.
contains
(
"mapper.java.vm"
))
if
(
template
.
contains
(
"sub-domain.java.vm"
)
&&
StringUtils
.
equals
(
GenConstants
.
TPL_SUB
,
genTable
.
getTplCategory
()))
{
{
fileName
=
StringUtils
.
format
(
"{}/domain/{}.java"
,
javaPath
,
genTable
.
getSubTable
().
getClassName
());
}
else
if
(
template
.
contains
(
"mapper.java.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/mapper/{}Mapper.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/mapper/{}Mapper.java"
,
javaPath
,
className
);
}
}
else
if
(
template
.
contains
(
"service.java.vm"
))
{
else
if
(
template
.
contains
(
"service.java.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/service/I{}Service.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/service/I{}Service.java"
,
javaPath
,
className
);
}
}
else
if
(
template
.
contains
(
"serviceImpl.java.vm"
))
{
else
if
(
template
.
contains
(
"serviceImpl.java.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/service/impl/{}ServiceImpl.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/service/impl/{}ServiceImpl.java"
,
javaPath
,
className
);
}
}
else
if
(
template
.
contains
(
"controller.java.vm"
))
{
else
if
(
template
.
contains
(
"controller.java.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/controller/{}Controller.java"
,
javaPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/controller/{}Controller.java"
,
javaPath
,
className
);
}
}
else
if
(
template
.
contains
(
"mapper.xml.vm"
))
{
else
if
(
template
.
contains
(
"mapper.xml.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/{}Mapper.xml"
,
mybatisPath
,
className
);
fileName
=
StringUtils
.
format
(
"{}/{}Mapper.xml"
,
mybatisPath
,
className
);
}
}
else
if
(
template
.
contains
(
"sql.vm"
))
{
else
if
(
template
.
contains
(
"sql.vm"
))
{
fileName
=
businessName
+
"Menu.sql"
;
fileName
=
businessName
+
"Menu.sql"
;
}
}
else
if
(
template
.
contains
(
"api.js.vm"
))
{
else
if
(
template
.
contains
(
"api.js.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/api/{}/{}.js"
,
vuePath
,
moduleName
,
businessName
);
fileName
=
StringUtils
.
format
(
"{}/api/{}/{}.js"
,
vuePath
,
moduleName
,
businessName
);
}
}
else
if
(
template
.
contains
(
"index.vue.vm"
))
{
else
if
(
template
.
contains
(
"index.vue.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/views/{}/{}/index.vue"
,
vuePath
,
moduleName
,
businessName
);
fileName
=
StringUtils
.
format
(
"{}/views/{}/{}/index.vue"
,
vuePath
,
moduleName
,
businessName
);
}
}
else
if
(
template
.
contains
(
"index-tree.vue.vm"
))
{
else
if
(
template
.
contains
(
"index-tree.vue.vm"
))
{
fileName
=
StringUtils
.
format
(
"{}/views/{}/{}/index.vue"
,
vuePath
,
moduleName
,
businessName
);
fileName
=
StringUtils
.
format
(
"{}/views/{}/{}/index.vue"
,
vuePath
,
moduleName
,
businessName
);
}
}
return
fileName
;
return
fileName
;
...
@@ -226,8 +201,7 @@ public class VelocityUtils
...
@@ -226,8 +201,7 @@ public class VelocityUtils
* @param packageName 包名称
* @param packageName 包名称
* @return 包前缀名称
* @return 包前缀名称
*/
*/
public
static
String
getPackagePrefix
(
String
packageName
)
public
static
String
getPackagePrefix
(
String
packageName
)
{
{
int
lastIndex
=
packageName
.
lastIndexOf
(
"."
);
int
lastIndex
=
packageName
.
lastIndexOf
(
"."
);
return
StringUtils
.
substring
(
packageName
,
0
,
lastIndex
);
return
StringUtils
.
substring
(
packageName
,
0
,
lastIndex
);
}
}
...
@@ -238,24 +212,18 @@ public class VelocityUtils
...
@@ -238,24 +212,18 @@ public class VelocityUtils
* @param genTable 业务表对象
* @param genTable 业务表对象
* @return 返回需要导入的包列表
* @return 返回需要导入的包列表
*/
*/
public
static
HashSet
<
String
>
getImportList
(
GenTable
genTable
)
public
static
HashSet
<
String
>
getImportList
(
GenTable
genTable
)
{
{
List
<
GenTableColumn
>
columns
=
genTable
.
getColumns
();
List
<
GenTableColumn
>
columns
=
genTable
.
getColumns
();
GenTable
subGenTable
=
genTable
.
getSubTable
();
GenTable
subGenTable
=
genTable
.
getSubTable
();
HashSet
<
String
>
importList
=
new
HashSet
<
String
>();
HashSet
<
String
>
importList
=
new
HashSet
<
String
>();
if
(
StringUtils
.
isNotNull
(
subGenTable
))
if
(
StringUtils
.
isNotNull
(
subGenTable
))
{
{
importList
.
add
(
"java.util.List"
);
importList
.
add
(
"java.util.List"
);
}
}
for
(
GenTableColumn
column
:
columns
)
for
(
GenTableColumn
column
:
columns
)
{
{
if
(!
column
.
isSuperColumn
()
&&
GenConstants
.
TYPE_DATE
.
equals
(
column
.
getJavaType
()))
{
if
(!
column
.
isSuperColumn
()
&&
GenConstants
.
TYPE_DATE
.
equals
(
column
.
getJavaType
()))
{
importList
.
add
(
"java.util.Date"
);
importList
.
add
(
"java.util.Date"
);
importList
.
add
(
"com.fasterxml.jackson.annotation.JsonFormat"
);
importList
.
add
(
"com.fasterxml.jackson.annotation.JsonFormat"
);
}
}
else
if
(!
column
.
isSuperColumn
()
&&
GenConstants
.
TYPE_BIGDECIMAL
.
equals
(
column
.
getJavaType
()))
{
else
if
(!
column
.
isSuperColumn
()
&&
GenConstants
.
TYPE_BIGDECIMAL
.
equals
(
column
.
getJavaType
()))
{
importList
.
add
(
"java.math.BigDecimal"
);
importList
.
add
(
"java.math.BigDecimal"
);
}
}
}
}
...
@@ -268,13 +236,11 @@ public class VelocityUtils
...
@@ -268,13 +236,11 @@ public class VelocityUtils
* @param genTable 业务表对象
* @param genTable 业务表对象
* @return 返回字典组
* @return 返回字典组
*/
*/
public
static
String
getDicts
(
GenTable
genTable
)
public
static
String
getDicts
(
GenTable
genTable
)
{
{
List
<
GenTableColumn
>
columns
=
genTable
.
getColumns
();
List
<
GenTableColumn
>
columns
=
genTable
.
getColumns
();
Set
<
String
>
dicts
=
new
HashSet
<
String
>();
Set
<
String
>
dicts
=
new
HashSet
<
String
>();
addDicts
(
dicts
,
columns
);
addDicts
(
dicts
,
columns
);
if
(
StringUtils
.
isNotNull
(
genTable
.
getSubTable
()))
if
(
StringUtils
.
isNotNull
(
genTable
.
getSubTable
()))
{
{
List
<
GenTableColumn
>
subColumns
=
genTable
.
getSubTable
().
getColumns
();
List
<
GenTableColumn
>
subColumns
=
genTable
.
getSubTable
().
getColumns
();
addDicts
(
dicts
,
subColumns
);
addDicts
(
dicts
,
subColumns
);
}
}
...
@@ -287,14 +253,11 @@ public class VelocityUtils
...
@@ -287,14 +253,11 @@ public class VelocityUtils
* @param dicts 字典列表
* @param dicts 字典列表
* @param columns 列集合
* @param columns 列集合
*/
*/
public
static
void
addDicts
(
Set
<
String
>
dicts
,
List
<
GenTableColumn
>
columns
)
public
static
void
addDicts
(
Set
<
String
>
dicts
,
List
<
GenTableColumn
>
columns
)
{
{
for
(
GenTableColumn
column
:
columns
)
{
for
(
GenTableColumn
column
:
columns
)
{
if
(!
column
.
isSuperColumn
()
&&
StringUtils
.
isNotEmpty
(
column
.
getDictType
())
&&
StringUtils
.
equalsAny
(
if
(!
column
.
isSuperColumn
()
&&
StringUtils
.
isNotEmpty
(
column
.
getDictType
())
&&
StringUtils
.
equalsAny
(
column
.
getHtmlType
(),
column
.
getHtmlType
(),
new
String
[]
{
GenConstants
.
HTML_SELECT
,
GenConstants
.
HTML_RADIO
,
GenConstants
.
HTML_CHECKBOX
}))
new
String
[]{
GenConstants
.
HTML_SELECT
,
GenConstants
.
HTML_RADIO
,
GenConstants
.
HTML_CHECKBOX
}))
{
{
dicts
.
add
(
"'"
+
column
.
getDictType
()
+
"'"
);
dicts
.
add
(
"'"
+
column
.
getDictType
()
+
"'"
);
}
}
}
}
...
@@ -307,8 +270,7 @@ public class VelocityUtils
...
@@ -307,8 +270,7 @@ public class VelocityUtils
* @param businessName 业务名称
* @param businessName 业务名称
* @return 返回权限前缀
* @return 返回权限前缀
*/
*/
public
static
String
getPermissionPrefix
(
String
moduleName
,
String
businessName
)
public
static
String
getPermissionPrefix
(
String
moduleName
,
String
businessName
)
{
{
return
StringUtils
.
format
(
"{}:{}"
,
moduleName
,
businessName
);
return
StringUtils
.
format
(
"{}:{}"
,
moduleName
,
businessName
);
}
}
...
@@ -318,11 +280,9 @@ public class VelocityUtils
...
@@ -318,11 +280,9 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @param paramsObj 生成其他选项
* @return 上级菜单ID字段
* @return 上级菜单ID字段
*/
*/
public
static
String
getParentMenuId
(
JSONObject
paramsObj
)
public
static
String
getParentMenuId
(
JSONObject
paramsObj
)
{
{
if
(
StringUtils
.
isNotEmpty
(
paramsObj
)
&&
paramsObj
.
containsKey
(
GenConstants
.
PARENT_MENU_ID
)
if
(
StringUtils
.
isNotEmpty
(
paramsObj
)
&&
paramsObj
.
containsKey
(
GenConstants
.
PARENT_MENU_ID
)
&&
StringUtils
.
isNotEmpty
(
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_ID
)))
&&
StringUtils
.
isNotEmpty
(
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_ID
)))
{
{
return
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_ID
);
return
paramsObj
.
getString
(
GenConstants
.
PARENT_MENU_ID
);
}
}
return
DEFAULT_PARENT_MENU_ID
;
return
DEFAULT_PARENT_MENU_ID
;
...
@@ -334,10 +294,8 @@ public class VelocityUtils
...
@@ -334,10 +294,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @param paramsObj 生成其他选项
* @return 树编码
* @return 树编码
*/
*/
public
static
String
getTreecode
(
JSONObject
paramsObj
)
public
static
String
getTreecode
(
JSONObject
paramsObj
)
{
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_CODE
))
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_CODE
))
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
));
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
));
}
}
return
StringUtils
.
EMPTY
;
return
StringUtils
.
EMPTY
;
...
@@ -349,10 +307,8 @@ public class VelocityUtils
...
@@ -349,10 +307,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @param paramsObj 生成其他选项
* @return 树父编码
* @return 树父编码
*/
*/
public
static
String
getTreeParentCode
(
JSONObject
paramsObj
)
public
static
String
getTreeParentCode
(
JSONObject
paramsObj
)
{
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_PARENT_CODE
))
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_PARENT_CODE
))
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
));
}
}
return
StringUtils
.
EMPTY
;
return
StringUtils
.
EMPTY
;
...
@@ -364,10 +320,8 @@ public class VelocityUtils
...
@@ -364,10 +320,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @param paramsObj 生成其他选项
* @return 树名称
* @return 树名称
*/
*/
public
static
String
getTreeName
(
JSONObject
paramsObj
)
public
static
String
getTreeName
(
JSONObject
paramsObj
)
{
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_NAME
))
{
if
(
paramsObj
.
containsKey
(
GenConstants
.
TREE_NAME
))
{
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
return
StringUtils
.
toCamelCase
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
));
}
}
return
StringUtils
.
EMPTY
;
return
StringUtils
.
EMPTY
;
...
@@ -379,20 +333,16 @@ public class VelocityUtils
...
@@ -379,20 +333,16 @@ public class VelocityUtils
* @param genTable 业务表对象
* @param genTable 业务表对象
* @return 展开按钮列序号
* @return 展开按钮列序号
*/
*/
public
static
int
getExpandColumn
(
GenTable
genTable
)
public
static
int
getExpandColumn
(
GenTable
genTable
)
{
{
String
options
=
genTable
.
getOptions
();
String
options
=
genTable
.
getOptions
();
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
JSONObject
paramsObj
=
JSON
.
parseObject
(
options
);
String
treeName
=
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
);
String
treeName
=
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
);
int
num
=
0
;
int
num
=
0
;
for
(
GenTableColumn
column
:
genTable
.
getColumns
())
for
(
GenTableColumn
column
:
genTable
.
getColumns
())
{
{
if
(
column
.
isList
())
{
if
(
column
.
isList
())
{
num
++;
num
++;
String
columnName
=
column
.
getColumnName
();
String
columnName
=
column
.
getColumnName
();
if
(
columnName
.
equals
(
treeName
))
if
(
columnName
.
equals
(
treeName
))
{
{
break
;
break
;
}
}
}
}
...
...
ruoyi-generator/src/main/resources/vm/java/controller.java.vm
View file @
8d8172b8
package
${
packageName
}.
controller
;
package
${
packageName
}.
controller
;
import
java
.
util
.
List
;
import
javax
.
servlet
.
http
.
HttpServletResponse
;
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
.
common
.
annotation
.
Log
;
import
com
.
ruoyi
.
common
.
annotation
.
Log
;
import
com
.
ruoyi
.
common
.
core
.
controller
.
BaseController
;
import
com
.
ruoyi
.
common
.
core
.
controller
.
BaseController
;
import
com
.
ruoyi
.
common
.
core
.
domain
.
AjaxResult
;
import
com
.
ruoyi
.
common
.
core
.
domain
.
AjaxResult
;
import
com
.
ruoyi
.
common
.
enums
.
BusinessType
;
import
com
.
ruoyi
.
common
.
enums
.
BusinessType
;
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
import
com
.
ruoyi
.
common
.
utils
.
poi
.
ExcelUtil
;
import
com
.
ruoyi
.
common
.
utils
.
poi
.
ExcelUtil
;
#
if
($
table
.
crud
||
$
table
.
sub
)
import
${
packageName
}.
vo
.${
ClassName
}
Vo
;
import
com
.
ruoyi
.
common
.
core
.
page
.
TableDataInfo
;
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
#
elseif
($
table
.
tree
)
import
io
.
swagger
.
annotations
.
Api
;
#
end
import
io
.
swagger
.
annotations
.
ApiOperation
;
import
lombok
.
RequiredArgsConstructor
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
security
.
access
.
prepost
.
PreAuthorize
;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
#
if
($
table
.
crud
||
$
table
.
sub
)
import
com
.
ruoyi
.
common
.
core
.
page
.
TableDataInfo
;
#
elseif
($
table
.
tree
)
#
end
import
javax
.
servlet
.
http
.
HttpServletResponse
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
List
;
/**
/**
*
${
functionName
}
Controller
*
${
functionName
}
Controller
...
@@ -30,86 +28,71 @@ import com.ruoyi.common.core.page.TableDataInfo;
...
@@ -30,86 +28,71 @@ import com.ruoyi.common.core.page.TableDataInfo;
*
@
author
${
author
}
*
@
author
${
author
}
*
@
date
${
datetime
}
*
@
date
${
datetime
}
*/
*/
@
Api
(
tags
=
"${functionName}Controller"
)
@
RestController
@
RestController
@
RequestMapping
(
"/${moduleName}/${businessName}"
)
@
RequestMapping
(
"/${moduleName}/${businessName}"
)
public
class
${
ClassName
}
Controller
extends
BaseController
@
RequiredArgsConstructor
(
onConstructor_
=
@
Autowired
)
{
public
class
${
ClassName
}
Controller
extends
BaseController
{
@
Autowired
private
I
${
ClassName
}
Service
${
className
}
Service
;
/**
private
final
I
${
ClassName
}
Service
${
className
}
Service
;
*
查询
${
functionName
}
列表
*/
@
ApiOperation
(
"查询${functionName}列表"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:list')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:list')"
)
@
GetMapping
(
"/list"
)
@
GetMapping
(
"/list"
)
#
if
($
table
.
crud
||
$
table
.
sub
)
#
if
($
table
.
crud
||
$
table
.
sub
)
public
TableDataInfo
list
(${
ClassName
}
${
className
})
public
TableDataInfo
<${
ClassName
}
Vo
>
list
(${
ClassName
}
Vo
entity
)
{
{
return
${
className
}
Service
.
queryList
(
entity
);
startPage
();
List
<${
ClassName
}>
list
=
${
className
}
Service
.
select
${
ClassName
}
List
(${
className
});
return
getDataTable
(
list
);
}
}
#
elseif
($
table
.
tree
)
#
elseif
($
table
.
tree
)
public
AjaxResult
list
(${
ClassName
}
${
className
})
public
AjaxResult
list
(${
ClassName
}
Vo
entity
)
{
{
return
AjaxResult
.
success
(
"查询成功"
,
${
className
}
Service
.
queryAll
(
entity
));
List
<${
ClassName
}>
list
=
${
className
}
Service
.
select
${
ClassName
}
List
(${
className
});
return
success
(
list
);
}
}
#
end
#
end
/**
@
ApiOperation
(
"查询${functionName}所有列表"
)
*
导出
${
functionName
}
列表
@
GetMapping
(
"/listAll"
)
*/
public
AjaxResult
listAll
(${
ClassName
}
Vo
entity
)
{
return
AjaxResult
.
success
(
"查询成功"
,
${
className
}
Service
.
queryAll
(
entity
));
}
@
ApiOperation
(
"导出${functionName}列表"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:export')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:export')"
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
EXPORT
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
EXPORT
)
@
PostMapping
(
"/export"
)
@
PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
${
ClassName
}
${
className
})
public
void
export
(
HttpServletResponse
response
,
${
ClassName
}
Vo
entity
)
{
{
List
<${
ClassName
}
Vo
>
list
=
${
className
}
Service
.
queryAll
(
entity
);
List
<${
ClassName
}>
list
=
${
className
}
Service
.
select
${
ClassName
}
List
(${
className
});
ExcelUtil
<${
ClassName
}
Vo
>
util
=
new
ExcelUtil
<>(${
ClassName
}
Vo
.
class
);
ExcelUtil
<${
ClassName
}>
util
=
new
ExcelUtil
<${
ClassName
}>(${
ClassName
}.
class
);
util
.
exportExcel
(
response
,
list
,
"${functionName}数据"
);
util
.
exportExcel
(
response
,
list
,
"${functionName}数据"
);
}
}
/**
@
ApiOperation
(
"获取${functionName}详细信息"
)
*
获取
${
functionName
}
详细信息
*/
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:query')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:query')"
)
@
GetMapping
(
value
=
"/{${pkColumn.javaField}}"
)
@
GetMapping
(
value
=
"/getInfo/{${pkColumn.javaField}}"
)
public
AjaxResult
getInfo
(@
PathVariable
(
"${pkColumn.javaField}"
)
${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
})
public
AjaxResult
getInfo
(@
PathVariable
(
"${pkColumn.javaField}"
)
${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
})
{
{
return
AjaxResult
.
success
(
"查询成功"
,
${
className
}
Service
.
queryById
(${
pkColumn
.
javaField
}));
return
success
(${
className
}
Service
.
select
${
ClassName
}
By
${
pkColumn
.
capJavaField
}(${
pkColumn
.
javaField
}));
}
}
/**
@
ApiOperation
(
"新增${functionName}"
)
*
新增
${
functionName
}
*/
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:add')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:add')"
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
INSERT
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
INSERT
)
@
PostMapping
@
PostMapping
(
"add"
)
public
AjaxResult
add
(@
RequestBody
${
ClassName
}
${
className
})
public
AjaxResult
add
(@
RequestBody
${
ClassName
}
Vo
entity
)
{
{
return
toAjax
(${
className
}
Service
.
save
(
entity
));
return
toAjax
(${
className
}
Service
.
insert
${
ClassName
}(${
className
}));
}
}
/**
@
ApiOperation
(
"修改${functionName}"
)
*
修改
${
functionName
}
*/
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:edit')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:edit')"
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
UPDATE
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
UPDATE
)
@
PutMapping
@
PostMapping
(
"edit"
)
public
AjaxResult
edit
(@
RequestBody
${
ClassName
}
${
className
})
public
AjaxResult
edit
(@
RequestBody
${
ClassName
}
Vo
entity
)
{
{
return
toAjax
(${
className
}
Service
.
updateById
(
entity
));
return
toAjax
(${
className
}
Service
.
update
${
ClassName
}(${
className
}));
}
}
/**
@
ApiOperation
(
"删除${functionName}"
)
*
删除
${
functionName
}
*/
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:remove')"
)
@
PreAuthorize
(
"@ss.hasPermi('${permissionPrefix}:remove')"
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
DELETE
)
@
Log
(
title
=
"${functionName}"
,
businessType
=
BusinessType
.
DELETE
)
@
DeleteMapping
(
"/{${pkColumn.javaField}s}"
)
@
GetMapping
(
"/remove/{${pkColumn.javaField}s}"
)
public
AjaxResult
remove
(@
PathVariable
${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
)
public
AjaxResult
remove
(@
PathVariable
${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
)
{
{
return
toAjax
(${
className
}
Service
.
removeByIds
(
Arrays
.
asList
(
ids
))
?
1
:
0
);
return
toAjax
(${
className
}
Service
.
delete
${
ClassName
}
By
${
pkColumn
.
capJavaField
}
s
(${
pkColumn
.
javaField
}
s
));
}
}
}
}
ruoyi-generator/src/main/resources/vm/js/api.js.vm
View file @
8d8172b8
...
@@ -9,10 +9,19 @@ export function list${BusinessName}(query) {
...
@@ -9,10 +9,19 @@ export function list${BusinessName}(query) {
})
})
}
}
// 查询${functionName}所有列表
export function listAll${BusinessName}(query) {
return request({
url: '/${moduleName}/${businessName}/listAll',
method: 'get',
params: query
})
}
// 查询${functionName}详细
// 查询${functionName}详细
export function get${BusinessName}(${pkColumn.javaField}) {
export function get${BusinessName}(${pkColumn.javaField}) {
return request({
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
url: '/${moduleName}/${businessName}/
getInfo/
' + ${pkColumn.javaField},
method: 'get'
method: 'get'
})
})
}
}
...
@@ -20,7 +29,7 @@ export function get${BusinessName}(${pkColumn.javaField}) {
...
@@ -20,7 +29,7 @@ export function get${BusinessName}(${pkColumn.javaField}) {
// 新增${functionName}
// 新增${functionName}
export function add${BusinessName}(data) {
export function add${BusinessName}(data) {
return request({
return request({
url: '/${moduleName}/${businessName}',
url: '/${moduleName}/${businessName}
/add
',
method: 'post',
method: 'post',
data: data
data: data
})
})
...
@@ -29,8 +38,8 @@ export function add${BusinessName}(data) {
...
@@ -29,8 +38,8 @@ export function add${BusinessName}(data) {
// 修改${functionName}
// 修改${functionName}
export function update${BusinessName}(data) {
export function update${BusinessName}(data) {
return request({
return request({
url: '/${moduleName}/${businessName}',
url: '/${moduleName}/${businessName}
/edit
',
method: 'p
u
t',
method: 'p
os
t',
data: data
data: data
})
})
}
}
...
@@ -38,7 +47,7 @@ export function update${BusinessName}(data) {
...
@@ -38,7 +47,7 @@ export function update${BusinessName}(data) {
// 删除${functionName}
// 删除${functionName}
export function del${BusinessName}(${pkColumn.javaField}) {
export function del${BusinessName}(${pkColumn.javaField}) {
return request({
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
url: '/${moduleName}/${businessName}/
remove/
' + ${pkColumn.javaField},
method: '
delete
'
method: '
get
'
})
})
}
}
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
View file @
8d8172b8
<template>
<template>
<div class="app-container">
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
#foreach($column in $columns)
#foreach($column in $columns)
#if($column.query)
#if($column.query)
#set($dictType=$column.dictType)
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf("("))
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#else
#set($comment=$column.columnComment)
#set($comment=$column.columnComment)
#end
#end
#if($column.htmlType == "input")
#if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${column.javaField}">
<el-form-item label="${comment}" prop="${column.javaField}">
<el-input
<el-input
v-model="queryParams.${column.javaField}"
v-model="queryParams.${column.javaField}"
...
@@ -20,9 +20,9 @@
...
@@ -20,9 +20,9 @@
@keyup.enter.native="handleQuery"
@keyup.enter.native="handleQuery"
/>
/>
</el-form-item>
</el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}">
<el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clea
rable>
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable filte
rable>
<el-option
<el-option
v-for="dict in dict.type.${dictType}"
v-for="dict in dict.type.${dictType}"
:key="dict.value"
:key="dict.value"
...
@@ -31,36 +31,36 @@
...
@@ -31,36 +31,36 @@
/>
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}">
<el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clea
rable>
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable filte
rable>
<el-option label="请选择字典生成" value="" />
<el-option label="请选择字典生成" value="" />
</el-select>
</el-select>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}">
<el-form-item label="${comment}" prop="${column.javaField}">
<el-date-picker clearable
<el-date-picker clearable
v-model="queryParams.${column.javaField}"
v-model="queryParams.${column.javaField}"
type="date"
type="date"
value-format="yyyy-MM-dd
"
value-format="yyyy-MM-dd HH:mm:ss
"
placeholder="请选择${comment}">
placeholder="请选择${comment}">
</el-date-picker>
</el-date-picker>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
<el-form-item label="${comment}">
<el-form-item label="${comment}">
<el-date-picker
<el-date-picker
v-model="daterange${AttrName}"
v-model="daterange${AttrName}"
style="width: 240px"
style="width: 240px"
value-format="yyyy-MM-dd
"
value-format="yyyy-MM-dd HH:mm:ss
"
type="daterange"
type="daterange"
range-separator="-"
range-separator="-"
start-placeholder="开始日期"
start-placeholder="开始日期"
end-placeholder="结束日期"
end-placeholder="结束日期"
></el-date-picker>
></el-date-picker>
</el-form-item>
</el-form-item>
#end
#end
#end
#end
#end
#end
<el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
...
@@ -115,42 +115,42 @@
...
@@ -115,42 +115,42 @@
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="selection" width="55" align="center" />
#foreach($column in $columns)
#foreach($column in $columns)
#set($javaField=$column.javaField)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf("("))
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#else
#set($comment=$column.columnComment)
#set($comment=$column.columnComment)
#end
#end
#if($column.pk)
#if($column.pk)
<el-table-column label="${comment}" align="center" prop="${javaField}" />
<el-table-column label="${comment}" align="center" prop="${javaField}" />
#elseif($column.list && $column.htmlType == "datetime")
#elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<template slot-scope="scope">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}'
) }}</span>
<span>{{ parseTime(scope.row.${javaField}
) }}</span>
</template>
</template>
</el-table-column>
</el-table-column>
#elseif($column.list && $column.htmlType == "imageUpload")
#elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
<template slot-scope="scope">
<template slot-scope="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template>
</template>
</el-table-column>
</el-table-column>
#elseif($column.list && "" != $column.dictType)
#elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}">
<el-table-column label="${comment}" align="center" prop="${javaField}">
<template slot-scope="scope">
<template slot-scope="scope">
#if($column.htmlType == "checkbox")
#if($column.htmlType == "checkbox")
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
#else
#else
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
#end
#end
</template>
</template>
</el-table-column>
</el-table-column>
#elseif($column.list && "" != $javaField)
#elseif($column.list && "" != $javaField)
<el-table-column label="${comment}" align="center" prop="${javaField}" />
<el-table-column label="${comment}" align="center" prop="${javaField}" />
#end
#end
#end
#end
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<template slot-scope="scope">
<el-button
<el-button
...
@@ -182,36 +182,36 @@
...
@@ -182,36 +182,36 @@
<!-- 添加或修改${functionName}对话框 -->
<!-- 添加或修改${functionName}对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns)
#foreach($column in $columns)
#set($field=$column.javaField)
#set($field=$column.javaField)
#if($column.insert && !$column.pk)
#if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf("("))
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#else
#set($comment=$column.columnComment)
#set($comment=$column.columnComment)
#end
#end
#set($dictType=$column.dictType)
#set($dictType=$column.dictType)
#if($column.htmlType == "input")
#if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${field}">
<el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "imageUpload")
#elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment
}">
<el-form-item label="${comment}" prop="${field
}">
<image-upload v-model="form.${field}"/>
<image-upload v-model="form.${field}"/>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "fileUpload")
#elseif($column.htmlType == "fileUpload")
<el-form-item label="${comment
}">
<el-form-item label="${comment}" prop="${field
}">
<file-upload v-model="form.${field}"/>
<file-upload v-model="form.${field}"/>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "editor")
#elseif($column.htmlType == "editor")
<el-form-item label="${comment
}">
<el-form-item label="${comment}" prop="${field
}">
<editor v-model="form.${field}" :min-height="192"/>
<editor v-model="form.${field}" :min-height="192"/>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "select" && "" != $dictType)
#elseif($column.htmlType == "select" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}"
>
<el-select v-model="form.${field}" placeholder="请选择${comment}" filterable
>
<el-option
<el-option
v-for="dict in dict.type.${dictType}"
v-for="dict in dict.type.${dictType}"
:key="dict.value"
:key="dict.value"
...
@@ -221,13 +221,13 @@
...
@@ -221,13 +221,13 @@
></el-option>
></el-option>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "select" && $dictType)
#elseif($column.htmlType == "select" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}"
>
<el-select v-model="form.${field}" placeholder="请选择${comment}" filterable
>
<el-option label="请选择字典生成" value="" />
<el-option label="请选择字典生成" value="" />
</el-select>
</el-select>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<el-form-item label="${comment}">
<el-form-item label="${comment}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox
<el-checkbox
...
@@ -238,13 +238,13 @@
...
@@ -238,13 +238,13 @@
</el-checkbox>
</el-checkbox>
</el-checkbox-group>
</el-checkbox-group>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "checkbox" && $dictType)
#elseif($column.htmlType == "checkbox" && $dictType)
<el-form-item label="${comment}">
<el-form-item label="${comment}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox>请选择字典生成</el-checkbox>
<el-checkbox>请选择字典生成</el-checkbox>
</el-checkbox-group>
</el-checkbox-group>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "radio" && "" != $dictType)
#elseif($column.htmlType == "radio" && "" != $dictType)
<el-form-item label="${comment}">
<el-form-item label="${comment}">
<el-radio-group v-model="form.${field}">
<el-radio-group v-model="form.${field}">
<el-radio
<el-radio
...
@@ -255,30 +255,30 @@
...
@@ -255,30 +255,30 @@
>{{dict.label}}</el-radio>
>{{dict.label}}</el-radio>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "radio" && $dictType)
#elseif($column.htmlType == "radio" && $dictType)
<el-form-item label="${comment}">
<el-form-item label="${comment}">
<el-radio-group v-model="form.${field}">
<el-radio-group v-model="form.${field}">
<el-radio label="1">请选择字典生成</el-radio>
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "datetime")
#elseif($column.htmlType == "datetime")
<el-form-item label="${comment}" prop="${field}">
<el-form-item label="${comment}" prop="${field}">
<el-date-picker clearable
<el-date-picker clearable
v-model="form.${field}"
v-model="form.${field}"
type="date"
type="date"
value-format="yyyy-MM-dd
"
value-format="yyyy-MM-dd HH:mm:ss
"
placeholder="请选择${comment}">
placeholder="请选择${comment}">
</el-date-picker>
</el-date-picker>
</el-form-item>
</el-form-item>
#elseif($column.htmlType == "textarea")
#elseif($column.htmlType == "textarea")
<el-form-item label="${comment}" prop="${field}">
<el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form-item>
#end
#end
#end
#end
#end
#end
#end
#end
#if($table.sub)
#if($table.sub)
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-col :span="1.5">
...
@@ -291,31 +291,31 @@
...
@@ -291,31 +291,31 @@
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="序号" align="center" prop="index" width="50"/>
#foreach($column in $subTable.columns)
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf("("))
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#else
#set($comment=$column.columnComment)
#set($comment=$column.columnComment)
#end
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && $column.htmlType == "input")
#elseif($column.list && $column.htmlType == "input")
<el-table-column label="$comment" prop="${javaField}" width="150">
<el-table-column label="$comment" prop="${javaField}" width="150">
<template slot-scope="scope">
<template slot-scope="scope">
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
</template>
</template>
</el-table-column>
</el-table-column>
#elseif($column.list && $column.htmlType == "datetime")
#elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="$comment" prop="${javaField}" width="240">
<el-table-column label="$comment" prop="${javaField}" width="240">
<template slot-scope="scope">
<template slot-scope="scope">
<el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd
" placeholder="请选择$comment" />
<el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd HH:mm:ss
" placeholder="请选择$comment" />
</template>
</template>
</el-table-column>
</el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
<el-table-column label="$comment" prop="${javaField}" width="150">
<el-table-column label="$comment" prop="${javaField}" width="150">
<template slot-scope="scope">
<template slot-scope="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment"
>
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment" filterable
>
<el-option
<el-option
v-for="dict in dict.type.$column.dictType"
v-for="dict in dict.type.$column.dictType"
:key="dict.value"
:key="dict.value"
...
@@ -325,18 +325,18 @@
...
@@ -325,18 +325,18 @@
</el-select>
</el-select>
</template>
</template>
</el-table-column>
</el-table-column>
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
<el-table-column label="$comment" prop="${javaField}" width="150">
<el-table-column label="$comment" prop="${javaField}" width="150">
<template slot-scope="scope">
<template slot-scope="scope">
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment"
>
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment" filterable
>
<el-option label="请选择字典生成" value="" />
<el-option label="请选择字典生成" value="" />
</el-select>
</el-select>
</template>
</template>
</el-table-column>
</el-table-column>
#end
#end
#end
#end
</el-table>
</el-table>
#end
#end
</el-form>
</el-form>
<div slot="footer" class="dialog-footer">
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button type="primary" @click="submitForm">确 定</el-button>
...
@@ -347,23 +347,25 @@
...
@@ -347,23 +347,25 @@
</template>
</template>
<script>
<script>
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
export default {
export default {
name: "${BusinessName}",
name: "${BusinessName}",
#if(${dicts} != '')
#if(${dicts} != '')
dicts: [${dicts}],
dicts: [${dicts}],
#end
#end
data() {
data() {
return {
return {
// 根路径
baseURL: process.env.VUE_APP_BASE_API,
// 遮罩层
// 遮罩层
loading: true,
loading: true,
// 选中数组
// 选中数组
ids: [],
ids: [],
#if($table.sub)
#if($table.sub)
// 子表选中数据
// 子表选中数据
checked${subClassName}: [],
checked${subClassName}: [],
#end
#end
// 非单个禁用
// 非单个禁用
single: true,
single: true,
// 非多个禁用
// 非多个禁用
...
@@ -374,48 +376,48 @@ export default {
...
@@ -374,48 +376,48 @@ export default {
total: 0,
total: 0,
// ${functionName}表格数据
// ${functionName}表格数据
${businessName}List: [],
${businessName}List: [],
#if($table.sub)
#if($table.sub)
// ${subTable.functionName}表格数据
// ${subTable.functionName}表格数据
${subclassName}List: [],
${subclassName}List: [],
#end
#end
// 弹出层标题
// 弹出层标题
title: "",
title: "",
// 是否显示弹出层
// 是否显示弹出层
open: false,
open: false,
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
// $comment时间范围
// $comment时间范围
daterange${AttrName}: [],
daterange${AttrName}: [],
#end
#end
#end
#end
// 查询参数
// 查询参数
queryParams: {
queryParams: {
pageNum: 1,
pageNum: 1,
pageSize: 10,
pageSize: 10,
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.query)
#if($column.query)
$column.javaField: null#if($foreach.count != $columns.size()),#end
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
#end
#end
},
},
// 表单参数
// 表单参数
form: {},
form: {},
// 表单校验
// 表单校验
rules: {
rules: {
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.required
)
#if($column.javaField != 'createBy' && $column.javaField != 'createTime' && $column.javaField != 'updateBy' && $column.javaField != 'updateTime' && $column.javaField != 'deleteStatus'
)
#set($parentheseIndex=$column.columnComment.indexOf("("))
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#else
#set($comment=$column.columnComment)
#set($comment=$column.columnComment)
#end
#end
$column.javaField: [
$column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
]#if($foreach.count != $columns.size()),#end
]#if($foreach.count != $columns.size()),#end
#end
#end
#end
#end
}
}
};
};
},
},
...
@@ -426,21 +428,21 @@ export default {
...
@@ -426,21 +428,21 @@ export default {
/** 查询${functionName}列表 */
/** 查询${functionName}列表 */
getList() {
getList() {
this.loading = true;
this.loading = true;
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
this.queryParams.params = {};
this.queryParams.params = {};
#break
#break
#end
#end
#end
#end
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
}
}
#end
#end
#end
#end
list${BusinessName}(this.queryParams).then(response => {
list${BusinessName}(this.queryParams).then(response => {
this.${businessName}List = response.rows;
this.${businessName}List = response.rows;
this.total = response.total;
this.total = response.total;
...
@@ -455,19 +457,20 @@ export default {
...
@@ -455,19 +457,20 @@ export default {
// 表单重置
// 表单重置
reset() {
reset() {
this.form = {
this.form = {
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "radio")
#if($column.javaField == 'createBy' || $column.javaField == 'createTime' || $column.javaField == 'updateBy' || $column.javaField == 'updateTime' || $column.javaField == 'deleteStatus')
#elseif($column.htmlType == "radio")
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
#elseif($column.htmlType == "checkbox")
#elseif($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end
$column.javaField: []#if($foreach.count != $columns.size()),#end
#else
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
#end
#end
};
};
#if($table.sub)
#if($table.sub)
this.${subclassName}List = [];
this.${subclassName}List = [];
#end
#end
this.resetForm("form");
this.resetForm("form");
},
},
/** 搜索按钮操作 */
/** 搜索按钮操作 */
...
@@ -477,12 +480,12 @@ export default {
...
@@ -477,12 +480,12 @@ export default {
},
},
/** 重置按钮操作 */
/** 重置按钮操作 */
resetQuery() {
resetQuery() {
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
this.daterange${AttrName} = [];
this.daterange${AttrName} = [];
#end
#end
#end
#end
this.resetForm("queryForm");
this.resetForm("queryForm");
this.handleQuery();
this.handleQuery();
},
},
...
@@ -504,14 +507,14 @@ export default {
...
@@ -504,14 +507,14 @@ export default {
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
get${BusinessName}(${pkColumn.javaField}).then(response => {
get${BusinessName}(${pkColumn.javaField}).then(response => {
this.form = response.data;
this.form = response.data;
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
#if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.split(",");
this.form.$column.javaField = this.form.${column.javaField}.split(",");
#end
#end
#end
#end
#if($table.sub)
#if($table.sub)
this.${subclassName}List = response.data.${subclassName}List;
this.${subclassName}List = response.data.${subclassName}List;
#end
#end
this.open = true;
this.open = true;
this.title = "修改${functionName}";
this.title = "修改${functionName}";
});
});
...
@@ -520,14 +523,14 @@ export default {
...
@@ -520,14 +523,14 @@ export default {
submitForm() {
submitForm() {
this.#[[$]]#refs["form"].validate(valid => {
this.#[[$]]#refs["form"].validate(valid => {
if (valid) {
if (valid) {
#foreach ($column in $columns)
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
#if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.join(",");
this.form.$column.javaField = this.form.${column.javaField}.join(",");
#end
#end
#end
#end
#if($table.sub)
#if($table.sub)
this.form.${subclassName}List = this.${subclassName}List;
this.form.${subclassName}List = this.${subclassName}List;
#end
#end
if (this.form.${pkColumn.javaField} != null) {
if (this.form.${pkColumn.javaField} != null) {
update${BusinessName}(this.form).then(response => {
update${BusinessName}(this.form).then(response => {
this.#[[$modal]]#.msgSuccess("修改成功");
this.#[[$modal]]#.msgSuccess("修改成功");
...
@@ -554,7 +557,7 @@ export default {
...
@@ -554,7 +557,7 @@ export default {
this.#[[$modal]]#.msgSuccess("删除成功");
this.#[[$modal]]#.msgSuccess("删除成功");
}).catch(() => {});
}).catch(() => {});
},
},
#if($table.sub)
#if($table.sub)
/** ${subTable.functionName}序号 */
/** ${subTable.functionName}序号 */
row${subClassName}Index({ row, rowIndex }) {
row${subClassName}Index({ row, rowIndex }) {
row.index = rowIndex + 1;
row.index = rowIndex + 1;
...
@@ -562,12 +565,12 @@ export default {
...
@@ -562,12 +565,12 @@ export default {
/** ${subTable.functionName}添加按钮操作 */
/** ${subTable.functionName}添加按钮操作 */
handleAdd${subClassName}() {
handleAdd${subClassName}() {
let obj = {};
let obj = {};
#foreach($column in $subTable.columns)
#foreach($column in $subTable.columns)
#if($column.pk || $column.javaField == ${subTableFkclassName})
#if($column.pk || $column.javaField == ${subTableFkclassName})
#elseif($column.list && "" != $javaField)
#elseif($column.list && "" != $javaField)
obj.$column.javaField = "";
obj.$column.javaField = "";
#end
#end
#end
#end
this.${subclassName}List.push(obj);
this.${subclassName}List.push(obj);
},
},
/** ${subTable.functionName}删除按钮操作 */
/** ${subTable.functionName}删除按钮操作 */
...
@@ -586,7 +589,7 @@ export default {
...
@@ -586,7 +589,7 @@ export default {
handle${subClassName}SelectionChange(selection) {
handle${subClassName}SelectionChange(selection) {
this.checked${subClassName} = selection.map(item => item.index)
this.checked${subClassName} = selection.map(item => item.index)
},
},
#end
#end
/** 导出按钮操作 */
/** 导出按钮操作 */
handleExport() {
handleExport() {
this.download('${moduleName}/${businessName}/export', {
this.download('${moduleName}/${businessName}/export', {
...
@@ -594,5 +597,5 @@ export default {
...
@@ -594,5 +597,5 @@ export default {
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
}
}
}
}
};
};
</script>
</script>
ruoyi-system/src/main/java/com/ruoyi/system/domain/FncSubjectType.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.system.domain
;
import
com.ruoyi.common.annotation.Excel
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.ruoyi.common.core.domain.BaseEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
lombok.experimental.Accessors
;
/**
* 科目类别对象 fnc_subject_type
*
* @author jlf
* @date 2022-11-17
*/
@Data
@Accessors
(
chain
=
true
)
@ToString
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
FncSubjectType
extends
BaseEntity
{
/**
* 科目类别id
*/
private
Long
subjectTypeId
;
/**
* 上级id
*/
@Excel
(
name
=
"上级id"
)
private
Long
parentId
;
/**
* 科目类别名称
*/
@Excel
(
name
=
"科目类别名称"
)
private
String
subjectTypeName
;
/**
* 显示顺序
*/
@Excel
(
name
=
"显示顺序"
)
private
Integer
orderNum
;
private
Integer
deleteStatus
;
}
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/FncSubjectTypeVo.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.system.domain.vo
;
import
com.ruoyi.common.core.domain.BaseEntity
;
import
com.ruoyi.system.domain.FncSubjectType
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.ToString
;
import
lombok.experimental.Accessors
;
/**
* 科目类别对象 fnc_subject_type
*
* @author jlf
* @date 2022-11-17
*/
@Data
@Accessors
(
chain
=
true
)
@ToString
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
FncSubjectTypeVo
extends
FncSubjectType
{
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/FncSubjectTypeMapper.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.system.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.ruoyi.system.domain.FncSubjectType
;
import
com.ruoyi.system.domain.vo.FncSubjectTypeVo
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 科目类别Mapper接口
*
* @author jlf
* @date 2022-11-17
*/
public
interface
FncSubjectTypeMapper
extends
BaseMapper
<
FncSubjectType
>
{
Page
<
FncSubjectTypeVo
>
queryList
(
Page
<?>
page
,
@Param
(
"entity"
)
FncSubjectTypeVo
entity
);
List
<
FncSubjectTypeVo
>
queryList
(
@Param
(
"entity"
)
FncSubjectTypeVo
entity
);
FncSubjectTypeVo
queryById
(
@Param
(
"id"
)
Long
subjectTypeId
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/IFncSubjectTypeService.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.system.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.system.domain.FncSubjectType
;
import
com.ruoyi.system.domain.vo.FncSubjectTypeVo
;
import
java.util.List
;
/**
* 科目类别Service接口
*
* @author jlf
* @date 2022-11-17
*/
public
interface
IFncSubjectTypeService
extends
IService
<
FncSubjectType
>
{
/**
* 分页查询
*
* @param entity
* @return
*/
TableDataInfo
<
FncSubjectTypeVo
>
queryList
(
FncSubjectTypeVo
entity
);
/**
* 查询全部
*
* @param entity
* @return
*/
List
<
FncSubjectTypeVo
>
queryAll
(
FncSubjectTypeVo
entity
);
/**
* 根据ID查询
*
* @param subjectTypeId
* @return
*/
FncSubjectTypeVo
queryById
(
Long
subjectTypeId
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FncSubjectTypeServiceImpl.java
0 → 100644
View file @
8d8172b8
package
com.ruoyi.system.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.utils.PageUtils
;
import
com.ruoyi.system.domain.FncSubjectType
;
import
com.ruoyi.system.domain.vo.FncSubjectTypeVo
;
import
com.ruoyi.system.mapper.FncSubjectTypeMapper
;
import
com.ruoyi.system.service.IFncSubjectTypeService
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 科目类别Service业务层处理
*
* @author jlf
* @date 2022-11-17
*/
@Service
public
class
FncSubjectTypeServiceImpl
extends
ServiceImpl
<
FncSubjectTypeMapper
,
FncSubjectType
>
implements
IFncSubjectTypeService
{
@Override
public
TableDataInfo
<
FncSubjectTypeVo
>
queryList
(
FncSubjectTypeVo
entity
)
{
return
PageUtils
.
buildDataInfo
(
this
.
baseMapper
.
queryList
(
PageUtils
.
buildPage
(),
entity
));
}
@Override
public
List
<
FncSubjectTypeVo
>
queryAll
(
FncSubjectTypeVo
entity
)
{
return
this
.
baseMapper
.
queryList
(
entity
);
}
@Override
public
FncSubjectTypeVo
queryById
(
Long
subjectTypeId
)
{
return
this
.
baseMapper
.
queryById
(
subjectTypeId
);
}
}
ruoyi-system/src/main/resources/mapper/finance/FncSubjectTypeMapper.xml
0 → 100644
View file @
8d8172b8
<?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.system.mapper.FncSubjectTypeMapper"
>
<sql
id=
"querySql"
>
select
<include
refid=
"allField"
/>
from fnc_subject_type A
<include
refid=
"search"
/>
</sql>
<select
id=
"queryList"
resultType=
"com.ruoyi.system.domain.vo.FncSubjectTypeVo"
>
<include
refid=
"querySql"
/>
<if
test=
"entity.subjectTypeName != null and entity.subjectTypeName != ''"
>
and A.subject_type_name like concat('%', #{entity.subjectTypeName}, '%')
</if>
order by A.create_time desc
</select>
<select
id=
"queryById"
resultType=
"com.ruoyi.system.domain.vo.FncSubjectTypeVo"
>
<include
refid=
"querySql"
/>
and A.id = #{id}
</select>
<sql
id=
"allField"
>
A.subject_type_id,
A.parent_id,
A.subject_type_name,
A.order_num,
A.create_by,
A.create_time,
A.update_by,
A.update_time
</sql>
<sql
id=
"search"
>
where A.delete_status = 1
</sql>
</mapper>
ruoyi-ui/src/api/finance/subjectType.js
0 → 100644
View file @
8d8172b8
import
request
from
'
@/utils/request
'
// 查询科目类别列表
export
function
listSubjectType
(
query
)
{
return
request
({
url
:
'
/finance/subjectType/list
'
,
method
:
'
get
'
,
params
:
query
})
}
// 查询科目类别详细
export
function
getSubjectType
(
subjectTypeId
)
{
return
request
({
url
:
'
/finance/subjectType/
'
+
subjectTypeId
,
method
:
'
get
'
})
}
// 新增科目类别
export
function
addSubjectType
(
data
)
{
return
request
({
url
:
'
/finance/subjectType/add
'
,
method
:
'
post
'
,
data
:
data
})
}
// 修改科目类别
export
function
updateSubjectType
(
data
)
{
return
request
({
url
:
'
/finance/subjectType/update
'
,
method
:
'
put
'
,
data
:
data
})
}
// 删除科目类别
export
function
delSubjectType
(
subjectTypeId
)
{
return
request
({
url
:
'
/finance/subjectType/
'
+
subjectTypeId
,
method
:
'
delete
'
})
}
ruoyi-ui/src/views/finance/ledger/index.vue
View file @
8d8172b8
...
@@ -35,8 +35,8 @@
...
@@ -35,8 +35,8 @@
<el-input
v-model=
"queryParams.saleEvaluation"
placeholder=
"请输入销售额评估"
clearable
<el-input
v-model=
"queryParams.saleEvaluation"
placeholder=
"请输入销售额评估"
clearable
@
keyup.enter.native=
"handleQuery"
/>
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"创建人"
prop=
"create
b
y"
>
<el-form-item
label=
"创建人"
prop=
"create
B
y"
>
<el-input
v-model=
"queryParams.create
b
y"
placeholder=
"请输入创建人"
clearable
<el-input
v-model=
"queryParams.create
B
y"
placeholder=
"请输入创建人"
clearable
@
keyup.enter.native=
"handleQuery"
/>
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
...
@@ -110,7 +110,7 @@
...
@@ -110,7 +110,7 @@
<
el
-
table
-
column
label
=
"
客户单位
"
align
=
"
center
"
prop
=
"
customerCompany
"
/>
<
el
-
table
-
column
label
=
"
客户单位
"
align
=
"
center
"
prop
=
"
customerCompany
"
/>
<
el
-
table
-
column
label
=
"
业务性质
"
align
=
"
center
"
prop
=
"
businessType
"
/>
<
el
-
table
-
column
label
=
"
业务性质
"
align
=
"
center
"
prop
=
"
businessType
"
/>
<
el
-
table
-
column
label
=
"
销售额评估
"
align
=
"
center
"
prop
=
"
saleEvaluation
"
/>
<
el
-
table
-
column
label
=
"
销售额评估
"
align
=
"
center
"
prop
=
"
saleEvaluation
"
/>
<
el
-
table
-
column
label
=
"
创建人
"
align
=
"
center
"
prop
=
"
create
b
y
"
/>
<
el
-
table
-
column
label
=
"
创建人
"
align
=
"
center
"
prop
=
"
create
B
y
"
/>
<
el
-
table
-
column
label
=
"
操作
"
align
=
"
center
"
class
-
name
=
"
small-padding fixed-width
"
>
<
el
-
table
-
column
label
=
"
操作
"
align
=
"
center
"
class
-
name
=
"
small-padding fixed-width
"
>
<
template
slot
-
scope
=
"
scope
"
>
<
template
slot
-
scope
=
"
scope
"
>
<
el
-
button
size
=
"
mini
"
type
=
"
text
"
icon
=
"
el-icon-edit
"
@
click
=
"
handleUpdate(scope.row)
"
<
el
-
button
size
=
"
mini
"
type
=
"
text
"
icon
=
"
el-icon-edit
"
@
click
=
"
handleUpdate(scope.row)
"
...
...
ruoyi-ui/src/views/finance/subjecttype/index.vue
0 → 100644
View file @
8d8172b8
<
template
>
<div
class=
"app-container"
>
<el-form
:model=
"queryParams"
ref=
"queryForm"
size=
"small"
:inline=
"true"
v-show=
"showSearch"
label-width=
"68px"
>
<el-form-item
label=
"科目类别名称"
prop=
"subjectTypeName"
>
<el-input
v-model=
"queryParams.subjectTypeName"
placeholder=
"请输入科目类别名称"
clearable
@
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
:gutter=
"10"
class=
"mb8"
>
<el-col
:span=
"1.5"
>
<el-button
type=
"primary"
plain
icon=
"el-icon-plus"
size=
"mini"
@
click=
"handleAdd"
v-hasPermi=
"['finance:subjectType:add']"
>
新增
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"success"
plain
icon=
"el-icon-edit"
size=
"mini"
:disabled=
"single"
@
click=
"handleUpdate"
v-hasPermi=
"['finance:subjectType:edit']"
>
修改
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"danger"
plain
icon=
"el-icon-delete"
size=
"mini"
:disabled=
"multiple"
@
click=
"handleDelete"
v-hasPermi=
"['finance:subjectType:remove']"
>
删除
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"warning"
plain
icon=
"el-icon-download"
size=
"mini"
@
click=
"handleExport"
v-hasPermi=
"['finance:subjectType:export']"
>
导出
</el-button>
</el-col>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
</el-row>
<el-table
v-loading=
"loading"
:data=
"subjectTypeList"
@
selection-change=
"handleSelectionChange"
>
<el-table-column
type=
"selection"
width=
"55"
align=
"center"
/>
<el-table-column
label=
"科目类别id"
align=
"center"
prop=
"subjectTypeId"
/>
<el-table-column
label=
"上级id"
align=
"center"
prop=
"parentId"
/>
<el-table-column
label=
"科目类别名称"
align=
"center"
prop=
"subjectTypeName"
/>
<el-table-column
label=
"显示顺序"
align=
"center"
prop=
"orderNum"
/>
<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=
"['finance:subjectType:edit']"
>
修改
</el-button>
<el-button
size=
"mini"
type=
"text"
icon=
"el-icon-delete"
@
click=
"handleDelete(scope.row)"
v-hasPermi=
"['finance:subjectType: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"
/>
<!-- 添加或修改科目类别对话框 -->
<el-dialog
:title=
"title"
:visible.sync=
"open"
width=
"500px"
append-to-body
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
label-width=
"80px"
>
<el-form-item
label=
"上级id"
prop=
"parentId"
>
<el-input
v-model=
"form.parentId"
placeholder=
"请输入上级id"
/>
</el-form-item>
<el-form-item
label=
"科目类别名称"
prop=
"subjectTypeName"
>
<el-input
v-model=
"form.subjectTypeName"
placeholder=
"请输入科目类别名称"
/>
</el-form-item>
<el-form-item
label=
"显示顺序"
prop=
"orderNum"
>
<el-input
v-model=
"form.orderNum"
placeholder=
"请输入显示顺序"
/>
</el-form-item>
</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
{
listSubjectType
,
getSubjectType
,
delSubjectType
,
addSubjectType
,
updateSubjectType
}
from
"
@/api/finance/subjectType
"
;
export
default
{
name
:
"
SubjectType
"
,
data
()
{
return
{
// 遮罩层
loading
:
true
,
// 选中数组
ids
:
[],
// 非单个禁用
single
:
true
,
// 非多个禁用
multiple
:
true
,
// 显示搜索条件
showSearch
:
true
,
// 总条数
total
:
0
,
// 科目类别表格数据
subjectTypeList
:
[],
// 弹出层标题
title
:
""
,
// 是否显示弹出层
open
:
false
,
// 查询参数
queryParams
:
{
pageNum
:
1
,
pageSize
:
10
,
subjectTypeName
:
null
,
},
// 表单参数
form
:
{},
// 表单校验
rules
:
{
parentId
:
[
{
required
:
true
,
message
:
"
上级id不能为空
"
,
trigger
:
"
blur
"
}
],
}
};
},
created
()
{
this
.
getList
();
},
methods
:
{
/** 查询科目类别列表 */
getList
()
{
this
.
loading
=
true
;
listSubjectType
(
this
.
queryParams
).
then
(
response
=>
{
this
.
subjectTypeList
=
response
.
rows
;
this
.
total
=
response
.
total
;
this
.
loading
=
false
;
});
},
// 取消按钮
cancel
()
{
this
.
open
=
false
;
this
.
reset
();
},
// 表单重置
reset
()
{
this
.
form
=
{
subjectTypeId
:
null
,
parentId
:
null
,
subjectTypeName
:
null
,
orderNum
:
null
,
createBy
:
null
,
createTime
:
null
,
updateBy
:
null
,
updateTime
:
null
};
this
.
resetForm
(
"
form
"
);
},
/** 搜索按钮操作 */
handleQuery
()
{
this
.
queryParams
.
pageNum
=
1
;
this
.
getList
();
},
/** 重置按钮操作 */
resetQuery
()
{
this
.
resetForm
(
"
queryForm
"
);
this
.
handleQuery
();
},
// 多选框选中数据
handleSelectionChange
(
selection
)
{
this
.
ids
=
selection
.
map
(
item
=>
item
.
subjectTypeId
)
this
.
single
=
selection
.
length
!==
1
this
.
multiple
=
!
selection
.
length
},
/** 新增按钮操作 */
handleAdd
()
{
this
.
reset
();
this
.
open
=
true
;
this
.
title
=
"
添加科目类别
"
;
},
/** 修改按钮操作 */
handleUpdate
(
row
)
{
this
.
reset
();
const
subjectTypeId
=
row
.
subjectTypeId
||
this
.
ids
getSubjectType
(
subjectTypeId
).
then
(
response
=>
{
this
.
form
=
response
.
data
;
this
.
open
=
true
;
this
.
title
=
"
修改科目类别
"
;
});
},
/** 提交按钮 */
submitForm
()
{
this
.
$refs
[
"
form
"
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
this
.
form
.
subjectTypeId
!=
null
)
{
updateSubjectType
(
this
.
form
).
then
(
response
=>
{
this
.
$modal
.
msgSuccess
(
"
修改成功
"
);
this
.
open
=
false
;
this
.
getList
();
});
}
else
{
addSubjectType
(
this
.
form
).
then
(
response
=>
{
this
.
$modal
.
msgSuccess
(
"
新增成功
"
);
this
.
open
=
false
;
this
.
getList
();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete
(
row
)
{
const
subjectTypeIds
=
row
.
subjectTypeId
||
this
.
ids
;
this
.
$modal
.
confirm
(
'
是否确认删除科目类别编号为"
'
+
subjectTypeIds
+
'
"的数据项?
'
).
then
(
function
()
{
return
delSubjectType
(
subjectTypeIds
);
}).
then
(()
=>
{
this
.
getList
();
this
.
$modal
.
msgSuccess
(
"
删除成功
"
);
}).
catch
(()
=>
{});
},
/** 导出按钮操作 */
handleExport
()
{
this
.
download
(
'
finance/subjectType/export
'
,
{
...
this
.
queryParams
},
`subjectType_
${
new
Date
().
getTime
()}
.xlsx`
)
}
}
};
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment