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
dbf34e6e
Commit
dbf34e6e
authored
Aug 10, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
b15e4155
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
274 additions
and
6 deletions
+274
-6
DemoListVo.java
...src/main/java/com/ceb/gjjs/mda/special/vo/DemoListVo.java
+34
-0
DemoVo.java
...ess/src/main/java/com/ceb/gjjs/mda/special/vo/DemoVo.java
+51
-0
DemoVo_2.java
...s/src/main/java/com/ceb/gjjs/mda/special/vo/DemoVo_2.java
+35
-0
ReflectUtil.java
...ness/src/main/java/com/ceb/gjjs/mda/util/ReflectUtil.java
+121
-0
ValidatorUtil.java
...ss/src/main/java/com/ceb/gjjs/mda/util/ValidatorUtil.java
+27
-0
AbstractModule.java
...a/com/brilliance/mda/runtime/mda/impl/AbstractModule.java
+1
-1
BaseVO.java
.../main/java/com/brilliance/mda/runtime/request/BaseVO.java
+5
-5
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/DemoListVo.java
0 → 100644
View file @
dbf34e6e
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.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
import
java.io.Serializable
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/10
*/
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DemoListVo
implements
Serializable
{
@JsonIgnore
private
static
final
long
serialVersionUID
=
1L
;
@Length
(
max
=
20
,
message
=
"最大长度为20"
)
@RelPath
(
"cur"
)
private
String
aa
;
@Need
@RelPath
(
"act"
)
private
String
bb
;
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/DemoVo.java
0 → 100644
View file @
dbf34e6e
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.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/10
*/
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DemoVo
implements
Serializable
{
@JsonIgnore
private
static
final
long
serialVersionUID
=
1L
;
@Length
(
max
=
2
,
message
=
"最大长度为20"
)
@RelPath
(
"acdgrp_rec_account"
)
// 映射到对应交易vo的字段
private
String
a
;
@Length
(
max
=
2
,
message
=
"最大长度为2"
)
@Need
private
String
b
;
@RelPath
(
"src"
)
private
String
src
;
@RelPath
(
"dataList"
)
@Need
private
List
<
DemoListVo
>
list
;
@RelPath
(
"acd"
)
@Need
private
DemoVo_2
demoVo_2
;
@RelPath
(
"addrs"
)
@Need
private
List
<
String
>
addrList
;
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/special/vo/DemoVo_2.java
0 → 100644
View file @
dbf34e6e
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.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
import
java.io.Serializable
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/10
*/
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DemoVo_2
implements
Serializable
{
@JsonIgnore
private
static
final
long
serialVersionUID
=
1L
;
@Length
(
max
=
20
,
message
=
"最大长度为20"
)
@RelPath
(
"entname"
)
private
String
name
;
@Length
(
max
=
2
,
message
=
"最大长度为2"
)
@RelPath
(
"inr"
)
private
String
addr
;
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/util/ReflectUtil.java
0 → 100644
View file @
dbf34e6e
package
com
.
ceb
.
gjjs
.
mda
.
util
;
import
com.brilliance.mda.runtime.annotation.RelPath
;
import
com.brilliance.mda.runtime.mda.impl.ModuleList
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/8
*/
public
class
ReflectUtil
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ReflectUtil
.
class
);
public
static
String
setObjValue
(
Object
specialVoValue
,
Class
specialVoClass
,
Object
req
,
Class
reqClass
)
{
Field
[]
declaredFields
=
specialVoClass
.
getDeclaredFields
();
for
(
Field
f
:
declaredFields
)
{
f
.
setAccessible
(
true
);
if
(
f
.
isAnnotationPresent
(
RelPath
.
class
))
{
RelPath
annotation
=
f
.
getAnnotation
(
RelPath
.
class
);
String
path
=
annotation
.
value
();
try
{
Object
o
=
f
.
get
(
specialVoValue
);
Field
declaredField
=
reqClass
.
getDeclaredField
(
path
);
declaredField
.
setAccessible
(
true
);
Class
<?>
type
=
declaredField
.
getType
();
// 基本数据类型
if
(
isPrimate
(
type
))
{
declaredField
.
set
(
req
,
o
);
}
// ModuleList类型
else
if
(
"com.brilliance.mda.runtime.mda.impl.ModuleList"
.
equals
(
type
.
getName
()))
{
// moduleList中的泛型
Class
moduleT
=
getTType
(
declaredField
);
// list中的泛型
Class
listT
=
getTType
(
f
);
List
list
=
(
List
)
o
;
ModuleList
moduleList
=
new
ModuleList
();
for
(
Object
data
:
list
)
{
Object
dataObj
=
moduleT
.
newInstance
();
String
s
=
setObjValue
(
data
,
listT
,
dataObj
,
moduleT
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
moduleList
.
add
(
dataObj
);
}
declaredField
.
set
(
req
,
moduleList
);
}
else
if
(
"java.util.List"
.
equals
(
type
.
getName
()))
{
// list数据类型
declaredField
.
set
(
req
,
o
);
}
else
{
// 对象类型
Object
typeO
=
type
.
newInstance
();
String
s
=
setObjValue
(
o
,
f
.
getType
(),
typeO
,
type
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
declaredField
.
set
(
req
,
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
;
}
}
}
}
return
""
;
}
/**
* 获取List的泛型
*
* @param f
* @return
*/
public
static
Class
getTType
(
Field
f
)
{
Type
genericType
=
f
.
getGenericType
();
if
(
genericType
instanceof
ParameterizedType
)
{
ParameterizedType
pt
=
(
ParameterizedType
)
genericType
;
//得到泛型里的class类型对象
Class
<?>
genericClazz
=
(
Class
<?>)
pt
.
getActualTypeArguments
()[
0
];
return
genericClazz
;
}
return
null
;
}
/**
* 是否是基本类型
*
* @param aclass
* @return
*/
public
static
boolean
isPrimate
(
Class
aclass
)
{
return
aclass
.
isAssignableFrom
(
String
.
class
)
||
aclass
.
isAssignableFrom
(
BigDecimal
.
class
)
||
aclass
.
isAssignableFrom
(
Date
.
class
)
||
aclass
.
isPrimitive
();
}
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/util/ValidatorUtil.java
View file @
dbf34e6e
...
...
@@ -7,6 +7,7 @@ import org.hibernate.validator.constraints.Length;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.lang.reflect.Field
;
import
java.util.List
;
/**
* @Description
...
...
@@ -14,6 +15,7 @@ import java.lang.reflect.Field;
* @Date 2023/8/8
*/
public
class
ValidatorUtil
{
public
static
String
check
(
Object
obj
)
{
Class
<?>
aClass
=
obj
.
getClass
();
Field
[]
fields
=
aClass
.
getDeclaredFields
();
...
...
@@ -54,8 +56,33 @@ public class ValidatorUtil {
if
(
type
.
isAssignableFrom
(
String
.
class
)
&&
StringUtils
.
isBlank
((
String
)
o
))
{
return
"参数校验错误["
+
f
.
getName
()
+
":为必需参数,不能为空]"
;
}
if
(
ReflectUtil
.
isPrimate
(
type
))
{
}
else
if
(
"java.util.List"
.
equals
(
type
.
getName
()))
{
List
list
=
(
List
)
o
;
if
(
list
.
size
()
==
0
)
{
return
"参数校验错误["
+
f
.
getName
()
+
":元素个数不能为0]"
;
}
// 获取list的泛型
Class
tType
=
ReflectUtil
.
getTType
(
f
);
if
(!
ReflectUtil
.
isPrimate
(
tType
))
{
for
(
Object
data
:
list
)
{
String
s
=
check
(
data
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
}
}
}
else
{
String
s
=
check
(
o
);
if
(!
StringUtils
.
isBlank
(
s
))
{
return
s
;
}
}
}
}
return
""
;
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/impl/AbstractModule.java
View file @
dbf34e6e
...
...
@@ -17,7 +17,7 @@ import java.lang.reflect.Field;
import
java.lang.reflect.Method
;
import
java.util.*
;
@JsonFilter
(
"fieldFilter"
)
//
@JsonFilter("fieldFilter")
@Module
public
abstract
class
AbstractModule
implements
IModule
,
IModuleRoot
{
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/request/BaseVO.java
View file @
dbf34e6e
...
...
@@ -7,7 +7,7 @@ public class BaseVO {
protected
String
src
;
protected
String
pageId
;
protected
Map
<
String
,
Object
>
params
;
protected
Map
<
String
,
Object
>
special_vo
;
protected
Map
<
String
,
Object
>
root
;
protected
List
<
Map
<
String
,
Object
>>
changes
;
...
...
@@ -64,11 +64,11 @@ public class BaseVO {
this
.
src
=
src
;
}
public
Map
<
String
,
Object
>
get
Special_vo
()
{
return
special_vo
;
public
Map
<
String
,
Object
>
get
Root
()
{
return
root
;
}
public
void
set
Special_vo
(
Map
<
String
,
Object
>
special_vo
)
{
this
.
special_vo
=
special_vo
;
public
void
set
Root
(
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