Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
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
s_guodong
gjjs-bd-common
Commits
23c485dd
Commit
23c485dd
authored
Aug 18, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
返回值的层级结构增加root
parent
090d76dc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
95 deletions
+81
-95
AbstractCommonResource.java
...om/ceb/gjjs/mda/resource/base/AbstractCommonResource.java
+42
-41
RespondRoot.java
...java/com/brilliance/mda/runtime/response/RespondRoot.java
+23
-0
ResponseSet.java
...java/com/brilliance/mda/runtime/response/ResponseSet.java
+16
-54
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/resource/base/AbstractCommonResource.java
View file @
23c485dd
...
...
@@ -2,6 +2,7 @@ package com.ceb.gjjs.mda.resource.base;
import
com.brilliance.mda.runtime.mda.driver.MdaEnv
;
import
com.brilliance.mda.runtime.request.BaseVO
;
import
com.brilliance.mda.runtime.response.RespondRoot
;
import
com.brilliance.mda.runtime.response.ResponseSet
;
import
com.brilliance.mda.support.service.ICommonService
;
import
com.brilliance.mda.support.td.BDAuthInfo
;
...
...
@@ -36,116 +37,116 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
@Path
(
"/init"
)
@POST
public
Respon
seSe
t
<
V
>
init
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
init
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
init
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
init
(
req
)
);
}
@Path
(
"/checkAll"
)
@POST
public
Respon
seSe
t
checkAll
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
checkAll
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
checkAll
(
req
);
return
new
RespondRoot
(
getCommonService
().
checkAll
(
req
)
);
}
@Path
(
"/saveData"
)
@POST
public
Respon
seSe
t
<
V
>
saveData
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
saveData
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
saveData
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
saveData
(
req
)
);
}
@Path
(
"/confirmData"
)
@POST
public
Respon
seSe
t
<
V
>
confirmData
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
confirmData
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
confirmData
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
confirmData
(
req
)
);
}
@Path
(
"/pending"
)
@POST
public
Respon
seSe
t
<
V
>
pending
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
pending
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
pending
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
pending
(
req
)
);
}
@Path
(
"/executeCheck/{rule}"
)
@POST
public
Respon
seSe
t
<
V
>
executeCheck
(
@PathParam
(
"rule"
)
String
rule
,
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
executeCheck
(
@PathParam
(
"rule"
)
String
rule
,
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
String
[]
ruleArr
=
rule
.
split
(
","
);
return
getCommonService
().
executeCheck
(
req
,
ruleArr
);
return
new
RespondRoot
<>(
getCommonService
().
executeCheck
(
req
,
ruleArr
)
);
}
@Path
(
"/executeRule/{rule}"
)
@POST
public
Respon
seSe
t
<
V
>
executeRule
(
@PathParam
(
"rule"
)
String
rule
,
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
executeRule
(
@PathParam
(
"rule"
)
String
rule
,
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
String
[]
ruleArr
=
rule
.
split
(
","
);
return
getCommonService
().
executeRule
(
req
,
ruleArr
);
return
new
RespondRoot
<>(
getCommonService
().
executeRule
(
req
,
ruleArr
)
);
}
@Path
(
"/executeDefault/{rule}"
)
@POST
public
Respon
seSe
t
<
V
>
executeDefault
(
@PathParam
(
"rule"
)
String
rule
,
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
executeDefault
(
@PathParam
(
"rule"
)
String
rule
,
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
String
[]
ruleArr
=
rule
.
split
(
","
);
return
getCommonService
().
executeDefault
(
req
,
ruleArr
);
return
new
RespondRoot
<>(
getCommonService
().
executeDefault
(
req
,
ruleArr
)
);
}
@Path
(
"/executeNotify"
)
@POST
public
Respon
seSe
t
<
V
>
executeNotify
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
executeNotify
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
executeNotify
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
executeNotify
(
req
)
);
}
@Path
(
"/executeDocpan"
)
@POST
public
Respon
seSe
t
<
V
>
executeDocpan
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
executeDocpan
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
executeDocpan
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
executeDocpan
(
req
)
);
}
@Path
(
"/executeDocpanDetail"
)
@POST
public
Respon
seSe
t
<
V
>
executeDocpanDetail
(
@RequestBody
V
req
)
{
public
Respon
dRoo
t
<
V
>
executeDocpanDetail
(
@RequestBody
V
req
)
{
String
checkResult
=
resetAndcheckParam
(
req
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
req
)
);
}
return
getCommonService
().
executeDocpanDetail
(
req
);
return
new
RespondRoot
<>(
getCommonService
().
executeDocpanDetail
(
req
)
);
}
...
...
@@ -160,7 +161,7 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
}
protected
<
T
>
Respon
seSe
t
<
T
>
executeRule
(
RequestCommonVo
requestCommonVo
,
Class
<
T
>
respondVoClass
,
String
rule
)
{
protected
<
T
>
Respon
dRoo
t
<
T
>
executeRule
(
RequestCommonVo
requestCommonVo
,
Class
<
T
>
respondVoClass
,
String
rule
)
{
V
baseVO
=
getVo
();
RequestBaseVo
requestBaseVo
=
requestCommonVo
.
getRoot
();
T
t
=
null
;
...
...
@@ -170,22 +171,22 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
}
String
s
=
resetAndcheckBaseParam
(
requestBaseVo
,
baseVO
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
s
,
t
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
s
,
t
)
);
}
String
checkResult
=
resetAndcheckParam
(
requestBaseVo
,
baseVO
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
t
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
t
)
);
}
String
[]
ruleArr
=
new
String
[]{
rule
};
ResponseSet
responseSet
=
getCommonService
().
executeRule
(
baseVO
,
ruleArr
);
Object
data
=
responseSet
.
getData
();
ReflectUtil
.
setValue2RespondVo
(
t
,
respondVoClass
,
data
,
baseVO
.
getClass
());
responseSet
.
setData
(
t
);
return
responseSet
;
return
new
RespondRoot
<>(
responseSet
)
;
}
protected
<
T
>
Respon
seSe
t
<
T
>
executeCheck
(
RequestCommonVo
<
RequestBaseVo
>
requestCommonVo
,
Class
<
T
>
respondVoClass
,
String
rule
)
{
protected
<
T
>
Respon
dRoo
t
<
T
>
executeCheck
(
RequestCommonVo
<
RequestBaseVo
>
requestCommonVo
,
Class
<
T
>
respondVoClass
,
String
rule
)
{
V
baseVO
=
getVo
();
RequestBaseVo
requestBaseVo
=
requestCommonVo
.
getRoot
();
T
t
=
null
;
...
...
@@ -195,18 +196,18 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
}
String
s
=
resetAndcheckBaseParam
(
requestBaseVo
,
baseVO
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
s
,
t
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
s
,
t
)
);
}
String
checkResult
=
resetAndcheckParam
(
requestBaseVo
,
baseVO
);
if
(
StringUtils
.
isNotBlank
(
checkResult
))
{
return
new
Respon
seSet
<>(
ResponseSet
.
CODE_FAILURE
,
checkResult
,
t
);
return
new
Respon
dRoot
<>(
new
ResponseSet
<>(
ResponseSet
.
CODE_FAILURE
,
s
,
t
)
);
}
String
[]
ruleArr
=
new
String
[]{
rule
};
ResponseSet
responseSet
=
getCommonService
().
executeCheck
(
baseVO
,
ruleArr
);
Object
data
=
responseSet
.
getData
();
ReflectUtil
.
setValue2RespondVo
(
t
,
respondVoClass
,
data
,
baseVO
.
getClass
());
responseSet
.
setData
(
t
);
return
responseSet
;
return
new
RespondRoot
<>(
responseSet
)
;
}
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/response/RespondRoot.java
0 → 100644
View file @
23c485dd
package
com
.
brilliance
.
mda
.
runtime
.
response
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/18
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
public
class
RespondRoot
<
T
>
implements
Serializable
{
private
ResponseSet
<
T
>
root
;
public
RespondRoot
(
ResponseSet
<
T
>
root
)
{
this
.
root
=
root
;
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/response/ResponseSet.java
View file @
23c485dd
...
...
@@ -21,18 +21,14 @@ public class ResponseSet<T> {
public
static
final
String
CODE_FAILURE
=
"BBBBBB"
;
public
static
final
String
MSG_SUCESS
=
"操作成功!"
;
private
String
respCode
;
private
String
respMsg
;
private
Map
<
String
,
String
>
fieldErrors
;
private
Map
<
String
,
List
<
String
>>
codeSet
;
private
String
retcod
;
private
String
retmsg
;
private
Object
data
;
public
ResponseSet
(
IContext
ctx
,
Object
t
)
{
this
.
re
spCode
=
CODE_SUCCESS
;
this
.
re
spM
sg
=
MSG_SUCESS
;
this
.
re
tcod
=
CODE_SUCCESS
;
this
.
re
tm
sg
=
MSG_SUCESS
;
this
.
data
=
t
;
fieldErrors
=
cloneFieldErrorsFromContext
(
ctx
);
this
.
codeSet
=
getValuesSet
(
ctx
);
ctx
.
visitValues
();
MdaDriver
.
setValueToVO
(
ctx
,
this
.
data
);
}
...
...
@@ -47,42 +43,24 @@ public class ResponseSet<T> {
return
valuesSet
;
}
private
Map
<
String
,
String
>
cloneFieldErrorsFromContext
(
IContext
ctx
)
{
if
(
ctx
==
null
)
{
return
null
;
}
Map
<
String
,
String
>
fieldErrors
=
ctx
.
getFieldErrors
();
Map
<
String
,
String
>
fieldErrorsClone
=
new
LinkedHashMap
<>();
fieldErrorsClone
.
putAll
(
fieldErrors
);
fieldErrors
.
clear
();
return
fieldErrorsClone
;
}
public
ResponseSet
(
Object
t
)
{
this
.
re
spCode
=
CODE_SUCCESS
;
this
.
re
spM
sg
=
MSG_SUCESS
;
this
.
re
tcod
=
CODE_SUCCESS
;
this
.
re
tm
sg
=
MSG_SUCESS
;
if
(
MdaEnv
.
getContext
()
!=
null
)
{
fieldErrors
=
cloneFieldErrorsFromContext
(
MdaEnv
.
getContext
());
this
.
codeSet
=
getValuesSet
(
MdaEnv
.
getContext
());
MdaEnv
.
getContext
().
visitValues
();
}
this
.
data
=
t
;
}
public
ResponseSet
(
String
errCode
,
String
errMsg
)
{
this
.
re
spCode
=
errCode
;
this
.
re
spM
sg
=
errMsg
;
this
.
re
tcod
=
errCode
;
this
.
re
tm
sg
=
errMsg
;
if
(
MdaEnv
.
getContext
()
!=
null
)
{
fieldErrors
=
cloneFieldErrorsFromContext
(
MdaEnv
.
getContext
());
this
.
codeSet
=
getValuesSet
(
MdaEnv
.
getContext
());
MdaEnv
.
getContext
().
visitValues
();
}
}
// public ResponseSet(String errCode,String errMsg,Map<String,String> fieldErrors){
// this(errCode,errMsg);
// this.fieldErrors = fieldErrors;
// }
public
ResponseSet
(
String
errCode
,
String
errMsg
,
T
t
)
{
this
(
errCode
,
errMsg
);
this
.
data
=
t
;
...
...
@@ -99,36 +77,20 @@ public class ResponseSet<T> {
this
.
data
=
data
;
}
public
String
getRespCode
()
{
return
respCode
;
}
public
void
setRespCode
(
String
respCode
)
{
this
.
respCode
=
respCode
;
}
public
String
getRespMsg
()
{
return
respMsg
;
}
public
void
setRespMsg
(
String
respMsg
)
{
this
.
respMsg
=
respMsg
;
}
public
Map
<
String
,
String
>
getFieldErrors
()
{
return
fieldErrors
;
public
String
getRetcod
()
{
return
retcod
;
}
public
void
set
FieldErrors
(
Map
<
String
,
String
>
fieldErrors
)
{
this
.
fieldErrors
=
fieldErrors
;
public
void
set
Retcod
(
String
retcod
)
{
this
.
retcod
=
retcod
;
}
public
Map
<
String
,
List
<
String
>>
getCodeSet
()
{
return
codeSet
;
public
String
getRetmsg
()
{
return
retmsg
;
}
public
void
set
CodeSet
(
Map
<
String
,
List
<
String
>>
codeSet
)
{
this
.
codeSet
=
codeSet
;
public
void
set
Retmsg
(
String
retmsg
)
{
this
.
retmsg
=
retmsg
;
}
static
class
BooleanResult
{
...
...
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