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
1e68e2b7
Commit
1e68e2b7
authored
Aug 11, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定制vo
parent
1f0bd7b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
172 additions
and
81 deletions
+172
-81
AbstractCommonResource.java
...om/ceb/gjjs/mda/resource/base/AbstractCommonResource.java
+0
-0
DemoResultVo.java
...c/main/java/com/ceb/gjjs/mda/special/vo/DemoResultVo.java
+31
-0
DemoVo.java
...ess/src/main/java/com/ceb/gjjs/mda/special/vo/DemoVo.java
+2
-5
RequestBaseVo.java
.../main/java/com/ceb/gjjs/mda/special/vo/RequestBaseVo.java
+36
-0
RespondBaseVo.java
.../main/java/com/ceb/gjjs/mda/special/vo/RespondBaseVo.java
+9
-0
ReflectUtil.java
...ness/src/main/java/com/ceb/gjjs/mda/util/ReflectUtil.java
+80
-19
BaseVO.java
.../main/java/com/brilliance/mda/runtime/request/BaseVO.java
+14
-57
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/resource/base/AbstractCommonResource.java
View file @
1e68e2b7
This diff is collapsed.
Click to expand it.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/DemoResultVo.java
0 → 100644
View file @
1e68e2b7
package
com
.
ceb
.
gjjs
.
mda
.
special
.
vo
;
import
com.brilliance.mda.runtime.annotation.RelPath
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
java.util.List
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/11
*/
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DemoResultVo
extends
RespondBaseVo
{
@RelPath
(
"acdgrp_rec_account"
)
private
String
acount
;
private
String
b
;
@RelPath
(
"dataList"
)
private
List
<
DemoListVo
>
data_list
;
@RelPath
(
"acd"
)
private
DemoVo_2
acd_data
;
@RelPath
(
"addrs"
)
private
List
<
String
>
addrLines
;
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/DemoVo.java
View file @
1e68e2b7
...
...
@@ -19,22 +19,19 @@ import java.util.List;
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DemoVo
implements
Serializable
{
public
class
DemoVo
extends
RequestBaseVo
implements
Serializable
{
@JsonIgnore
private
static
final
long
serialVersionUID
=
1L
;
@Length
(
max
=
2
,
message
=
"最大长度为20"
)
@RelPath
(
"acdgrp_rec_account"
)
// 映射到对应交易vo的字段
@RelPath
(
"acdgrp_rec_account"
)
private
String
a
;
@Length
(
max
=
2
,
message
=
"最大长度为2"
)
@Need
private
String
b
;
@RelPath
(
"src"
)
private
String
src
;
@RelPath
(
"dataList"
)
@Need
private
List
<
DemoListVo
>
list
;
...
...
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/RequestBaseVo.java
0 → 100644
View file @
1e68e2b7
package
com
.
ceb
.
gjjs
.
mda
.
special
.
vo
;
import
com.brilliance.mda.runtime.annotation.Need
;
import
com.brilliance.mda.runtime.annotation.RelPath
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
/**
* @Description 请求定制vo的基类
* @Author s_guodong
* @Date 2023/8/10
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
public
class
RequestBaseVo
{
@Length
(
max
=
8
,
message
=
"长度最大8"
)
@Need
private
String
id
;
@Length
(
max
=
10
,
message
=
"长度最大10"
)
@Need
private
String
cifno
;
@Length
(
max
=
8
,
message
=
"长度最大8"
)
@Need
private
String
userid
;
@RelPath
(
"src"
)
@Length
(
max
=
12
,
message
=
"长度最大12"
)
@Need
private
String
src
;
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/RespondBaseVo.java
0 → 100644
View file @
1e68e2b7
package
com
.
ceb
.
gjjs
.
mda
.
special
.
vo
;
/**
* @Description 返回定制vo的基类
* @Author s_guodong
* @Date 2023/8/10
*/
public
class
RespondBaseVo
{
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/util/ReflectUtil.java
View file @
1e68e2b7
...
...
@@ -10,6 +10,7 @@ import java.lang.reflect.Field;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -21,8 +22,8 @@ import java.util.List;
public
class
ReflectUtil
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ReflectUtil
.
class
);
public
static
String
set
ObjValue
(
Object
specialVoValue
,
Class
specialVoClass
,
Object
req
,
Class
req
Class
)
{
Field
[]
declaredFields
=
special
VoClass
.
getDeclaredFields
();
public
static
String
set
Value2RequestVo
(
Object
requestVo
,
Class
requestVoClass
,
Object
baseVo
,
Class
baseVo
Class
)
{
Field
[]
declaredFields
=
request
VoClass
.
getDeclaredFields
();
for
(
Field
f
:
declaredFields
)
{
f
.
setAccessible
(
true
);
...
...
@@ -30,13 +31,13 @@ public class ReflectUtil {
RelPath
annotation
=
f
.
getAnnotation
(
RelPath
.
class
);
String
path
=
annotation
.
value
();
try
{
Object
o
=
f
.
get
(
specialVoValue
);
Field
declaredField
=
req
Class
.
getDeclaredField
(
path
);
Object
o
=
f
.
get
(
requestVo
);
Field
declaredField
=
baseVo
Class
.
getDeclaredField
(
path
);
declaredField
.
setAccessible
(
true
);
Class
<?>
type
=
declaredField
.
getType
();
// 基本数据类型
if
(
isPrimate
(
type
))
{
declaredField
.
set
(
req
,
o
);
declaredField
.
set
(
baseVo
,
o
);
}
// ModuleList类型
else
if
(
"com.brilliance.mda.runtime.mda.impl.ModuleList"
.
equals
(
type
.
getName
()))
{
...
...
@@ -49,36 +50,96 @@ public class ReflectUtil {
ModuleList
moduleList
=
new
ModuleList
();
for
(
Object
data
:
list
)
{
Object
dataObj
=
moduleT
.
newInstance
();
String
s
=
set
ObjValue
(
data
,
listT
,
dataObj
,
moduleT
);
String
s
=
set
Value2RequestVo
(
data
,
listT
,
dataObj
,
moduleT
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
moduleList
.
add
(
dataObj
);
}
declaredField
.
set
(
req
,
moduleList
);
declaredField
.
set
(
baseVo
,
moduleList
);
}
else
if
(
"java.util.List"
.
equals
(
type
.
getName
()))
{
// list数据类型
declaredField
.
set
(
req
,
o
);
declaredField
.
set
(
baseVo
,
o
);
}
else
{
// 对象类型
Object
typeO
=
type
.
newInstance
();
String
s
=
set
ObjValue
(
o
,
f
.
getType
(),
typeO
,
type
);
String
s
=
set
Value2RequestVo
(
o
,
f
.
getType
(),
typeO
,
type
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
declaredField
.
set
(
req
,
typeO
);
declaredField
.
set
(
baseVo
,
typeO
);
}
}
catch
(
Exception
e
)
{
Class
<?>
superclass
=
reqClass
.
getSuperclass
();
try
{
Field
superclassDeclaredField
=
superclass
.
getDeclaredField
(
path
);
superclassDeclaredField
.
setAccessible
(
true
);
superclassDeclaredField
.
set
(
req
,
f
.
get
(
specialVoValue
));
}
catch
(
Exception
ex
)
{
String
errMsg
=
specialVoClass
.
getName
()
+
"中字段"
+
f
.
getName
()
+
"反射错误"
;
log
.
error
(
errMsg
);
return
errMsg
;
// Class<?> superclass = baseVoClass.getSuperclass();
// try {
// Field superclassDeclaredField = superclass.getDeclaredField(path);
// superclassDeclaredField.setAccessible(true);
// superclassDeclaredField.set(baseVo, f.get(requestVo));
// } catch (Exception ex) {
// String errMsg = requestVoClass.getName() + "中字段" + f.getName() + "反射错误";
// log.error(errMsg);
// return errMsg;
// }
String
errMsg
=
requestVoClass
.
getName
()
+
"中字段"
+
f
.
getName
()
+
"反射错误"
;
log
.
error
(
errMsg
,
e
);
return
errMsg
;
}
}
}
return
""
;
}
public
static
String
setValue2RespondVo
(
Object
respondVo
,
Class
respondVoClass
,
Object
baseVo
,
Class
baseVoClass
)
{
Field
[]
declaredFields
=
respondVoClass
.
getDeclaredFields
();
for
(
Field
f
:
declaredFields
)
{
f
.
setAccessible
(
true
);
if
(
f
.
isAnnotationPresent
(
RelPath
.
class
))
{
RelPath
annotation
=
f
.
getAnnotation
(
RelPath
.
class
);
String
path
=
annotation
.
value
();
try
{
Field
declaredField
=
baseVoClass
.
getDeclaredField
(
path
);
declaredField
.
setAccessible
(
true
);
Object
o
=
declaredField
.
get
(
baseVo
);
if
(
o
==
null
)
{
continue
;
}
Class
<?>
type
=
declaredField
.
getType
();
// 基本数据类型
if
(
isPrimate
(
type
))
{
f
.
set
(
respondVo
,
o
);
}
else
if
(
"com.brilliance.mda.runtime.mda.impl.ModuleList"
.
equals
(
type
.
getName
()))
{
// list数据类型
Class
tType
=
ReflectUtil
.
getTType
(
f
);
if
(
ReflectUtil
.
isPrimate
(
tType
))
{
// list的泛型是基本类型
f
.
set
(
respondVo
,
o
);
}
else
{
// 泛型是对象
List
list
=
(
List
)
o
;
List
dataList
=
new
ArrayList
(
list
.
size
());
for
(
Object
data
:
list
)
{
Object
o1
=
tType
.
newInstance
();
setValue2RespondVo
(
o1
,
tType
,
data
,
ReflectUtil
.
getTType
(
declaredField
));
dataList
.
add
(
o1
);
}
f
.
set
(
respondVo
,
dataList
);
}
}
else
if
(
"java.util.List"
.
equals
(
type
.
getName
()))
{
f
.
set
(
respondVo
,
o
);
}
else
{
// 对象类型
Object
typeO
=
f
.
getType
().
newInstance
();
String
s
=
setValue2RespondVo
(
typeO
,
f
.
getType
(),
o
,
type
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
f
.
set
(
respondVo
,
typeO
);
}
}
catch
(
Exception
e
)
{
String
errMsg
=
respondVoClass
.
getName
()
+
"中字段"
+
f
.
getName
()
+
"反射错误"
;
log
.
error
(
errMsg
);
return
errMsg
;
}
}
}
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/request/BaseVO.java
View file @
1e68e2b7
package
com
.
brilliance
.
mda
.
runtime
.
request
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
@Data
public
class
BaseVO
{
protected
String
src
;
protected
String
userid
;
protected
String
id
;
protected
String
cifno
;
protected
String
pageId
;
protected
Map
<
String
,
Object
>
params
;
protected
Map
<
String
,
Object
>
root
;
protected
List
<
Map
<
String
,
Object
>>
changes
;
protected
int
pageNum
;
//第几页,从1开始,比如1,2,3,4,5......
protected
int
pageSize
;
//分页每页大小
public
Map
<
String
,
Object
>
getParams
()
{
return
params
;
}
public
void
setParams
(
Map
<
String
,
Object
>
parmas
)
{
this
.
params
=
parmas
;
}
public
List
<
Map
<
String
,
Object
>>
getChanges
()
{
return
changes
;
}
public
void
setChanges
(
List
<
Map
<
String
,
Object
>>
changes
)
{
this
.
changes
=
changes
;
}
public
String
getPageId
()
{
return
pageId
;
}
public
void
setPageId
(
String
pageId
)
{
this
.
pageId
=
pageId
;
}
public
int
getPageNum
()
{
return
pageNum
;
}
public
void
setPageNum
(
int
pageNum
)
{
this
.
pageNum
=
pageNum
;
}
public
int
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
String
getSrc
()
{
return
src
;
}
/**
* 第几页,从1开始,比如1,2,3,4,5......
*/
protected
int
pageNum
;
public
void
setSrc
(
String
src
)
{
this
.
src
=
src
;
}
/**
* 分页每页大小
*/
protected
int
pageSize
;
public
Map
<
String
,
Object
>
getRoot
()
{
return
root
;
}
public
void
setRoot
(
Map
<
String
,
Object
>
root
)
{
this
.
root
=
root
;
}
}
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