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
05b5cf8d
Commit
05b5cf8d
authored
Jan 02, 2024
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f411eff0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
19 deletions
+14
-19
MyDateDeSerialized.java
...main/java/com/ceb/gjjs/mda/config/MyDateDeSerialized.java
+4
-4
ValidatorUtil.java
...ss/src/main/java/com/ceb/gjjs/mda/util/ValidatorUtil.java
+1
-10
RelPath.java
...n/java/com/brilliance/mda/runtime/annotation/RelPath.java
+9
-5
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/MyDateDeSerialized.java
View file @
05b5cf8d
package
com
.
ceb
.
gjjs
.
mda
.
config
;
import
com.brilliance.eibs.util.StringUtil
;
import
com.brilliance.mda.runtime.annotation.RelPath
;
import
com.ceb.gjjs.mda.util.ValidatorUtil
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.fasterxml.jackson.databind.DeserializationContext
;
import
com.fasterxml.jackson.databind.JsonDeserializer
;
import
javax.validation.constraints.Pattern
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.text.ParseException
;
...
...
@@ -31,17 +31,17 @@ public class MyDateDeSerialized extends JsonDeserializer {
}
declaredField
.
setAccessible
(
true
);
if
(
StringUtil
.
isNotEmpty
(
source
))
{
Pattern
patternAnnotation
=
declaredField
.
getAnnotation
(
Pattern
.
class
);
String
msg
=
declaredField
.
getAnnotation
(
RelPath
.
class
).
message
(
);
String
format
=
declaredField
.
getAnnotation
(
JsonFormat
.
class
).
pattern
();
if
(
format
.
length
()
!=
source
.
length
())
{
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
patternAnnotation
==
null
?
"时间格式不正确"
:
patternAnnotation
.
message
()
);
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
StringUtil
.
isEmpty
(
msg
)
?
"时间格式不正确"
:
msg
);
return
null
;
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
format
);
try
{
date
=
simpleDateFormat
.
parse
(
source
);
}
catch
(
ParseException
e
)
{
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
patternAnnotation
==
null
?
"时间格式不正确"
:
patternAnnotation
.
message
()
);
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
StringUtil
.
isEmpty
(
msg
)
?
"时间格式不正确"
:
msg
);
return
null
;
}
}
...
...
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/util/ValidatorUtil.java
View file @
05b5cf8d
...
...
@@ -3,9 +3,7 @@ package com.ceb.gjjs.mda.util;
import
com.brilliance.eibs.util.StringUtil
;
import
com.brilliance.mda.runtime.annotation.ListValue
;
import
com.brilliance.mda.runtime.annotation.Need
;
import
com.brilliance.mda.runtime.mda.util.DateUtils
;
import
com.brilliance.mda.support.jakson.serialize.DecimalLength
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.apache.commons.lang3.StringUtils
;
import
org.hibernate.validator.constraints.Length
;
...
...
@@ -171,14 +169,7 @@ public class ValidatorUtil {
return
"参数校验错误["
+
annotation
.
message
()
+
"]"
;
}
}
if
(
f
.
isAnnotationPresent
(
JsonFormat
.
class
)
&&
o
!=
null
)
{
Date
date
=
(
Date
)
o
;
JsonFormat
annotation
=
f
.
getAnnotation
(
JsonFormat
.
class
);
String
format
=
DateUtils
.
format
(
date
,
annotation
.
pattern
());
if
(
annotation
.
pattern
().
length
()
!=
format
.
length
())
{
return
"参数校验错误[时间格式不正确]"
;
}
}
}
else
if
(
type
.
getName
().
contains
(
"com"
))
{
// 对象类型
String
check
=
check
(
o
);
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/annotation/RelPath.java
View file @
05b5cf8d
...
...
@@ -12,14 +12,18 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 视图映射注解
*
* @author fukai
*
*/
@Documented
@Retention
(
RUNTIME
)
@Target
({
TYPE
,
FIELD
})
@Target
({
TYPE
,
FIELD
})
public
@interface
RelPath
{
String
value
();
//路径
DirType
dir
()
default
DirType
.
BOTH
;
//输入输出方向
boolean
recursion
()
default
false
;
//是否递归关联
String
value
();
//路径
DirType
dir
()
default
DirType
.
BOTH
;
//输入输出方向
boolean
recursion
()
default
false
;
//是否递归关联
String
message
()
default
""
;
}
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