Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
d4057d96
Commit
d4057d96
authored
Apr 03, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存结果集
parent
ae1c828d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
37 deletions
+68
-37
MqAspect.java
...oud/src/main/java/com/yanzuoguang/cloud/aop/MqAspect.java
+2
-2
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+4
-2
BaseDao.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
+2
-2
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/Impl/BaseDaoImpl.java
+21
-20
AllBeanRowMapper.java
...c/main/java/com/yanzuoguang/db/Impl/AllBeanRowMapper.java
+32
-3
BaseService.java
...db/src/main/java/com/yanzuoguang/service/BaseService.java
+1
-1
BaseServiceImpl.java
...in/java/com/yanzuoguang/service/Impl/BaseServiceImpl.java
+6
-7
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/MqAspect.java
View file @
d4057d96
...
@@ -30,7 +30,7 @@ public class MqAspect extends BaseRequestAspect {
...
@@ -30,7 +30,7 @@ public class MqAspect extends BaseRequestAspect {
* exec aop point aspect
* exec aop point aspect
*/
*/
@Pointcut
(
"execution(* *..mq..*Consumer.*(..))"
)
@Pointcut
(
"execution(* *..mq..*Consumer.*(..))"
)
public
void
web
Aspect
()
{
public
void
mq
Aspect
()
{
}
}
/**
/**
...
@@ -39,7 +39,7 @@ public class MqAspect extends BaseRequestAspect {
...
@@ -39,7 +39,7 @@ public class MqAspect extends BaseRequestAspect {
* @param joinPoint
* @param joinPoint
* @return
* @return
*/
*/
@Around
(
value
=
"
web
Aspect()"
)
@Around
(
value
=
"
mq
Aspect()"
)
public
Object
requestWebAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
public
Object
requestWebAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Log
.
threadBegin
();
Log
.
threadBegin
();
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
d4057d96
package
com
.
yanzuoguang
.
cloud
.
aop
;
package
com
.
yanzuoguang
.
cloud
.
aop
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
com.yanzuoguang.util.helper.JSONHelper
;
import
com.yanzuoguang.util.helper.JSONHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.vo.LogVo
;
import
com.yanzuoguang.util.vo.LogVo
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
...
@@ -149,7 +149,9 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -149,7 +149,9 @@ public class WebAspect extends BaseRequestAspect {
return
;
return
;
}
}
// 正常请求不记录
// 正常请求不记录
if
(!
logAll
&&
responseResult
.
getCode
()
==
ResultConstants
.
SUCCESS
)
{
if
(!
logAll
&&
responseResult
!=
null
&&
responseResult
.
getCode
()
==
ResultConstants
.
SUCCESS
)
{
return
;
return
;
}
}
LogVo
logVo
=
initLogInterVo
(
HttpAspectUtil
.
getHttpRequestUrl
(),
joinPoint
,
responseResult
);
LogVo
logVo
=
initLogInterVo
(
HttpAspectUtil
.
getHttpRequestUrl
(),
joinPoint
,
responseResult
);
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
View file @
d4057d96
...
@@ -36,9 +36,9 @@ public interface BaseDao {
...
@@ -36,9 +36,9 @@ public interface BaseDao {
* 删除数据
* 删除数据
*
*
* @param model 需要删除的数据
* @param model 需要删除的数据
* @return 删除的
主键编号
* @return 删除的
记录数量
*/
*/
String
remove
(
Object
model
);
int
remove
(
Object
model
);
/**
/**
* 加载数据
* 加载数据
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/Impl/BaseDaoImpl.java
View file @
d4057d96
...
@@ -2,13 +2,15 @@ package com.yanzuoguang.dao.Impl;
...
@@ -2,13 +2,15 @@ package com.yanzuoguang.dao.Impl;
import
com.yanzuoguang.dao.BaseDao
;
import
com.yanzuoguang.dao.BaseDao
;
import
com.yanzuoguang.dao.DaoConst
;
import
com.yanzuoguang.dao.DaoConst
;
import
com.yanzuoguang.db.Impl.AllBeanRowMapper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.vo.InitDao
;
import
com.yanzuoguang.util.vo.InitDao
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.MapRow
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -180,33 +182,32 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
...
@@ -180,33 +182,32 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
* @param model 需要删除的数据
* @param model 需要删除的数据
* @return 删除的主键编号
* @return 删除的主键编号
*/
*/
public
String
remove
(
Object
model
)
{
public
int
remove
(
Object
model
)
{
Object
from
=
model
;
// 获取来源主键
// 获取来源主键
Object
from
=
model
;
String
keyString
=
getInputKey
(
from
);
String
keyString
=
getInputKey
(
from
);
// 当主键存在值时,直接通过主键删除
if
(
StringHelper
.
isEmpty
(
keyString
))
{
MapRow
to
=
new
MapRow
();
ObjectHelper
.
writeWithFrom
(
to
,
model
);
from
=
this
.
queryFirst
(
MapRow
.
class
,
DaoConst
.
Load
,
from
);
if
(
from
==
null
)
{
return
""
;
}
keyString
=
this
.
getKeyString
(
from
);
}
// 当主键存在时,只通过主键加载
if
(!
StringHelper
.
isEmpty
(
keyString
))
{
if
(!
StringHelper
.
isEmpty
(
keyString
))
{
// 去掉其他非主键的属性
from
=
new
HashMap
<
String
,
Object
>();
from
=
new
HashMap
<
String
,
Object
>();
this
.
setKeyString
(
from
,
keyString
);
this
.
setKeyString
(
from
,
keyString
);
}
// 调用删除日志
this
.
check
(
DaoConst
.
OperatorTypeRemove
,
keyString
,
from
);
this
.
check
(
DaoConst
.
OperatorTypeRemove
,
keyString
,
from
);
}
else
{
List
<
MapRow
>
rows
=
this
.
query
(
MapRow
.
class
,
DaoConst
.
Load
,
from
);
for
(
MapRow
row
:
rows
)
{
keyString
=
this
.
getKeyString
(
from
);
if
(
StringHelper
.
isEmpty
(
keyString
))
{
keyString
=
StringHelper
.
toString
(
AllBeanRowMapper
.
getLoweRowField
(
row
,
this
.
getKey
()));
}
// 调用删除日志
this
.
check
(
DaoConst
.
OperatorTypeRemove
,
keyString
,
row
);
}
}
// 调用删除语句
SqlData
sqlData
=
this
.
getSql
(
DaoConst
.
Remove
);
SqlData
sqlData
=
this
.
getSql
(
DaoConst
.
Remove
);
int
ret
=
updateSql
(
sqlData
,
from
);
return
updateSql
(
sqlData
,
from
);
String
retVal
=
ret
>
0
?
keyString
:
""
;
return
retVal
;
}
}
/**
/**
...
...
yzg-util-db/src/main/java/com/yanzuoguang/db/Impl/AllBeanRowMapper.java
View file @
d4057d96
package
com
.
yanzuoguang
.
db
.
Impl
;
package
com
.
yanzuoguang
.
db
.
Impl
;
import
com.yanzuoguang.extend.ConfigDb
;
import
com.yanzuoguang.extend.ConfigDb
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.MapRow
;
import
org.springframework.beans.*
;
import
org.springframework.beans.*
;
import
org.springframework.dao.DataRetrievalFailureException
;
import
org.springframework.dao.DataRetrievalFailureException
;
...
@@ -110,14 +110,43 @@ public class AllBeanRowMapper<T> implements RowMapper<T> {
...
@@ -110,14 +110,43 @@ public class AllBeanRowMapper<T> implements RowMapper<T> {
* @param name the string containing original name
* @param name the string containing original name
* @return the converted name
* @return the converted name
*/
*/
p
rivate
String
underscoreName
(
String
name
)
{
p
ublic
static
String
underscoreName
(
String
name
)
{
if
(!
StringUtils
.
hasLength
(
name
))
{
if
(!
StringUtils
.
hasLength
(
name
))
{
return
""
;
return
""
;
}
}
return
name
.
toLowerCase
().
replace
(
"_"
,
""
);
return
name
.
toLowerCase
().
replace
(
"_"
,
""
);
}
}
/**
* 将行进行转换
*
* @param from
* @return
*/
public
static
MapRow
toLoweRow
(
MapRow
from
)
{
MapRow
to
=
new
MapRow
();
for
(
String
key
:
from
.
keySet
())
{
to
.
put
(
underscoreName
(
key
),
from
.
get
(
key
));
}
return
to
;
}
/**
* 获取空值字段
*
* @param from
* @return
*/
public
static
Object
getLoweRowField
(
MapRow
from
,
String
field
)
{
field
=
underscoreName
(
field
);
for
(
String
key
:
from
.
keySet
())
{
if
(
underscoreName
(
key
).
equals
(
field
))
{
return
from
.
get
(
key
);
}
}
return
null
;
}
/**
/**
* Extract the values for all columns in the current row.
* Extract the values for all columns in the current row.
* <p>Utilizes public setters and result setByType metadata.
* <p>Utilizes public setters and result setByType metadata.
...
...
yzg-util-db/src/main/java/com/yanzuoguang/service/BaseService.java
View file @
d4057d96
...
@@ -33,7 +33,7 @@ public interface BaseService<T> {
...
@@ -33,7 +33,7 @@ public interface BaseService<T> {
*
*
* @param models 需要删除的数据
* @param models 需要删除的数据
*/
*/
List
<
String
>
remove
(
T
...
models
);
int
remove
(
T
...
models
);
/**
/**
* 加载数据
* 加载数据
...
...
yzg-util-db/src/main/java/com/yanzuoguang/service/Impl/BaseServiceImpl.java
View file @
d4057d96
...
@@ -124,13 +124,12 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
...
@@ -124,13 +124,12 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
*
*
* @param models 需要删除的数据
* @param models 需要删除的数据
*/
*/
public
List
<
String
>
remove
(
T
...
models
)
{
public
int
remove
(
T
...
models
)
{
List
<
String
>
ids
=
new
ArrayList
<
String
>()
;
int
ret
=
0
;
for
(
T
item
:
models
)
{
for
(
T
item
:
models
)
{
String
id
=
removeItem
(
item
);
ret
+=
removeItem
(
item
);
ids
.
add
(
id
);
}
}
return
ids
;
return
ret
;
}
}
/**
/**
...
@@ -139,8 +138,8 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
...
@@ -139,8 +138,8 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
* @param item
* @param item
* @return
* @return
*/
*/
protected
String
removeItem
(
T
item
)
{
protected
int
removeItem
(
T
item
)
{
String
id
=
this
.
getDao
().
remove
(
item
);
int
id
=
this
.
getDao
().
remove
(
item
);
check
(
"删除"
,
this
.
tag
,
id
);
check
(
"删除"
,
this
.
tag
,
id
);
return
id
;
return
id
;
}
}
...
...
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