Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
appbuild
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
赵啸非
appbuild
Commits
8dd6121e
Commit
8dd6121e
authored
2 years ago
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加feign接口自动生成
parent
aa098ae5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
63 deletions
+80
-63
appbuild-manager/src/main/java/com/mortals/xhx/base/system/gentable/service/impl/GentableServiceImpl.java
...ase/system/gentable/service/impl/GentableServiceImpl.java
+65
-48
appbuild-manager/src/main/resources/template/java/feign.java.ftl
...d-manager/src/main/resources/template/java/feign.java.ftl
+15
-15
No files found.
appbuild-manager/src/main/java/com/mortals/xhx/base/system/gentable/service/impl/GentableServiceImpl.java
View file @
8dd6121e
...
...
@@ -162,43 +162,56 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
continue
;
}
//如果开启feign生成模式,加载feign生成模板
if
(
gentableEntity
.
getGenFeign
()
!=
null
&&
gentableEntity
.
getGenFeign
()
==
0
)
{
if
(
gentableEntity
.
getGenFeign
()
!=
null
&&
gentableEntity
.
getGenFeign
()
==
0
)
{
if
(
temp
.
contains
(
"feign.java.ftl"
)
||
temp
.
contains
(
"pdu.java.ftl"
))
{
continue
;
}
}
if
(
gentableEntity
.
getIsShowControl
()!=
null
&&
gentableEntity
.
getIsShowControl
()
==
2
)
{
if
(
temp
.
contains
(
"webForm.java.ftl"
))
{
continue
;
}
if
(
gentableEntity
.
getIsShowControl
()
!=
null
)
{
if
(
gentableEntity
.
getIsShowControl
()
==
2
)
{
if
(
temp
.
contains
(
"webForm.java.ftl"
))
{
continue
;
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
}
if
(
gentableEntity
.
getIsShowControl
()
==
0
)
{
if
(
temp
.
contains
(
"webBody.java.ftl"
))
{
}
else
if
(
gentableEntity
.
getIsShowControl
()
==
0
)
{
if
(
temp
.
contains
(
"webBody.java.ftl"
))
{
continue
;
}
}
}
else
{
if
(
temp
.
contains
(
"webForm.java.ftl"
))
{
continue
;
}
}
if
(
gentableEntity
.
getDetailShow
()!=
null
&&
gentableEntity
.
getDetailShow
()
==
0
)
{
if
(
temp
.
contains
(
"VueDialogShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
1
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
2
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDialogShow.vue.ftl"
))
{
continue
;
if
(
gentableEntity
.
getDetailShow
()
!=
null
)
{
if
(
gentableEntity
.
getDetailShow
()
==
0
)
{
if
(
temp
.
contains
(
"VueDialogShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
1
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
2
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDialogShow.vue.ftl"
))
{
continue
;
}
}
else
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
}
else
{
}
else
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
if
(
temp
.
equals
(
"menu.sql.ftl"
)
||
temp
.
equals
(
"db.sql.ftl"
)
||
temp
.
equals
(
"api.md.ftl"
))
{
try
{
List
<
GentableEntity
>
tableList
=
new
ArrayList
<>();
...
...
@@ -502,41 +515,45 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
continue
;
}
//restBody模式 不加载web,webForm模式
if
(
gentableEntity
.
getIsShowControl
()
==
2
)
{
if
(
temp
.
contains
(
"web.java.ftl"
)
||
temp
.
contains
(
"webForm.java.ftl"
))
{
continue
;
if
(
gentableEntity
.
getIsShowControl
()
!=
null
)
{
if
(
gentableEntity
.
getIsShowControl
()
==
2
)
{
if
(
temp
.
contains
(
"webForm.java.ftl"
))
{
continue
;
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
}
else
if
(
gentableEntity
.
getIsShowControl
()
==
0
)
{
if
(
temp
.
contains
(
"webBody.java.ftl"
))
{
continue
;
}
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
}
else
{
if
(
temp
.
contains
(
"webBody.java.ftl"
))
{
continue
;
}
}
//如果开启feign生成模式,加载feign生成模板
if
(
gentableEntity
.
getGenFeign
()
==
0
)
{
if
(
temp
.
contains
(
"feign.java.ftl"
)
||
temp
.
contains
(
"pdu.java.ftl"
))
{
if
(
temp
.
contains
(
"webForm.java.ftl"
))
{
continue
;
}
}
if
(
gentableEntity
.
getDetailShow
()!=
null
&&
gentableEntity
.
getDetailShow
()
==
0
)
{
if
(
temp
.
contains
(
"VueDialogShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
1
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
2
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDialogShow.vue.ftl"
))
{
continue
;
if
(
gentableEntity
.
getDetailShow
()
!=
null
)
{
if
(
gentableEntity
.
getDetailShow
()
==
0
)
{
if
(
temp
.
contains
(
"VueDialogShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
1
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
else
if
(
gentableEntity
.
getDetailShow
()
==
2
)
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDialogShow.vue.ftl"
))
{
continue
;
}
}
else
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
}
}
else
{
}
else
{
if
(
temp
.
contains
(
"webVueShow.vue.ftl"
)
||
temp
.
contains
(
"VueDrawerShow.vue.ftl"
))
{
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
appbuild-manager/src/main/resources/template/java/feign.java.ftl
View file @
8dd6121e
package
${
packageFeignName
};
import
com
.
mortals
.
xhx
.
common
.
pdu
.
RespData
;
import
com
.
mortals
.
xhx
.
common
.
pdu
.${
businessName
}.${
ClassName
}
Pdu
;
import
com
.
alibaba
.
fastjson
.
JSON
;
import
com
.
mortals
.
framework
.
common
.
Rest
;
...
...
@@ -9,13 +9,13 @@ import lombok.extern.slf4j.Slf4j;
import
org
.
springframework
.
cloud
.
openfeign
.
FeignClient
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
import
java
.
util
.
List
;
/**
*
${
functionName
}
Feign
接口
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
FeignClient
(
name
=
"${code}"
,
path
=
"${path}"
,
fallback
=
${
ClassName
}
FeignFallbackFactory
.
class
)
@
FeignClient
(
name
=
"${code}"
,
path
=
"${path}"
,
fallback
Factory
=
${
ClassName
}
FeignFallbackFactory
.
class
)
public
interface
I
${
ClassName
}
Feign
extends
IFeign
{
...
...
@@ -26,7 +26,7 @@ public interface I${ClassName}Feign extends IFeign {
*
@
return
*/
@
PostMapping
(
value
=
"/${RequestMapping}/list"
)
String
list
(@
RequestBody
${
ClassName
}
Pdu
${
className
}
Pdu
);
Rest
<
RespData
<
List
<${
ClassName
}
Pdu
>>>
list
(@
RequestBody
${
ClassName
}
Pdu
${
className
}
Pdu
);
/**
...
...
@@ -36,7 +36,7 @@ public interface I${ClassName}Feign extends IFeign {
*
@
return
*/
@
GetMapping
(
value
=
"/${RequestMapping}/info"
)
String
info
(@
RequestParam
(
value
=
"id"
)
Long
id
);
Rest
<${
ClassName
}
Pdu
>
info
(@
RequestParam
(
value
=
"id"
)
Long
id
);
/**
*
删除
${
functionName
}
...
...
@@ -45,7 +45,7 @@ public interface I${ClassName}Feign extends IFeign {
*
@
return
*/
@
GetMapping
(
value
=
"/${RequestMapping}/delete"
)
String
delete
(
Long
[]
ids
,@
RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
Void
>
delete
(
Long
[]
ids
,@
RequestHeader
(
"Authorization"
)
String
authorization
);
/**
...
...
@@ -55,7 +55,7 @@ public interface I${ClassName}Feign extends IFeign {
*
@
return
*/
@
PostMapping
(
value
=
"/${RequestMapping}/save"
)
String
save
(@
RequestBody
${
ClassName
}
Pdu
${
className
}
Pdu
,@
RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
RespData
<${
ClassName
}
Pdu
>>
save
(@
RequestBody
${
ClassName
}
Pdu
${
className
}
Pdu
,@
RequestHeader
(
"Authorization"
)
String
authorization
);
}
...
...
@@ -68,23 +68,23 @@ class ${ClassName}FeignFallbackFactory implements FallbackFactory<I${ClassName}F
public
I
${
ClassName
}
Feign
create
(
Throwable
t
)
{
return
new
I
${
ClassName
}
Feign
()
{
@
Override
public
String
list
(${
ClassName
}
Pdu
${
className
}
Pdu
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法获取${functionName}列表,请稍后再试!"
)
);
public
Rest
<
RespData
<
List
<${
ClassName
}
Pdu
>>>
list
(${
ClassName
}
Pdu
${
className
}
Pdu
)
{
return
Rest
.
fail
(
"暂时无法获取${functionName}列表,请稍后再试!"
);
}
@
Override
public
String
info
(
Long
id
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法获取${functionName}详细,请稍后再试!"
)
);
public
Rest
<${
ClassName
}
Pdu
>
info
(
Long
id
)
{
return
Rest
.
fail
(
"暂时无法获取${functionName}详细,请稍后再试!"
);
}
@
Override
public
String
delete
(
Long
[]
ids
,
String
authorization
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法删除${functionName},请稍后再试!"
)
);
public
Rest
<
Void
>
delete
(
Long
[]
ids
,
String
authorization
)
{
return
Rest
.
fail
(
"暂时无法删除${functionName},请稍后再试!"
);
}
@
Override
public
String
save
(${
ClassName
}
Pdu
${
className
}
Pdu
,
String
authorization
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法保存${functionName},请稍后再试!"
)
);
public
Rest
<
RespData
<${
ClassName
}
Pdu
>>
save
(${
ClassName
}
Pdu
${
className
}
Pdu
,
String
authorization
)
{
return
Rest
.
fail
(
"暂时无法保存${functionName},请稍后再试!"
);
}
};
}
...
...
This diff is collapsed.
Click to expand it.
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