Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
new-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
binfast
new-project
Commits
d6544b0a
Commit
d6544b0a
authored
Oct 16, 2025
by
刘斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 完善代码生成模板
parent
6311c823
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1397 additions
and
1 deletion
+1397
-1
application.yml
admin/src/main/resources/application.yml
+1
-1
controller.java.vm
admin/src/main/resources/vm/java/controller.java.vm
+103
-0
domain.java.vm
admin/src/main/resources/vm/java/domain.java.vm
+62
-0
mapper.java.vm
admin/src/main/resources/vm/java/mapper.java.vm
+16
-0
pageParam.java.vm
admin/src/main/resources/vm/java/pageParam.java.vm
+34
-0
param.java.vm
admin/src/main/resources/vm/java/param.java.vm
+47
-0
service.java.vm
admin/src/main/resources/vm/java/service.java.vm
+68
-0
serviceImpl.java.vm
admin/src/main/resources/vm/java/serviceImpl.java.vm
+157
-0
vo.java.vm
admin/src/main/resources/vm/java/vo.java.vm
+67
-0
sql.vm
admin/src/main/resources/vm/sql/sql.vm
+38
-0
api.ts.vm
admin/src/main/resources/vm/ts/api.ts.vm
+65
-0
types.ts.vm
admin/src/main/resources/vm/ts/types.ts.vm
+66
-0
data.ts.vm
admin/src/main/resources/vm/vue/data.ts.vm
+142
-0
form.vue.vm
admin/src/main/resources/vm/vue/form.vue.vm
+212
-0
list.vue.vm
admin/src/main/resources/vm/vue/list.vue.vm
+145
-0
modal.vue.vm
admin/src/main/resources/vm/vue/modal.vue.vm
+167
-0
mapper.xml.vm
admin/src/main/resources/vm/xml/mapper.xml.vm
+7
-0
No files found.
admin/src/main/resources/application.yml
View file @
d6544b0a
...
...
@@ -34,7 +34,7 @@ management:
endpoints
:
web
:
exposure
:
include
:
health,info,
shutdown,
logfile
include
:
health,info,logfile
endpoint
:
health
:
show-details
:
ALWAYS
...
...
admin/src/main/resources/vm/java/controller.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
controller
;
import
java
.
util
.
List
;
import
cn
.
dev33
.
satoken
.
annotation
.
SaCheckPermission
;
import
com
.
alibaba
.
cola
.
dto
.
PageResponse
;
import
com
.
alibaba
.
cola
.
dto
.
Response
;
import
com
.
alibaba
.
cola
.
dto
.
SingleResponse
;
import
jakarta
.
annotation
.
Resource
;
import
jakarta
.
validation
.
constraints
.
Min
;
import
jakarta
.
validation
.
constraints
.
NotEmpty
;
import
org
.
springframework
.
validation
.
annotation
.
Validated
;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
import
top
.
binfast
.
common
.
core
.
constant
.
BusinessType
;
import
top
.
binfast
.
common
.
core
.
validate
.
AddGroup
;
import
top
.
binfast
.
common
.
core
.
validate
.
EditGroup
;
import
top
.
binfast
.
common
.
core
.
util
.
ResponseUtils
;
import
top
.
binfast
.
common
.
excel
.
annotion
.
ExcelExport
;
import
top
.
binfast
.
common
.
log
.
annotation
.
PinSysLog
;
import
${
packageName
}.
domain
.
params
.${
className
}.${
ClassName
}
ListParam
;
import
${
packageName
}.
domain
.
params
.${
className
}.${
ClassName
}
Param
;
import
${
packageName
}.
domain
.
vo
.${
className
}.${
ClassName
}
Vo
;
import
${
packageName
}.
service
.${
className
}.${
ClassName
}
Serv
;
/**
*
${
functionName
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Validated
@
RestController
@
RequestMapping
(
"/${moduleName}/${businessName}"
)
public
class
${
ClassName
}
Ctrl
{
@
Resource
private
${
ClassName
}
Serv
${
className
}
Serv
;
/**
*
查询
${
functionName
}
列表
*/
@
SaCheckPermission
(
"${permissionPrefix}:list"
)
@
GetMapping
(
"/page"
)
public
PageResponse
<${
ClassName
}
Vo
>
pageList
(${
ClassName
}
ListParam
param
)
{
return
${
className
}
Serv
.
queryPageList
(
param
);
}
/**
*
导出
${
functionName
}
列表
*/
@
ExcelExport
@
SaCheckPermission
(
"${permissionPrefix}:export"
)
@
PinSysLog
(
value
=
"${functionName}"
,
businessType
=
BusinessType
.
EXPORT
)
@
PostMapping
(
"/export"
)
public
List
<${
ClassName
}
Vo
>
export
(${
ClassName
}
ListParam
param
)
{
return
${
className
}
Serv
.
queryList
(
param
);
}
/**
*
获取
${
functionName
}
详细信息
*
*
@
param
${
pkColumn
.
javaField
}
主键
*/
@
SaCheckPermission
(
"${permissionPrefix}:query"
)
@
GetMapping
(
"/{${pkColumn.javaField}}"
)
public
SingleResponse
<${
ClassName
}
Vo
>
getDetail
(@
PathVariable
@
Min
(
1
)
${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
})
{
return
SingleResponse
.
of
(${
className
}
Serv
.
queryById
(${
pkColumn
.
javaField
}));
}
/**
*
新增
${
functionName
}
*/
@
SaCheckPermission
(
"${permissionPrefix}:add"
)
@
PinSysLog
(
value
=
"${functionName}"
,
businessType
=
BusinessType
.
INSERT
)
@
PostMapping
()
public
Response
add
(@
Validated
(
AddGroup
.
class
)
@
RequestBody
${
ClassName
}
Param
param
)
{
return
ResponseUtils
.
ofResult
(${
className
}
Serv
.
insertByParam
(
param
));
}
/**
*
修改
${
functionName
}
*/
@
SaCheckPermission
(
"${permissionPrefix}:edit"
)
@
PinSysLog
(
value
=
"${functionName}"
,
businessType
=
BusinessType
.
UPDATE
)
@
PutMapping
()
public
Response
edit
(@
Validated
(
EditGroup
.
class
)
@
RequestBody
${
ClassName
}
Param
param
)
{
return
ResponseUtils
.
ofResult
(${
className
}
Serv
.
updateByParam
(
param
));
}
/**
*
删除
${
functionName
}
*
*
@
param
${
pkColumn
.
javaField
}
s
主键串
*/
@
SaCheckPermission
(
"${permissionPrefix}:remove"
)
@
PinSysLog
(
value
=
"${functionName}"
,
businessType
=
BusinessType
.
DELETE
)
@
DeleteMapping
(
"/{${pkColumn.javaField}s}"
)
public
Response
remove
(@
NotEmpty
(
message
=
"主键不能为空"
)
@
PathVariable
${
pkColumn
.
javaType
}[]
${
pkColumn
.
javaField
}
s
)
{
return
ResponseUtils
.
ofResult
(${
className
}
Serv
.
delByIds
(
List
.
of
(${
pkColumn
.
javaField
}
s
)));
}
}
\ No newline at end of file
admin/src/main/resources/vm/java/domain.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
domain
.
model
.${
className
};
#
foreach
($
column
in
$
columns
)
#
if
($
column
.
javaField
==
'tenantId'
)
#
set
($
IsTenant
=
1
)
#
end
#
end
#
if
($
IsTenant
==
1
)
import
top
.
binfast
.
common
.
mybatis
.
bean
.
model
.
TenantModel
;
#
else
import
top
.
binfast
.
common
.
mybatis
.
bean
.
model
.
BaseModel
;
#
end
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
lombok
.
Getter
;
import
lombok
.
Setter
;
import
lombok
.
EqualsAndHashCode
;
#
foreach
($
import
in
$
importList
)
import
${
import
};
#
end
import
java
.
io
.
Serial
;
/**
*
${
functionName
}
对象
${
tableName
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
#
if
($
IsTenant
==
1
)
#
set
($
Entity
=
"TenantModel"
)
#
else
#
set
($
Entity
=
"BaseModel"
)
#
end
@
Getter
@
Setter
@
EqualsAndHashCode
(
callSuper
=
true
)
@
TableName
(
"${tableName}"
)
public
class
${
ClassName
}
extends
${
Entity
}
{
@
Serial
private
static
final
long
serialVersionUID
=
1L
;
#
foreach
($
column
in
$
columns
)
#
if
(
!$table.isSuperColumn($column.javaField))
/**
*
$
column
.
columnComment
*/
#
if
($
column
.
javaField
==
'deleted'
)
@
TableLogic
#
end
#
if
($
column
.
javaField
==
'version'
)
@
Version
#
end
#
if
($
column
.
isPk
==
1
)
@
TableId
(
value
=
"$column.columnName"
)
#
end
private
$
column
.
javaType
$
column
.
javaField
;
#
end
#
end
}
admin/src/main/resources/vm/java/mapper.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
mapper
.${
className
};
import
${
packageName
}.
domain
.
model
.${
className
}.${
ClassName
};
import
top
.
binfast
.
common
.
mybatis
.
mapper
.
BinBaseMapper
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
/**
*
${
functionName
}
Mapper
接口
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Mapper
public
interface
${
ClassName
}
Mapper
extends
BinBaseMapper
<${
ClassName
}>
{
}
admin/src/main/resources/vm/java/pageParam.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
domain
.
params
.${
className
};
import
lombok
.
Getter
;
import
lombok
.
Setter
;
import
top
.
binfast
.
common
.
core
.
bean
.
params
.
PageQueryParam
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Map
;
#
foreach
($
import
in
$
importList
)
import
${
import
};
#
end
/**
*
${
functionName
}
分页对象
${
tableName
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Getter
@
Setter
public
class
${
ClassName
}
ListParam
extends
PageQueryParam
{
#
foreach
($
column
in
$
columns
)
#
if
(($
column
.
query
))
/**
*
$
column
.
columnComment
*/
private
$
column
.
javaType
$
column
.
javaField
;
#
end
#
end
private
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
}
admin/src/main/resources/vm/java/param.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
domain
.
params
.${
className
};
import
${
packageName
}.
domain
.
model
.${
ClassName
};
import
top
.
binfast
.
common
.
core
.
validate
.
AddGroup
;
import
top
.
binfast
.
common
.
core
.
validate
.
EditGroup
;
import
io
.
github
.
linpeilie
.
annotations
.
AutoMapper
;
import
lombok
.
Data
;
import
jakarta
.
validation
.
constraints
.*;
#
foreach
($
import
in
$
importList
)
import
${
import
};
#
end
/**
*
${
functionName
}
业务对象
${
tableName
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Data
@
AutoMapper
(
target
=
${
ClassName
}.
class
,
reverseConvertGenerate
=
false
)
public
class
${
ClassName
}
Param
{
#
foreach
($
column
in
$
columns
)
#
if
(($
column
.
isPk
==
1
||
!$table.isSuperColumn($column.javaField)) && ($column.query || $column.insert || $column.edit))
/**
*
$
column
.
columnComment
*/
#
if
($
column
.
insert
&&
$
column
.
edit
)
#
set
($
Group
=
"AddGroup.class, EditGroup.class"
)
#
elseif
($
column
.
insert
)
#
set
($
Group
=
"AddGroup.class"
)
#
elseif
($
column
.
edit
)
#
set
($
Group
=
"EditGroup.class"
)
#
end
#
if
($
column
.
required
)
#
if
($
column
.
javaType
==
'String'
)
@
NotBlank
(
message
=
"$column.columnComment不能为空"
,
groups
=
{
$
Group
})
#
else
@
NotNull
(
message
=
"$column.columnComment不能为空"
,
groups
=
{
$
Group
})
#
end
#
end
private
$
column
.
javaType
$
column
.
javaField
;
#
end
#
end
}
admin/src/main/resources/vm/java/service.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.${
className
}.
service
;
import
${
packageName
}.
domain
.
model
.${
className
}.${
ClassName
};
import
${
packageName
}.
domain
.
vo
.${
className
}.${
ClassName
}
Vo
;
import
${
packageName
}.
domain
.
params
.${
className
}.${
ClassName
}
ListParam
;
import
${
packageName
}.
domain
.
params
.${
className
}.${
ClassName
}
Param
;
import
com
.
alibaba
.
cola
.
dto
.
PageResponse
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
IService
;
import
java
.
util
.
List
;
/**
*
${
functionName
}
Service
接口
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
public
interface
${
ClassName
}
Serv
extends
IService
<${
ClassName
}>
{
/**
*
分页查询
${
functionName
}
列表
*
*
@
param
param
查询条件
*
@
return
${
functionName
}
分页列表
*/
PageResponse
<${
ClassName
}
Vo
>
queryPageList
(${
ClassName
}
ListParam
param
);
/**
*
查询符合条件的
${
functionName
}
列表
*
*
@
param
param
查询条件
*
@
return
${
functionName
}
列表
*/
List
<${
ClassName
}
Vo
>
queryList
(${
ClassName
}
ListParam
param
);
/**
*
查询
${
functionName
}
*
*
@
param
${
pkColumn
.
javaField
}
主键
*
@
return
${
functionName
}
*/
${
ClassName
}
Vo
queryById
(${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
});
/**
*
新增
${
functionName
}
*
*
@
param
param
${
functionName
}
*
@
return
是否新增成功
*/
Boolean
insertByParam
(${
ClassName
}
Param
param
);
/**
*
修改
${
functionName
}
*
*
@
param
param
${
functionName
}
*
@
return
是否修改成功
*/
Boolean
updateByParam
(${
ClassName
}
Param
param
);
/**
*
校验并批量删除
${
functionName
}
信息
*
*
@
param
ids
待删除的主键集合
*
@
return
是否删除成功
*/
Boolean
delByIds
(
List
<${
pkColumn
.
javaType
}>
ids
);
}
admin/src/main/resources/vm/java/serviceImpl.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
service
.${
className
}.
impl
;
import
cn
.
hutool
.
core
.
util
.
StrUtil
;
import
com
.
alibaba
.
cola
.
dto
.
PageResponse
;
import
com
.
baomidou
.
mybatisplus
.
core
.
conditions
.
query
.
LambdaQueryWrapper
;
import
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
Wrappers
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
impl
.
ServiceImpl
;
import
lombok
.
RequiredArgsConstructor
;
import
org
.
springframework
.
stereotype
.
Service
;
import
top
.
binfast
.
common
.
core
.
util
.
MapstructUtils
;
import
top
.
binfast
.
common
.
mybatis
.
util
.
QueryUtil
;
import
${
packageName
}.
domain
.
model
.${
className
}.${
ClassName
};
import
${
packageName
}.
domain
.
vo
.${
className
}.${
ClassName
}
Vo
;
import
${
packageName
}.
domain
.
params
.${
className
}.${
ClassName
}
ListParam
;
import
${
packageName
}.
domain
.
params
.${
className
}.${
ClassName
}
Param
;
import
${
packageName
}.
mapper
.${
className
}.${
ClassName
}
Mapper
;
import
${
packageName
}.
service
.${
className
}.${
ClassName
}
Serv
;
#
if
($
table
.
tree
)
import
top
.
binfast
.
common
.
seed
.
base
.
DataObjectUtil
;
#
end
import
java
.
util
.
List
;
/**
*
${
functionName
}
Service
业务层处理
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
RequiredArgsConstructor
@
Service
public
class
${
ClassName
}
ServImpl
extends
ServiceImpl
<${
ClassName
}
Mapper
,
${
ClassName
}>
implements
${
ClassName
}
Serv
{
private
final
${
ClassName
}
Mapper
${
className
}
Mapper
;
/**
*
分页查询
${
functionName
}
列表
*
*
@
param
param
查询条件
*
@
return
${
functionName
}
分页列表
*/
@
Override
public
PageResponse
<${
ClassName
}
Vo
>
queryPageList
(${
ClassName
}
ListParam
param
)
{
Page
<${
ClassName
}>
page
=
QueryUtil
.
getPage
(
param
);
LambdaQueryWrapper
<${
ClassName
}>
lambdaQuery
=
this
.
buildQueryWrapper
(
param
);
${
className
}
Mapper
.
selectPage
(
page
,
lambdaQuery
);
#
if
($
table
.
crud
)
return
QueryUtil
.
getPageResponse
(
page
,
MapstructUtils
.
convert
(
page
.
getRecords
(),
${
ClassName
}
Vo
.
class
));
#
elseif
($
table
.
tree
)
List
<${
ClassName
}
Vo
>
${
className
}
VoList
=
DataObjectUtil
.
generateTree
(
MapstructUtils
.
convert
(
page
.
getRecords
(),
${
ClassName
}
Vo
.
class
));
return
QueryUtil
.
getPageResponse
(${
className
}
VoList
,
page
);
#
end
}
/**
*
查询符合条件的
${
functionName
}
列表
*
*
@
param
param
查询条件
*
@
return
${
functionName
}
列表
*/
@
Override
public
List
<${
ClassName
}
Vo
>
queryList
(${
ClassName
}
ListParam
param
)
{
LambdaQueryWrapper
<${
ClassName
}>
lambdaQuery
=
this
.
buildQueryWrapper
(
param
);
return
MapstructUtils
.
convert
(${
className
}
Mapper
.
selectList
(
lambdaQuery
),
${
ClassName
}
Vo
.
class
);
}
private
LambdaQueryWrapper
<${
ClassName
}>
buildQueryWrapper
(${
ClassName
}
ListParam
param
)
{
LambdaQueryWrapper
<${
ClassName
}>
lambdaQuery
=
Wrappers
.<${
ClassName
}>
lambdaQuery
();
#
foreach
($
column
in
$
columns
)
#
if
($
column
.
query
)
#
set
($
queryType
=$
column
.
queryType
)
#
set
($
javaField
=$
column
.
javaField
)
#
set
($
javaType
=$
column
.
javaType
)
#
set
($
columnName
=$
column
.
columnName
)
#
set
($
AttrName
=$
column
.
javaField
.
substring
(
0
,
1
).
toUpperCase
()
+
${
column
.
javaField
.
substring
(
1
)})
#
set
($
mpMethod
=$
column
.
queryType
.
toLowerCase
())
#
if
($
queryType
!= 'BETWEEN')
#
if
($
javaType
==
'String'
)
#
set
($
condition
=
'StrUtil.isNotBlank(param.get'
+$
AttrName
+
'())'
)
#
else
#
set
($
condition
=
'param.get'
+$
AttrName
+
'() != null'
)
#
end
lambdaQuery
.$
mpMethod
($
condition
,
${
ClassName
}::
get
$
AttrName
,
param
.
get
$
AttrName
());
#
else
lambdaQuery
.
between
(
params
.
get
(
"begin$AttrName"
)
!= null && params.get("end$AttrName") != null,
${
ClassName
}::
get
$
AttrName
,
params
.
get
(
"begin$AttrName"
),
params
.
get
(
"end$AttrName"
));
#
end
#
end
###
if
($
column
.
javaField
==
'deleted'
)
##
lambdaQuery
.
eq
(${
ClassName
}::
getDeleted
,
DeletedStatus
.
UN_DELETED
);
###
end
#
set
($
AttrName
=$
column
.
javaField
.
substring
(
0
,
1
).
toUpperCase
()
+
${
column
.
javaField
.
substring
(
1
)})
#
if
($
column
.
isPk
==
1
)
lambdaQuery
.
orderByDesc
(${
ClassName
}::
get
$
AttrName
);
#
end
#
end
return
lambdaQuery
;
}
/**
*
查询
${
functionName
}
*
*
@
param
${
pkColumn
.
javaField
}
主键
*
@
return
${
functionName
}
*/
@
Override
public
${
ClassName
}
Vo
queryById
(${
pkColumn
.
javaType
}
${
pkColumn
.
javaField
}){
${
ClassName
}
${
className
}
=
${
className
}
Mapper
.
selectById
(${
pkColumn
.
javaField
});
return
MapstructUtils
.
convert
(${
className
},
${
ClassName
}
Vo
.
class
);
}
/**
*
新增
${
functionName
}
*
*
@
param
param
${
functionName
}
*
@
return
是否新增成功
*/
@
Override
public
Boolean
insertByParam
(${
ClassName
}
Param
param
)
{
${
ClassName
}
${
className
}
=
MapstructUtils
.
convert
(
param
,
${
ClassName
}.
class
);
return
this
.
save
(${
className
});
}
/**
*
修改
${
functionName
}
*
*
@
param
param
${
functionName
}
*
@
return
是否修改成功
*/
@
Override
public
Boolean
updateByParam
(${
ClassName
}
Param
param
)
{
${
ClassName
}
${
className
}
=
MapstructUtils
.
convert
(
param
,
${
ClassName
}.
class
);
return
this
.
updateById
(${
className
});
}
/**
*
保存前的数据校验
*/
private
void
validEntityBeforeSave
(${
ClassName
}
entity
){
//
做一些数据校验
,
如唯一约束
}
/**
*
校验并批量删除
${
functionName
}
信息
*
*
@
param
ids
待删除的主键集合
*
@
return
是否删除成功
*/
@
Override
@
Transactional
(
rollbackFor
=
{
Exception
.
class
})
public
Boolean
delByIds
(
List
<${
pkColumn
.
javaType
}>
ids
)
{
//
做一些业务上的校验
,
判断是否需要校验
return
this
.
removeByIds
(
ids
);
}
}
admin/src/main/resources/vm/java/vo.java.vm
0 → 100644
View file @
d6544b0a
package
${
packageName
}.
domain
.
vo
.${
className
};
#
foreach
($
import
in
$
importList
)
import
${
import
};
#
end
import
${
packageName
}.
domain
.
model
.${
ClassName
};
import
cn
.
idev
.
excel
.
annotation
.
ExcelIgnoreUnannotated
;
import
cn
.
idev
.
excel
.
annotation
.
ExcelProperty
;
import
cn
.
idev
.
excel
.
annotation
.
ExcelIgnore
;
import
top
.
binfast
.
common
.
excel
.
annotion
.
ExcelDictFormat
;
import
top
.
binfast
.
common
.
excel
.
converters
.
ExcelDictConvert
;
import
io
.
github
.
linpeilie
.
annotations
.
AutoMapper
;
import
lombok
.
Data
;
import
java
.
io
.
Serial
;
import
java
.
io
.
Serializable
;
/**
*
${
functionName
}
视图对象
${
tableName
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Data
@
ExcelIgnoreUnannotated
@
AutoMapper
(
target
=
${
ClassName
}.
class
)
public
class
${
ClassName
}
Vo
implements
Serializable
{
@
Serial
private
static
final
long
serialVersionUID
=
1L
;
#
foreach
($
column
in
$
columns
)
#
if
($
column
.
list
)
/**
*
$
column
.
columnComment
*/
#
set
($
parentheseIndex
=$
column
.
columnComment
.
indexOf
(
"("
))
#
if
($
parentheseIndex
!= -1)
#
set
($
comment
=$
column
.
columnComment
.
substring
(
0
,
$
parentheseIndex
))
#
else
#
set
($
comment
=$
column
.
columnComment
)
#
end
#
if
(${
column
.
dictType
}
&&
${
column
.
dictType
}
!= '')
@
ExcelProperty
(
value
=
"${comment}"
,
converter
=
ExcelDictConvert
.
class
)
@
ExcelDictFormat
(
dictType
=
"${column.dictType}"
)
#
elseif
($
parentheseIndex
!= -1)
@
ExcelProperty
(
value
=
"${comment}"
,
converter
=
ExcelDictConvert
.
class
)
@
ExcelDictFormat
(
readConverterExp
=
"$column.readConverterExp()"
)
#
elseif
($
column
.
isPk
==
1
)
#
else
@
ExcelProperty
(
value
=
"${comment}"
)
#
end
private
$
column
.
javaType
$
column
.
javaField
;
#
if
($
column
.
htmlType
==
"imageUpload"
)
/**
*
${
column
.
columnComment
}
Url
*/
@
Translation
(
type
=
TransConstant
.
OSS_ID_TO_URL
,
mapper
=
"${column.javaField}"
)
private
String
${
column
.
javaField
}
Url
;
#
end
#
end
#
end
}
admin/src/main/resources/vm/sql/sql.vm
0 → 100644
View file @
d6544b0a
-- 菜单 SQL
insert into sys_menu (id, name, parent_id, page_name, order_num, node_path, type, is_leaf, perms, level, visible, is_cache, deleted, create_by, create_time, update_by, update_time)
values(${table.menuIds[0]}, '${functionName}', ${parentMenuId}, '${ClassName}List', ${table.menuIds[0]}, '/0/${parentMenuId}/${table.menuIds[0]}/', 1, 0, '${permissionPrefix}:list', 2, 1, 1, 0, 1, sysdate(), null, null);
-- 按钮 SQL
insert into sys_menu (id, name, parent_id, page_name, order_num, node_path, type, is_leaf, perms, level, visible, is_cache, deleted, create_by, create_time, update_by, update_time)
values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '', 1, '/0/${parentMenuId}/${table.menuIds[0]}/${table.menuIds[1]}/', 2, 1, '${permissionPrefix}:query', 3, 0, 0, 0, 1, sysdate(), null, null);
insert into sys_menu (id, name, parent_id, page_name, order_num, node_path, type, is_leaf, perms, level, visible, is_cache, deleted, create_by, create_time, update_by, update_time)
values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '', 2, '/0/${parentMenuId}/${table.menuIds[0]}/${table.menuIds[2]}/', 2, 1, '${permissionPrefix}:add', 3, 0, 0, 0, 1, sysdate(), null, null);
insert into sys_menu (id, name, parent_id, page_name, order_num, node_path, type, is_leaf, perms, level, visible, is_cache, deleted, create_by, create_time, update_by, update_time)
values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '', 3, '/0/${parentMenuId}/${table.menuIds[0]}/${table.menuIds[3]}/', 2, 1, '${permissionPrefix}:edit', 3, 0, 0, 0, 1, sysdate(), null, null);
insert into sys_menu (id, name, parent_id, page_name, order_num, node_path, type, is_leaf, perms, level, visible, is_cache, deleted, create_by, create_time, update_by, update_time)
values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '', 4, '/0/${parentMenuId}/${table.menuIds[0]}/${table.menuIds[4]}/', 2, 1, '${permissionPrefix}:remove', 3, 0, 0, 0, 1, sysdate(), null, null);
insert into sys_menu (id, name, parent_id, page_name, order_num, node_path, type, is_leaf, perms, level, visible, is_cache, deleted, create_by, create_time, update_by, update_time)
values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '', 5, '/0/${parentMenuId}/${table.menuIds[0]}/${table.menuIds[5]}/', 2, 1, '${permissionPrefix}:export', 3, 0, 0, 0, 1, sysdate(), null, null);
-- 管理员菜单关联 SQL
INSERT INTO sys_role_menu (id, menu_id, role_id)
VALUES (${table.menuRoleIds[0]}, ${table.menuIds[0]}, 1);
INSERT INTO sys_role_menu (id, menu_id, role_id)
VALUES (${table.menuRoleIds[1]}, ${table.menuIds[1]}, 1);
INSERT INTO sys_role_menu (id, menu_id, role_id)
VALUES (${table.menuRoleIds[2]}, ${table.menuIds[2]}, 1);
INSERT INTO sys_role_menu (id, menu_id, role_id)
VALUES (${table.menuRoleIds[3]}, ${table.menuIds[3]}, 1);
INSERT INTO sys_role_menu (id, menu_id, role_id)
VALUES (${table.menuRoleIds[4]}, ${table.menuIds[4]}, 1);
INSERT INTO sys_role_menu (id, menu_id, role_id)
VALUES (${table.menuRoleIds[5]}, ${table.menuIds[5]}, 1);
\ No newline at end of file
admin/src/main/resources/vm/ts/api.ts.vm
0 → 100644
View file @
d6544b0a
import type { BaseModel, PageQuery } from '#/api/baseModel';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
export namespace ${BusinessName}Api {
export interface ${BusinessName} extends BaseModel {
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField) && ($column.insert || $column.edit))
/**
* $column.columnComment
*/
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) number;
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
#elseif($column.javaType == 'Boolean') boolean;
#else string;#end
#end
#end
}
}
/**
* 查询${functionName}列表
* @param params
* @returns {*} page
*/
export function apiPage(params: PageQuery) {
return requestClient.get('/${moduleName}/${businessName}/page', { params });
}
/**
* 查询${functionName}详细
* @param ${pkColumn.javaField}
*/
export function apiDetail(${pkColumn.javaField}: number) {
return requestClient.get(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`);
}
/**
* 新增${functionName}
* @param data
*/
export function apiAdd(data: ${BusinessName}Api.${BusinessName}) {
return requestClient.post('/${moduleName}/${businessName}', data);
}
/**
* 修改${functionName}
* @param data
*/
export function apiUpdate(data: ${BusinessName}Api.${BusinessName}) {
return requestClient.put('/${moduleName}/${businessName}', data);
}
/**
* 删除${functionName}
* @param ${pkColumn.javaField}
*/
export function apiDelete(${pkColumn.javaField}: Array<number> | number) {
return requestClient.delete(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`);
}
/**
* 导出${functionName}
* @param params
*/
export function apiExport(params: PageQuery) {
return commonExport('/${moduleName}/${businessName}/export', params);
}
admin/src/main/resources/vm/ts/types.ts.vm
0 → 100644
View file @
d6544b0a
import { BaseModel, QueryParam } from '@/api/model/baseModel';
export interface ${BusinessName}VO extends BaseModel {
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField) && $column.list)
/**
* $column.columnComment
*/
$column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
#elseif($column.javaType == 'Boolean') boolean;
#else string;
#end
#if($column.htmlType == "imageUpload")
/**
* ${column.columnComment}Url
*/
${column.javaField}Url: string;
#end
#end
#end
#if ($table.tree)
/**
* 子对象
*/
children: ${BusinessName}VO[];
#end
}
export interface ${BusinessName}Param extends BaseModel {
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField) && ($column.insert || $column.edit))
/**
* $column.columnComment
*/
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
#elseif($column.javaType == 'Boolean') boolean;
#else string;
#end
#end
#end
}
export interface ${BusinessName}Query extends QueryParam{
#foreach ($column in $columns)
#if($column.query)
/**
* $column.columnComment
*/
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
#elseif($column.javaType == 'Boolean') boolean;
#else string;
#end
#end
#end
/**
* 日期范围参数等
*/
params?: any;
}
admin/src/main/resources/vm/vue/data.ts.vm
0 → 100644
View file @
d6544b0a
import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ${BusinessName}Api } from '#/api/${moduleName}/${businessName}';
import { DictEnum } from '@vben/constants';
import { getDictOptions, getTagDicts } from '#/utils/dict';
export const querySchema: VbenFormSchema[] = [
#foreach($column in $columns)
#if($column.query)
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.htmlType == "input" || $column.htmlType == "textarea")
{
component: 'Input',
fieldName: '${column.javaField}',
label: '${comment}',
},
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType && $dictType)
{
component: 'Select',
componentProps: {
#if($dictType == "SYS_COMMON_STATUS")
options: getDictOptions(DictEnum.${dictType}, true),
#else
options: getDictOptions(DictEnum.${dictType}),
#end
},
fieldName: '${column.javaField}',
label: '${comment}',
},
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
{
component: 'Select',
componentProps: {
},
fieldName: '${column.javaField}',
label: '${comment}',
},
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
{
component: 'DatePicker',
fieldName: '${column.javaField}',
label: '${comment}',
},
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
{
component: 'RangePicker',
fieldName: '${column.javaField}',
label: '${comment}',
},
#end
#end
#end
];
export function useColumns(
onActionClick: OnActionClickFn<${BusinessName}Api.${BusinessName}>,
): VxeTableGridOptions<${BusinessName}Api.${BusinessName}>['columns'] {
return [
#foreach($column in $columns)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if(!$column.pk)
#if($column.list && $column.htmlType == "datetime")
{
title: '${comment}',
field: '${javaField}',
formatter: 'formatDateTime',
},
#elseif($column.list && $column.htmlType == "imageUpload")
{
title: '${comment}',
field: '${javaField}',
slots: { default: '${javaField}' },
},
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio") && $column.dictType && "" != $column.dictType)
{
title: '${comment}',
field: '${javaField}',
#if($column.dictType == "SYS_COMMON_STATUS")
cellRender: { name: 'CellTag', options: [getTagDicts(DictEnum.${column.dictType}, true)] },
#else
cellRender: { name: 'CellTag', options: [getTagDicts(DictEnum.${column.dictType})] },
#end
},
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio") && !$column.dictType)
{
title: '${comment}',
field: '${javaField}',
cellRender: { name: 'CellTag', options: [getTagDicts()] },
},
#elseif($column.list && "" != $javaField)
{
title: '${comment}',
field: '${javaField}',
},
#end
#end
#end
{
align: 'right',
cellRender: {
attrs: {
nameField: 'name',
nameTitle: '${functionName}',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
accessCode: ['${permissionPrefix}:edit'],
}, // 默认的编辑按钮
{
code: 'delete',
accessCode: ['${permissionPrefix}:remove'],
}, // 默认的删除按钮
],
},
field: 'action',
fixed: 'right',
headerAlign: 'center',
resizable: false,
showOverflow: false,
title: '操作',
width: 'auto',
},
];
}
admin/src/main/resources/vm/vue/form.vue.vm
0 → 100644
View file @
d6544b0a
<script
lang=
"ts"
setup
>
import
type
{
VbenFormSchema
}
from
'#/adapter/form'
;
import
type
{
$
{
BusinessName
}
Api
}
from
'#/api/${moduleName}/${businessName}'
;
import
{
computed
,
ref
}
from
'vue'
;
import
{
useVbenDrawer
}
from
'@vben/common-ui'
;
import
{
DictEnum
}
from
'@vben/constants'
;
import
{
getVxePopupContainer
}
from
'@vben/utils'
;
import
{
useVbenForm
,
z
}
from
'#/adapter/form'
;
import
{
apiAdd
,
apiUpdate
}
from
'#/api/${moduleName}/${businessName}'
;
import
{
getDictOptions
}
from
'#/utils/dict'
;
import
{
defaultFormValueGetter
,
useBeforeCloseDiff
}
from
'#/utils/popup'
;
const
emit
=
defineEmits
<
{
success
:
[];
}
>
();
const
formData
=
ref
<
$
{
BusinessName
}
Api
.
$
{
BusinessName
}
>
();
const
formSchema
:
VbenFormSchema
[]
=
[
#
foreach
(
$column
in
$columns
)
#
set
(
$field
=
$column
.
javaField
)
#
if
((
$column
.
insert
||
$column
.
edit
)
&&
!
$column
.
pk
)
#
set
(
$parentheseIndex
=
$column
.
columnComment
.
indexOf
(
"("
))
#
if
(
$parentheseIndex
!=
-
1
)
#
set
(
$comment
=
$column
.
columnComment
.
substring
(
0
,
$parentheseIndex
))
#
else
#
set
(
$comment
=
$column
.
columnComment
)
#
end
#
set
(
$dictType
=
$column
.
dictType
)
{
#
if
(
$column
.
htmlType
==
"input"
)
component
:
'Input'
,
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"imageUpload"
)
component
:
'ImageUpload'
,
componentProps
:
{
maxCount
:
1
,
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"fileUpload"
)
component
:
'FileUpload'
,
componentProps
:
{
maxCount
:
1
,
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"editor"
)
component
:
'RichTextarea'
,
componentProps
:
{
width
:
'100%'
,
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"select"
&&
""
!=
$dictType
&&
$dictType
)
component
:
'Select'
,
componentProps
:
{
getVxePopupContainer
,
#
if
(
$dictType
==
"SYS_COMMON_STATUS"
)
options
:
getDictOptions
(
DictEnum
.
$
{
dictType
},
true
),
#
else
options
:
getDictOptions
(
DictEnum
.
$
{
dictType
}),
#
end
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'selectRequired'
,
#
elseif
(
$column
.
htmlType
==
"select"
&&
!
$dictType
)
component
:
'Select'
,
componentProps
:
{
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'selectRequired'
,
#
elseif
(
$column
.
htmlType
==
"checkbox"
&&
""
!=
$dictType
&&
$dictType
)
component
:
'CheckboxGroup'
,
componentProps
:
{
getVxePopupContainer
,
#
if
(
$dictType
==
"SYS_COMMON_STATUS"
)
options
:
getDictOptions
(
DictEnum
.
$
{
dictType
},
true
),
#
else
options
:
getDictOptions
(
DictEnum
.
$
{
dictType
}),
#
end
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"checkbox"
&&
!
$dictType
)
component
:
'CheckboxGroup'
,
componentProps
:
{
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"radio"
&&
""
!=
$dictType
&&
$dictType
)
component
:
'RadioGroup'
,
componentProps
:
{
buttonStyle
:
'solid'
,
optionType
:
'button'
,
#
if
(
$dictType
==
"SYS_COMMON_STATUS"
)
options
:
getDictOptions
(
DictEnum
.
$
{
dictType
},
true
),
#
else
options
:
getDictOptions
(
DictEnum
.
$
{
dictType
}),
#
end
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"radio"
&&
!
$dictType
)
component
:
'RadioGroup'
,
componentProps
:
{
buttonStyle
:
'solid'
,
optionType
:
'button'
,
},
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"datetime"
)
component
:
'DatePicker'
,
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
elseif
(
$column
.
htmlType
==
"textarea"
)
component
:
'Textarea'
,
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
#
end
},
#
end
#
end
];
const
[
BasicForm
,
formApi
]
=
useVbenForm
({
commonConfig
:
{
componentProps
:
{
class
:
'w-full'
,
},
formItemClass
:
'col-span-2'
,
labelWidth
:
90
,
},
schema
:
formSchema
,
showDefaultActions
:
false
,
wrapperClass
:
'grid-cols-2'
,
});
const
{
onBeforeClose
,
markInitialized
,
resetInitialized
}
=
useBeforeCloseDiff
(
{
initializedGetter
:
defaultFormValueGetter
(
formApi
),
currentGetter
:
defaultFormValueGetter
(
formApi
),
},
);
const
[
Drawer
,
drawerApi
]
=
useVbenDrawer
({
onBeforeClose
,
onClosed
:
handleClosed
,
onConfirm
:
onSubmit
,
async
onOpenChange
(
isOpen
)
{
if
(
!
isOpen
)
{
return
null
;
}
const
data
=
drawerApi
.
getData
<
$
{
BusinessName
}
Api
.
$
{
BusinessName
}
>
();
if
(
data
)
{
formData
.
value
=
data
;
await
formApi
.
setValues
(
formData
.
value
);
}
else
{
formApi
.
resetForm
();
}
await
markInitialized
();
},
});
async
function
onSubmit
()
{
const
{
valid
}
=
await
formApi
.
validate
();
if
(
valid
)
{
drawerApi
.
lock
();
const
data
=
await
formApi
.
getValues
<
$
{
BusinessName
}
Api
.
$
{
BusinessName
}
>
();
try
{
await
(
formData
.
value
?.
id
?
apiUpdate
({
id
:
formData
.
value
.
id
,
...
data
})
:
apiAdd
(
data
));
resetInitialized
();
emit
(
'success'
);
drawerApi
.
close
();
}
finally
{
drawerApi
.
unlock
();
}
}
}
async
function
handleClosed
()
{
await
formApi
.
resetForm
();
resetInitialized
();
}
const
getDrawerTitle
=
computed
(()
=>
formData
.
value
?.
id
?
'修改${functionName}'
:
'新增${functionName}'
,
);
</script>
<template>
<Drawer
class=
"w-full max-w-[800px]"
:title=
"getDrawerTitle"
>
<BasicForm
class=
"mx-4"
/>
</Drawer>
</template>
admin/src/main/resources/vm/vue/list.vue.vm
0 → 100644
View file @
d6544b0a
<script lang="ts" setup>
import type { VbenFormProps } from '@vben/common-ui';
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { ${BusinessName}Api } from '#/api/${moduleName}/${businessName}';
import { Page, useVbenDrawer } from '@vben/common-ui';
import { Plus } from '@vben/icons';
import { Button, message, Space } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { apiDelete, apiExport, apiPage } from '#/api/${moduleName}/${businessName}';
import { commonDownloadExcel } from '#/utils/file/download';
import { querySchema, useColumns } from './data';
import Form from './form.vue';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema,
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
};
const [FormDrawer, formDrawerApi] = useVbenDrawer({
connectedComponent: Form,
});
const [Grid, gridApi] = useVbenVxeGrid({
formOptions,
gridOptions: {
columns: useColumns(onActionClick),
height: 'auto',
keepSource: true,
pagerConfig: {
enabled: true,
},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await apiPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
// 高亮当前行
isCurrent: true,
},
} as VxeTableGridOptions,
});
function onActionClick({ code, row }: OnActionClickParams<${BusinessName}Api.${BusinessName}>) {
switch (code) {
case 'delete': {
onDelete(row);
break;
}
case 'edit': {
onEdit(row);
break;
}
default: {
break;
}
}
}
function onRefresh() {
gridApi.query();
}
function onEdit(row: ${BusinessName}Api.${BusinessName}) {
formDrawerApi.setData(row).open();
}
function onCreate() {
formDrawerApi.setData({}).open();
}
function onDelete(row: ${BusinessName}Api.${BusinessName}) {
const hideLoading = message.loading({
content: `正在删除${row.name}...`,
duration: 0,
key: 'action_process_msg',
});
apiDelete(row.id || 0)
.then(() => {
message.success({
content: `${row.name}删除成功`,
key: 'action_process_msg',
});
onRefresh();
})
.catch(() => {
hideLoading();
});
}
function handleDownloadExcel() {
commonDownloadExcel(apiExport, '${functionName}', gridApi.formApi.form.values);
}
</script>
<template>
<Page auto-content-height>
<FormDrawer @success="onRefresh" />
<Grid table-title="${functionName}列表">
<template #toolbar-tools>
<Space>
<Button
v-access:code="['${permissionPrefix}:export']"
@click="handleDownloadExcel"
>
导出
</Button>
<Button
v-access:code="['${permissionPrefix}:add']"
type="primary"
@click="onCreate"
>
<Plus class="size-5" />
新增
</Button>
</Space>
</template>
#foreach($column in $columns)
#set($javaField=$column.javaField)
#if($column.list && $column.htmlType == "imageUpload")
<template #${javaField}="{ row }">
<img style="width: 21px;" :src="row.${javaField}" />
</template>
#end
#end
</Grid>
</Page>
</template>
admin/src/main/resources/vm/vue/modal.vue.vm
0 → 100644
View file @
d6544b0a
<script
lang=
"ts"
setup
>
import
type
{
VbenFormSchema
}
from
'#/adapter/form'
;
import
type
{
$
{
BusinessName
}
Api
}
from
'#/api/${moduleName}/${businessName}'
;
import
{
computed
,
ref
}
from
'vue'
;
import
{
useVbenModal
}
from
'@vben/common-ui'
;
import
{
getVxePopupContainer
}
from
'@vben/utils'
;
import
{
useVbenForm
}
from
'#/adapter/form'
;
import
{
apiAdd
,
apiUpdate
}
from
'#/api/${moduleName}/${businessName}'
;
import
{
defaultFormValueGetter
,
useBeforeCloseDiff
}
from
'#/utils/popup'
;
const
emit
=
defineEmits
<
{
success
:
[];
}
>
();
const
formData
=
ref
<
$
{
BusinessName
}
Api
.
$
{
BusinessName
}
>
();
const
formSchema
:
VbenFormSchema
[]
=
[
#
foreach
(
$column
in
$columns
)
#
set
(
$field
=
$column
.
javaField
)
#
if
((
$column
.
insert
||
$column
.
edit
)
&&
!
$column
.
pk
)
#
set
(
$parentheseIndex
=
$column
.
columnComment
.
indexOf
(
"("
))
#
if
(
$parentheseIndex
!=
-
1
)
#
set
(
$comment
=
$column
.
columnComment
.
substring
(
0
,
$parentheseIndex
))
#
else
#
set
(
$comment
=
$column
.
columnComment
)
#
end
#
set
(
$dictType
=
$column
.
dictType
)
{
#
if
(
$column
.
htmlType
==
"input"
)
component
:
'Input'
,
#
elseif
(
$column
.
htmlType
==
"imageUpload"
)
component
:
'ImageUpload'
,
componentProps
:
{
maxCount
:
1
,
},
#
elseif
(
$column
.
htmlType
==
"fileUpload"
)
component
:
'FileUpload'
,
componentProps
:
{
maxCount
:
1
,
},
#
elseif
(
$column
.
htmlType
==
"editor"
)
component
:
'RichTextarea'
,
componentProps
:
{
width
:
'100%'
,
},
#
elseif
(
$column
.
htmlType
==
"select"
&&
""
!=
$dictType
&&
$dictType
)
component
:
'Select'
,
componentProps
:
{
getVxePopupContainer
,
options
:
getDictOptions
(
'${dictType}'
),
},
#
elseif
(
$column
.
htmlType
==
"select"
&&
!
$dictType
)
component
:
'Select'
,
componentProps
:
{
},
#
elseif
(
$column
.
htmlType
==
"checkbox"
&&
""
!=
$dictType
&&
$dictType
)
component
:
'CheckboxGroup'
,
componentProps
:
{
getVxePopupContainer
,
options
:
getDictOptions
(
'${dictType}'
),
},
#
elseif
(
$column
.
htmlType
==
"checkbox"
&&
!
$dictType
)
component
:
'CheckboxGroup'
,
componentProps
:
{
},
#
elseif
(
$column
.
htmlType
==
"radio"
&&
""
!=
$dictType
&&
$dictType
)
component
:
'RadioGroup'
,
componentProps
:
{
buttonStyle
:
'solid'
,
optionType
:
'button'
,
options
:
getDictOptions
(
'${dictType}'
),
},
#
elseif
(
$column
.
htmlType
==
"radio"
&&
!
$dictType
)
component
:
'RadioGroup'
,
componentProps
:
{
buttonStyle
:
'solid'
,
optionType
:
'button'
,
},
#
elseif
(
$column
.
htmlType
==
"datetime"
)
component
:
'DatePicker'
,
#
elseif
(
$column
.
htmlType
==
"textarea"
)
component
:
'Textarea'
,
#
end
fieldName
:
'${field}'
,
label
:
'${comment}'
,
rules
:
'required'
,
},
#
end
#
end
];
const
[
BasicForm
,
formApi
]
=
useVbenForm
({
commonConfig
:
{
componentProps
:
{
class
:
'w-full'
,
},
formItemClass
:
'col-span-2'
,
labelWidth
:
90
,
},
schema
:
formSchema
,
showDefaultActions
:
false
,
wrapperClass
:
'grid-cols-2'
,
});
const
{
onBeforeClose
,
markInitialized
,
resetInitialized
}
=
useBeforeCloseDiff
(
{
initializedGetter
:
defaultFormValueGetter
(
formApi
),
currentGetter
:
defaultFormValueGetter
(
formApi
),
},
);
const
[
BasicModal
,
modalApi
]
=
useVbenModal
({
fullscreenButton
:
false
,
onBeforeClose
,
onClosed
:
handleClosed
,
onConfirm
:
onSubmit
,
onOpenChange
:
async
(
isOpen
)
=>
{
if
(
!
isOpen
)
{
return
null
;
}
modalApi
.
modalLoading
(
true
);
const
data
=
modalApi
.
getData
<
$
{
BusinessName
}
Api
.
$
{
BusinessName
}
>
();
if
(
data
)
{
formData
.
value
=
data
;
await
formApi
.
setValues
(
formData
.
value
);
}
await
markInitialized
();
modalApi
.
modalLoading
(
false
);
},
});
async
function
onSubmit
()
{
const
{
valid
}
=
await
formApi
.
validate
();
if
(
valid
)
{
modalApi
.
lock
();
const
data
=
await
formApi
.
getValues
<
$
{
BusinessName
}
Api
.
$
{
BusinessName
}
>
();
try
{
await
(
formData
.
value
?.
id
?
apiUpdate
({
id
:
formData
.
value
.
id
,
...
data
})
:
apiAdd
(
data
));
resetInitialized
();
emit
(
'success'
);
modalApi
.
close
();
}
finally
{
modalApi
.
unlock
();
}
}
}
async
function
handleClosed
()
{
await
formApi
.
resetForm
();
resetInitialized
();
}
const
getModalTitle
=
computed
(()
=>
formData
.
value
?.
id
?
'修改${functionName}'
:
'新增${functionName}'
,
);
</script>
<template>
<BasicModal
:title=
"getModalTitle"
>
<BasicForm
class=
"mx-4"
/>
</BasicModal>
</template>
admin/src/main/resources/vm/xml/mapper.xml.vm
0 → 100644
View file @
d6544b0a
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"${packageName}.mapper.${className}.${ClassName}Mapper"
>
</mapper>
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