Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
78296679
提交
78296679
编写于
9月 02, 2022
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
basePath
上级
b7fdef29
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
61 行增加
和
36 行删除
+61
-36
ApiMethodModel.java
...rc/main/java/cn/ibizlab/codegen/model/ApiMethodModel.java
+46
-30
ApiModel.java
...core/src/main/java/cn/ibizlab/codegen/model/ApiModel.java
+4
-0
BootSecurityConfig.java.hbs
...n/java/{{packageName}}/config/BootSecurityConfig.java.hbs
+5
-0
{{apiEntities}}Resource.java.hbs
...kageName}}/{{apis}}/rest/{{apiEntities}}Resource.java.hbs
+6
-6
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ApiMethodModel.java
浏览文件 @
78296679
...
...
@@ -82,48 +82,64 @@ public class ApiMethodModel extends BaseModel {
return
strName
;
}
private
String
requestPath
;
public
String
getRequestPath
()
{
String
path
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
parentApiEntities
))
{
for
(
ApiEntityRSModel
apiRs
:
parentApiEntities
)
{
String
strMajorEntityPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiRs
.
getMajorEntityCodeName
()).
toLowerCase
());
path
=
String
.
format
(
"/%s/{%s}"
,
strMajorEntityPlurlize
,
StringAdvUtils
.
camelcase
(
apiRs
.
getParentIdFieldCodeName
()))
+
path
;
if
(
requestPath
==
null
)
{
String
path
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
parentApiEntities
))
{
for
(
ApiEntityRSModel
apiRs
:
parentApiEntities
)
{
String
strMajorEntityPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiRs
.
getMajorEntityCodeName
()).
toLowerCase
());
path
=
String
.
format
(
"/%s/{%s}"
,
strMajorEntityPlurlize
,
StringAdvUtils
.
camelcase
(
apiRs
.
getParentIdFieldCodeName
()))
+
path
;
}
}
}
//主键
String
strPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiEntity
.
getCodeName
()).
toLowerCase
());
if
(
getPSDEServiceAPIMethod
().
isNeedResourceKey
()&&(!
"save"
.
equalsIgnoreCase
(
name
)))
{
path
=
path
+
String
.
format
(
"/%s/{%s}"
,
strPlurlize
,
StringAdvUtils
.
camelcase
(
apiEntity
.
getEntity
().
getKeyField
().
getCodeName
()));
}
else
{
path
=
path
+
String
.
format
(
"/%s"
,
strPlurlize
);
}
//主键
String
strPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiEntity
.
getCodeName
()).
toLowerCase
());
if
(
getPSDEServiceAPIMethod
().
isNeedResourceKey
()&&(!
"save"
.
equalsIgnoreCase
(
name
)))
{
path
=
path
+
String
.
format
(
"/%s/{%s}"
,
strPlurlize
,
StringAdvUtils
.
camelcase
(
apiEntity
.
getEntity
().
getKeyField
().
getCodeName
()));
}
else
{
path
=
path
+
String
.
format
(
"/%s"
,
strPlurlize
);
}
//方法名
if
(!
ArrayUtils
.
contains
(
ignoreMethodNames
,
this
.
getName
().
toUpperCase
()))
{
path
=
path
+
String
.
format
(
"/%s"
,
this
.
getName
().
toLowerCase
());
//方法名
if
(!
ArrayUtils
.
contains
(
ignoreMethodNames
,
this
.
getName
().
toUpperCase
()))
{
path
=
path
+
String
.
format
(
"/%s"
,
this
.
getName
().
toLowerCase
());
}
requestPath
=
path
;
}
return
requestPath
;
}
return
path
;
public
String
getRequestPath2
()
{
if
(!
ObjectUtils
.
isEmpty
(
this
.
getRequestPath
()))
return
requestPath
.
substring
(
1
);
return
""
;
}
private
List
pathVariables
;
public
List
getPathVariables
()
{
List
pathVariables
=
new
ArrayList
();
if
(!
CollectionUtils
.
isEmpty
(
parentApiEntities
))
{
for
(
ApiEntityRSModel
apiRs
:
parentApiEntities
)
{
String
strMajorEntityPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiRs
.
getMajorEntityCodeName
()).
toLowerCase
());
if
(
pathVariables
==
null
)
{
pathVariables
=
new
ArrayList
();
if
(!
CollectionUtils
.
isEmpty
(
parentApiEntities
))
{
for
(
ApiEntityRSModel
apiRs
:
parentApiEntities
)
{
String
strMajorEntityPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiRs
.
getMajorEntityCodeName
()).
toLowerCase
());
JSONObject
pathVariable
=
new
JSONObject
();
pathVariable
.
put
(
"name"
,
apiRs
.
getParentIdFieldCodeName
());
pathVariable
.
put
(
"type"
,
PropType
.
findType
(
apiRs
.
getParentIdFieldType
()));
pathVariables
.
add
(
0
,
pathVariable
);
}
}
if
(
getPSDEServiceAPIMethod
().
isNeedResourceKey
()&&(!
"save"
.
equalsIgnoreCase
(
name
)))
{
JSONObject
pathVariable
=
new
JSONObject
();
pathVariable
.
put
(
"name"
,
api
Rs
.
getParentIdField
CodeName
());
pathVariable
.
put
(
"type"
,
PropType
.
findType
(
apiRs
.
getParentIdFieldType
()
));
pathVariables
.
add
(
0
,
pathVariable
);
pathVariable
.
put
(
"name"
,
api
Entity
.
getEntity
().
getKeyField
().
get
CodeName
());
pathVariable
.
put
(
"type"
,
apiEntity
.
getEntity
().
getKeyField
().
getType
(
));
pathVariables
.
add
(
pathVariable
);
}
}
if
(
getPSDEServiceAPIMethod
().
isNeedResourceKey
()&&(!
"save"
.
equalsIgnoreCase
(
name
)))
{
JSONObject
pathVariable
=
new
JSONObject
();
pathVariable
.
put
(
"name"
,
apiEntity
.
getEntity
().
getKeyField
().
getCodeName
());
pathVariable
.
put
(
"type"
,
apiEntity
.
getEntity
().
getKeyField
().
getType
());
pathVariables
.
add
(
pathVariable
);
}
return
pathVariables
;
}
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ApiModel.java
浏览文件 @
78296679
...
...
@@ -36,6 +36,10 @@ public class ApiModel extends BaseModel {
}
public
String
getBasePath
()
{
return
"${ibiz.rest.basePath."
+
this
.
codeName
.
toLowerCase
()+
":/"
+
this
.
codeName
.
toLowerCase
()+
"/}"
;
}
private
SystemModel
system
;
...
...
modules/ibizlab-template/ibizlab-template-ibizedge/src/main/resources/templ/{{projectName}}-boot/src/main/java/{{packageName}}/config/BootSecurityConfig.java.hbs
浏览文件 @
78296679
...
...
@@ -98,6 +98,11 @@ public class BootSecurityConfig extends WebSecurityConfigurerAdapter {
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.png",
"/**/*.ttf",
"/**/*.woff",
"/**/*.eot",
"/**/*.woff2",
"/**/*.ico",
"/**/assets/**",
"/**/css/**",
...
...
modules/ibizlab-template/ibizlab-template-ibizedge/src/main/resources/templ/{{projectName}}-core/src/main/java/{{packageName}}/{{apis}}/rest/{{apiEntities}}Resource.java.hbs
浏览文件 @
78296679
...
...
@@ -38,7 +38,7 @@ import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"
{{
apiEntity
.
apiName
}}
" })
@RestController("
{{
lowerCase
apiEntity
.
api
.
codeName
}}
-
{{
lowerCase
apiEntity
.
codeName
}}
")
@RequestMapping("
/
{{
lowerCase
apiEntity
.
api
.
codeName
}}
")
@RequestMapping("
{{
apiEntity
.
api
.
basePath
}}
")
public class
{{
apiEntity
.
codeName
}}
Resource {
@Autowired
...
...
@@ -66,7 +66,7 @@ public class {{apiEntity.codeName}}Resource {
{{/if}}
{{/
eq
}}
{{/
eq
}}
@RequestMapping(method = RequestMethod.
{{
requestMethod
}}
, value = "
{{
requestPath
}}
")
@RequestMapping(method = RequestMethod.
{{
requestMethod
}}
, value = "
{{
requestPath
2
}}
")
public ResponseEntity
<
{{
outParam
}}
>
{{
camelCase
name
}}{{#
each
pathVariables
}}{{#if
@first
}}
By
{{else}}
And
{{/if}}{{
pascalCase
name
}}{{/
each
}}
(
{{#
each
pathVariables
}}{{#
unless
@first
}}
,
{{/
unless
}}
@PathVariable("
{{
camelCase
name
}}
")
{{
type
.
java
}}
{{
camelCase
name
}}{{/
each
}}{{#if
body
}}{{#if
pathVariables
}}
,
{{/if}}{{#
neq
requestMethod
'GET'
}}
@Validated @RequestBody
{{/
neq
}}{{
body
}}{{/if}}
) {
{{!行为}}
...
...
@@ -121,7 +121,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','
{{
projectName
}}
-
{{
apiEntity
.
entity
.
codeName
}}
-Create-all')")
@ApiOperation(value = "批量新建
{{
apiEntity
.
entity
.
logicName
}}
", tags = {"
{{
apiEntity
.
entity
.
logicName
}}
" }, notes = "批量新建
{{
apiEntity
.
entity
.
logicName
}}
")
@RequestMapping(method = RequestMethod.POST, value = "
/
{{
pluralize
apiEntity
.
codeName
}}
/batch")
@RequestMapping(method = RequestMethod.POST, value = "
{{
pluralize
apiEntity
.
codeName
}}
/batch")
public ResponseEntity
<Boolean>
createBatch(@RequestBody List
<
{{
apiEntity
.
codeName
}}
DTO>
dtos) {
{{
camelCase
apiEntity
.
entity
.
codeName
}}
Service.createBatch(
{{
camelCase
apiEntity
.
defaultDto
.
codeName
}}
Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
...
...
@@ -129,7 +129,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','
{{
projectName
}}
-
{{
apiEntity
.
entity
.
codeName
}}
-Update-all')")
@ApiOperation(value = "批量更新
{{
apiEntity
.
entity
.
logicName
}}
", tags = {"
{{
apiEntity
.
entity
.
logicName
}}
" }, notes = "批量更新
{{
apiEntity
.
entity
.
logicName
}}
")
@RequestMapping(method = RequestMethod.PUT, value = "
/
{{
pluralize
apiEntity
.
codeName
}}
/batch")
@RequestMapping(method = RequestMethod.PUT, value = "
{{
pluralize
apiEntity
.
codeName
}}
/batch")
public ResponseEntity
<Boolean>
updateBatch(@RequestBody List
<
{{
apiEntity
.
codeName
}}
DTO>
dtos) {
{{
camelCase
apiEntity
.
entity
.
codeName
}}
Service.updateBatch(
{{
camelCase
apiEntity
.
defaultDto
.
codeName
}}
Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
...
...
@@ -137,7 +137,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','
{{
projectName
}}
-
{{
apiEntity
.
entity
.
codeName
}}
-Save-all')")
@ApiOperation(value = "批量保存
{{
apiEntity
.
entity
.
logicName
}}
", tags = {"
{{
apiEntity
.
entity
.
logicName
}}
" }, notes = "批量保存
{{
apiEntity
.
entity
.
logicName
}}
")
@RequestMapping(method = RequestMethod.POST, value = "
/
{{
pluralize
apiEntity
.
codeName
}}
/savebatch")
@RequestMapping(method = RequestMethod.POST, value = "
{{
pluralize
apiEntity
.
codeName
}}
/savebatch")
public ResponseEntity
<Boolean>
saveBatch(@RequestBody List
<
{{
apiEntity
.
codeName
}}
DTO>
dtos) {
{{
camelCase
apiEntity
.
entity
.
codeName
}}
Service.saveBatch(
{{
camelCase
apiEntity
.
defaultDto
.
codeName
}}
Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
...
...
@@ -145,7 +145,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','
{{
projectName
}}
-
{{
apiEntity
.
entity
.
codeName
}}
-Remove-all')")
@ApiOperation(value = "批量删除
{{
apiEntity
.
entity
.
logicName
}}
", tags = {"
{{
apiEntity
.
entity
.
logicName
}}
" }, notes = "批量删除
{{
apiEntity
.
entity
.
logicName
}}
")
@RequestMapping(method = RequestMethod.DELETE, value = {"
/
{{
pluralize
apiEntity
.
codeName
}}
","/
{{
pluralize
apiEntity
.
codeName
}}
/batch"})
@RequestMapping(method = RequestMethod.DELETE, value = {"
{{
pluralize
apiEntity
.
codeName
}}
","/
{{
pluralize
apiEntity
.
codeName
}}
/batch"})
public ResponseEntity
<Boolean>
removeBatch(@RequestBody List
<
{{
apiEntity
.
entity
.
keyField
.
type
.
java
}}
>
ids) {
{{
camelCase
apiEntity
.
entity
.
codeName
}}
Service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录