Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
f684fb7e
Commit
f684fb7e
authored
May 09, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化日志记录的详情显示
parent
2690c232
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
118 additions
and
3 deletions
+118
-3
src/main/java/com/stylefeng/guns/common/constant/dictmap/DeptDict.java
+5
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/DictMap.java
+6
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/LogDict.java
+5
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/MenuDict.java
+5
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/RoleDict.java
+5
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/UserDict.java
+7
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/base/AbstractDictMap.java
+25
-1
src/main/java/com/stylefeng/guns/common/constant/dictmap/base/SystemDict.java
+5
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/factory/DictFieldWarpperFactory.java
+28
-0
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
+1
-0
src/main/java/com/stylefeng/guns/core/util/Contrast.java
+26
-2
No files found.
src/main/java/com/stylefeng/guns/common/constant/dictmap/DeptDict.java
View file @
f684fb7e
...
@@ -19,4 +19,9 @@ public class DeptDict extends AbstractDictMap {
...
@@ -19,4 +19,9 @@ public class DeptDict extends AbstractDictMap {
put
(
"fullname"
,
"部门全称"
);
put
(
"fullname"
,
"部门全称"
);
put
(
"tips"
,
"备注"
);
put
(
"tips"
,
"备注"
);
}
}
@Override
protected
void
initBeWrapped
()
{
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/DictMap.java
View file @
f684fb7e
...
@@ -9,9 +9,15 @@ import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
...
@@ -9,9 +9,15 @@ import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
* @date 2017-05-06 15:43
* @date 2017-05-06 15:43
*/
*/
public
class
DictMap
extends
AbstractDictMap
{
public
class
DictMap
extends
AbstractDictMap
{
@Override
@Override
public
void
init
()
{
public
void
init
()
{
put
(
"dictId"
,
"字典id"
);
put
(
"dictId"
,
"字典id"
);
put
(
"dictName"
,
"字典名称"
);
put
(
"dictName"
,
"字典名称"
);
}
}
@Override
protected
void
initBeWrapped
()
{
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/LogDict.java
View file @
f684fb7e
...
@@ -14,4 +14,9 @@ public class LogDict extends AbstractDictMap {
...
@@ -14,4 +14,9 @@ public class LogDict extends AbstractDictMap {
public
void
init
()
{
public
void
init
()
{
put
(
"tips"
,
"备注"
);
put
(
"tips"
,
"备注"
);
}
}
@Override
protected
void
initBeWrapped
()
{
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/MenuDict.java
View file @
f684fb7e
...
@@ -26,4 +26,9 @@ public class MenuDict extends AbstractDictMap {
...
@@ -26,4 +26,9 @@ public class MenuDict extends AbstractDictMap {
put
(
"isopen"
,
"是否打开"
);
put
(
"isopen"
,
"是否打开"
);
put
(
""
,
""
);
put
(
""
,
""
);
}
}
@Override
protected
void
initBeWrapped
()
{
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/RoleDict.java
View file @
f684fb7e
...
@@ -20,4 +20,9 @@ public class RoleDict extends AbstractDictMap {
...
@@ -20,4 +20,9 @@ public class RoleDict extends AbstractDictMap {
put
(
"deptid"
,
"部门id"
);
put
(
"deptid"
,
"部门id"
);
put
(
"tips"
,
"备注"
);
put
(
"tips"
,
"备注"
);
}
}
@Override
protected
void
initBeWrapped
()
{
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/UserDict.java
View file @
f684fb7e
...
@@ -23,4 +23,11 @@ public class UserDict extends AbstractDictMap {
...
@@ -23,4 +23,11 @@ public class UserDict extends AbstractDictMap {
put
(
"roleid"
,
"角色id"
);
put
(
"roleid"
,
"角色id"
);
put
(
"deptid"
,
"部门id"
);
put
(
"deptid"
,
"部门id"
);
}
}
@Override
protected
void
initBeWrapped
()
{
putFieldWrapperMethodName
(
"sex"
,
"getSexName"
);
putFieldWrapperMethodName
(
"deptid"
,
"getDeptName"
);
putFieldWrapperMethodName
(
"roleid"
,
"getSingleRoleName"
);
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/base/AbstractDictMap.java
View file @
f684fb7e
...
@@ -11,12 +11,30 @@ import java.util.HashMap;
...
@@ -11,12 +11,30 @@ import java.util.HashMap;
public
abstract
class
AbstractDictMap
{
public
abstract
class
AbstractDictMap
{
protected
HashMap
<
String
,
String
>
dictory
=
new
HashMap
<>();
protected
HashMap
<
String
,
String
>
dictory
=
new
HashMap
<>();
protected
HashMap
<
String
,
String
>
fieldWarpperDictory
=
new
HashMap
<>();
public
AbstractDictMap
(){
public
AbstractDictMap
(){
put
(
"id"
,
"主键id"
);
put
(
"id"
,
"主键id"
);
init
();
init
();
initBeWrapped
();
}
}
/**
* 初始化字段英文名称和中文名称对应的字典
*
* @author stylefeng
* @Date 2017/5/9 19:39
*/
public
abstract
void
init
();
/**
* 初始化需要被包装的字段(例如:性别为1:男,2:女,需要被包装为汉字)
*
* @author stylefeng
* @Date 2017/5/9 19:35
*/
protected
abstract
void
initBeWrapped
();
public
String
get
(
String
key
)
{
public
String
get
(
String
key
)
{
return
this
.
dictory
.
get
(
key
);
return
this
.
dictory
.
get
(
key
);
}
}
...
@@ -25,5 +43,11 @@ public abstract class AbstractDictMap {
...
@@ -25,5 +43,11 @@ public abstract class AbstractDictMap {
this
.
dictory
.
put
(
key
,
value
);
this
.
dictory
.
put
(
key
,
value
);
}
}
public
abstract
void
init
();
public
String
getFieldWarpperMethodName
(
String
key
){
return
this
.
fieldWarpperDictory
.
get
(
key
);
}
public
void
putFieldWrapperMethodName
(
String
key
,
String
methodName
){
this
.
fieldWarpperDictory
.
put
(
key
,
methodName
);
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/base/SystemDict.java
View file @
f684fb7e
...
@@ -12,4 +12,9 @@ public class SystemDict extends AbstractDictMap {
...
@@ -12,4 +12,9 @@ public class SystemDict extends AbstractDictMap {
public
void
init
()
{
public
void
init
()
{
}
}
@Override
protected
void
initBeWrapped
()
{
}
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/factory/DictFieldWarpperFactory.java
0 → 100644
View file @
f684fb7e
package
com
.
stylefeng
.
guns
.
common
.
constant
.
dictmap
.
factory
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
java.lang.reflect.Method
;
/**
* 字段的包装创建工厂
*
* @author fengshuonan
* @date 2017-05-06 15:12
*/
public
class
DictFieldWarpperFactory
{
public
static
Object
createFieldWarpper
(
Object
field
,
String
methodName
)
{
ConstantFactory
me
=
ConstantFactory
.
me
();
try
{
Method
method
=
ConstantFactory
.
class
.
getMethod
(
methodName
,
field
.
getClass
());
Object
result
=
method
.
invoke
(
me
,
field
);
return
result
;
}
catch
(
Exception
e
)
{
throw
new
BussinessException
(
BizExceptionEnum
.
ERROR_WRAPPER_FIELD
);
}
}
}
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
View file @
f684fb7e
...
@@ -12,6 +12,7 @@ public enum BizExceptionEnum {
...
@@ -12,6 +12,7 @@ public enum BizExceptionEnum {
*/
*/
DICT_EXISTED
(
400
,
"字典已经存在"
),
DICT_EXISTED
(
400
,
"字典已经存在"
),
ERROR_CREATE_DICT
(
500
,
"创建字典失败"
),
ERROR_CREATE_DICT
(
500
,
"创建字典失败"
),
ERROR_WRAPPER_FIELD
(
500
,
"包装字典属性失败"
),
/**
/**
...
...
src/main/java/com/stylefeng/guns/core/util/Contrast.java
View file @
f684fb7e
package
com
.
stylefeng
.
guns
.
core
.
util
;
package
com
.
stylefeng
.
guns
.
core
.
util
;
import
com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap
;
import
com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap
;
import
com.stylefeng.guns.common.constant.dictmap.factory.DictFieldWarpperFactory
;
import
com.stylefeng.guns.common.constant.dictmap.factory.DictMapFactory
;
import
com.stylefeng.guns.common.constant.dictmap.factory.DictMapFactory
;
import
com.stylefeng.guns.core.support.StrKit
;
import
com.stylefeng.guns.core.support.StrKit
;
...
@@ -21,6 +22,12 @@ public class Contrast {
...
@@ -21,6 +22,12 @@ public class Contrast {
//记录每个修改字段的分隔符
//记录每个修改字段的分隔符
public
static
final
String
separator
=
";;;"
;
public
static
final
String
separator
=
";;;"
;
/**
* 比较两个对象,并返回不一致的信息
*
* @author stylefeng
* @Date 2017/5/9 19:34
*/
public
static
String
contrastObj
(
Object
pojo1
,
Object
pojo2
)
{
public
static
String
contrastObj
(
Object
pojo1
,
Object
pojo2
)
{
String
str
=
""
;
String
str
=
""
;
try
{
try
{
...
@@ -38,7 +45,7 @@ public class Contrast {
...
@@ -38,7 +45,7 @@ public class Contrast {
if
(
o1
==
null
||
o2
==
null
)
{
if
(
o1
==
null
||
o2
==
null
)
{
continue
;
continue
;
}
}
if
(
o1
instanceof
Date
)
{
if
(
o1
instanceof
Date
)
{
o1
=
DateUtil
.
getDay
((
Date
)
o1
);
o1
=
DateUtil
.
getDay
((
Date
)
o1
);
}
}
if
(!
o1
.
toString
().
equals
(
o2
.
toString
()))
{
if
(!
o1
.
toString
().
equals
(
o2
.
toString
()))
{
...
@@ -55,6 +62,12 @@ public class Contrast {
...
@@ -55,6 +62,12 @@ public class Contrast {
return
str
;
return
str
;
}
}
/**
* 比较两个对象pojo1和pojo2,并输出不一致信息
*
* @author stylefeng
* @Date 2017/5/9 19:34
*/
public
static
String
contrastObj
(
String
dictClass
,
String
key
,
Object
pojo1
,
Map
<
String
,
String
>
pojo2
)
{
public
static
String
contrastObj
(
String
dictClass
,
String
key
,
Object
pojo1
,
Map
<
String
,
String
>
pojo2
)
{
AbstractDictMap
dictMap
=
DictMapFactory
.
createDictMap
(
dictClass
);
AbstractDictMap
dictMap
=
DictMapFactory
.
createDictMap
(
dictClass
);
String
value
=
pojo2
.
get
(
key
);
String
value
=
pojo2
.
get
(
key
);
...
@@ -74,15 +87,24 @@ public class Contrast {
...
@@ -74,15 +87,24 @@ public class Contrast {
if
(
o1
==
null
||
o2
==
null
)
{
if
(
o1
==
null
||
o2
==
null
)
{
continue
;
continue
;
}
}
if
(
o1
instanceof
Date
)
{
if
(
o1
instanceof
Date
)
{
o1
=
DateUtil
.
getDay
((
Date
)
o1
);
o1
=
DateUtil
.
getDay
((
Date
)
o1
);
}
else
if
(
o1
instanceof
Integer
)
{
o2
=
Integer
.
parseInt
(
o2
.
toString
());
}
}
if
(!
o1
.
toString
().
equals
(
o2
.
toString
()))
{
if
(!
o1
.
toString
().
equals
(
o2
.
toString
()))
{
if
(
i
!=
1
)
{
if
(
i
!=
1
)
{
str
+=
separator
;
str
+=
separator
;
}
}
String
fieldName
=
dictMap
.
get
(
field
.
getName
());
String
fieldName
=
dictMap
.
get
(
field
.
getName
());
String
fieldWarpperMethodName
=
dictMap
.
getFieldWarpperMethodName
(
field
.
getName
());
if
(
fieldWarpperMethodName
!=
null
)
{
Object
o1Warpper
=
DictFieldWarpperFactory
.
createFieldWarpper
(
o1
,
fieldWarpperMethodName
);
Object
o2Warpper
=
DictFieldWarpperFactory
.
createFieldWarpper
(
o2
,
fieldWarpperMethodName
);
str
+=
"字段名称:"
+
fieldName
+
",旧值:"
+
o1Warpper
+
",新值:"
+
o2Warpper
;
}
else
{
str
+=
"字段名称:"
+
fieldName
+
",旧值:"
+
o1
+
",新值:"
+
o2
;
str
+=
"字段名称:"
+
fieldName
+
",旧值:"
+
o1
+
",新值:"
+
o2
;
}
i
++;
i
++;
}
}
}
}
...
@@ -91,4 +113,5 @@ public class Contrast {
...
@@ -91,4 +113,5 @@ public class Contrast {
}
}
return
str
;
return
str
;
}
}
}
}
\ No newline at end of file
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