Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cloud
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
data-hook
gic-cloud
Commits
9fbf18a8
Commit
9fbf18a8
authored
Oct 27, 2021
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
取数平台调整
parent
d0adfc0b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
434 additions
and
12 deletions
+434
-12
DhDecryptKey.java
...in/java/com/gic/cloud/data/hook/api/dto/DhDecryptKey.java
+100
-0
DecryptKeyService.java
...om/gic/cloud/data/hook/api/service/DecryptKeyService.java
+9
-0
DhDecryptKeyMapper.java
...m/gic/cloud/data/hook/service/dao/DhDecryptKeyMapper.java
+58
-0
CsvResultSetHelper.java
...ic/cloud/data/hook/service/entity/CsvResultSetHelper.java
+69
-2
DecryptKeyServiceImpl.java
...c/cloud/data/hook/service/impl/DecryptKeyServiceImpl.java
+35
-0
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+34
-10
FreeQueryServiceImpl.java
...ic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
+4
-0
DhDecryptKeyMapper.xml
...-service/src/main/resources/mapper/DhDecryptKeyMapper.xml
+125
-0
No files found.
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/dto/DhDecryptKey.java
0 → 100644
View file @
9fbf18a8
package
com
.
gic
.
cloud
.
data
.
hook
.
api
.
dto
;
import
java.util.Date
;
/**
* dh_decrypt_key
*/
public
class
DhDecryptKey
{
/**
*
*/
private
Integer
id
;
/**
*
*/
private
String
enterpriseId
;
/**
*
*/
private
String
publicKey
;
/**
*
*/
private
String
privateKey
;
/**
*
*/
private
Date
createTime
;
/**
*
*/
private
Date
expireTime
;
/**
*
*/
private
Date
updateTime
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getEnterpriseId
()
{
return
enterpriseId
;
}
public
void
setEnterpriseId
(
String
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
}
public
String
getPublicKey
()
{
return
publicKey
;
}
public
void
setPublicKey
(
String
publicKey
)
{
this
.
publicKey
=
publicKey
;
}
public
String
getPrivateKey
()
{
return
privateKey
;
}
public
void
setPrivateKey
(
String
privateKey
)
{
this
.
privateKey
=
privateKey
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getExpireTime
()
{
return
expireTime
;
}
public
void
setExpireTime
(
Date
expireTime
)
{
this
.
expireTime
=
expireTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
\ No newline at end of file
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/service/DecryptKeyService.java
0 → 100644
View file @
9fbf18a8
package
com
.
gic
.
cloud
.
data
.
hook
.
api
.
service
;
import
com.gic.cloud.data.hook.api.dto.DhDecryptKey
;
public
interface
DecryptKeyService
{
void
saveDecryKey
(
String
enterpriseId
,
String
publicKey
,
String
privateKey
);
DhDecryptKey
getKeyByEnterpriseId
(
String
enterpriseId
);
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/dao/DhDecryptKeyMapper.java
0 → 100644
View file @
9fbf18a8
package
com
.
gic
.
cloud
.
data
.
hook
.
service
.
dao
;
import
com.gic.cloud.data.hook.api.dto.DhDecryptKey
;
import
org.apache.ibatis.annotations.Param
;
public
interface
DhDecryptKeyMapper
{
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int
deleteByPrimaryKey
(
Integer
id
);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insert
(
DhDecryptKey
record
);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insertSelective
(
DhDecryptKey
record
);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
DhDecryptKey
selectByPrimaryKey
(
Integer
id
);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKeySelective
(
DhDecryptKey
record
);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKey
(
DhDecryptKey
record
);
DhDecryptKey
selectByEnterpriseId
(
@Param
(
"enterpriseId"
)
String
enterpriseId
);
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/entity/CsvResultSetHelper.java
View file @
9fbf18a8
package
com
.
gic
.
cloud
.
data
.
hook
.
service
.
entity
;
import
cn.hutool.crypto.asymmetric.KeyType
;
import
cn.hutool.crypto.asymmetric.RSA
;
import
com.alibaba.dubbo.common.utils.StringUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.gic.cloud.data.hook.api.dto.DhDecryptKey
;
import
com.gic.cloud.data.hook.api.entity.FlatQueryCondition
;
import
com.gic.cloud.data.hook.api.service.DecryptKeyService
;
import
com.gic.cloud.data.hook.service.DecryptUtils
;
import
com.gic.cloud.data.hook.service.impl.FreeQueryServiceImpl
;
import
com.opencsv.ResultSetHelper
;
...
...
@@ -13,6 +19,8 @@ import java.sql.ResultSetMetaData;
import
java.sql.SQLException
;
import
java.sql.Types
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -25,11 +33,37 @@ public class CsvResultSetHelper implements ResultSetHelper {
private
List
<
String
>
filters
=
null
;
private
List
<
FlatQueryCondition
>
allFields
=
null
;
public
CsvResultSetHelper
(
String
filterMode
,
List
<
String
>
filters
,
List
<
FlatQueryCondition
>
allFields
)
{
private
String
enterpriseId
;
private
List
<
String
>
decryptEnterpriseIdList
=
new
ArrayList
<>();
private
boolean
needDecryptByEnt
=
false
;
private
DecryptKeyService
decryptKeyService
;
private
String
publicKey
;
private
RSA
rsa
;
public
CsvResultSetHelper
(
String
filterMode
,
List
<
String
>
filters
,
List
<
FlatQueryCondition
>
allFields
,
String
enterpriseId
,
DecryptKeyService
decryptKeyService
)
{
this
.
filterMode
=
filterMode
;
this
.
filters
=
filters
;
this
.
allFields
=
allFields
;
this
.
enterpriseId
=
enterpriseId
;
this
.
decryptKeyService
=
decryptKeyService
;
Config
config
=
ConfigService
.
getConfig
(
"application"
);
String
decryptEnterpriseIds
=
config
.
getProperty
(
"decryptEnterpriseIds"
,
""
);
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isNotBlank
(
decryptEnterpriseIds
)
&&
allFields
!=
null
){
decryptEnterpriseIdList
=
Arrays
.
asList
(
decryptEnterpriseIds
.
split
(
" "
));
if
(
decryptEnterpriseIdList
.
contains
(
enterpriseId
)){
needDecryptByEnt
=
true
;
//创建密钥
DhDecryptKey
key
=
decryptKeyService
.
getKeyByEnterpriseId
(
enterpriseId
);
rsa
=
new
RSA
();
if
(
key
==
null
){
decryptKeyService
.
saveDecryKey
(
enterpriseId
,
rsa
.
getPublicKeyBase64
(),
rsa
.
getPrivateKeyBase64
());
publicKey
=
rsa
.
getPublicKeyBase64
();
}
else
{
publicKey
=
key
.
getPublicKey
();
}
}
}
}
@Override
...
...
@@ -43,7 +77,15 @@ public class CsvResultSetHelper implements ResultSetHelper {
result
[
i
]
=
rsColumnName
;
}
// FOR OVER
}
// IF OVER
if
(
needDecryptByEnt
){
//补齐加密字段
for
(
FlatQueryCondition
condition
:
allFields
){
if
(
FreeQueryServiceImpl
.
FILTERS_PHONE_ONLY
.
contains
(
condition
.
getFieldName
())){
result
[
result
.
length
]
=
condition
.
getFieldMark
();
}
}
}
return
result
;
}
@Override
...
...
@@ -66,6 +108,7 @@ public class CsvResultSetHelper implements ResultSetHelper {
@Override
public
String
[]
getColumnValues
(
ResultSet
resultSet
,
boolean
b
,
String
s
,
String
s1
)
throws
SQLException
,
IOException
{
String
[]
result
=
new
String
[
0
];
String
[]
decyptValue
=
new
String
[
0
];
int
columnCount
=
resultSet
.
getMetaData
().
getColumnCount
();
if
(
columnCount
>
0
)
{
result
=
new
String
[
columnCount
];
...
...
@@ -107,6 +150,11 @@ public class CsvResultSetHelper implements ResultSetHelper {
result
[
i
]
=
DecryptUtils
.
dataSecurityProcessUserName
(
resultSet
.
getString
(
columnName
));
}
else
{
result
[
i
]
=
"******"
;
if
(
needDecryptByEnt
&&
allFields
==
null
&&
isPhoneNumber
(
columnName
)){
//导出数据中需要增加加密列,先解密再加密
String
value
=
DecryptUtils
.
getInstance
().
decrypt
(
resultSet
.
getString
(
columnName
));
decyptValue
[
decyptValue
.
length
]
=
new
String
(
rsa
.
encrypt
(
value
.
getBytes
(
"UTF-8"
),
KeyType
.
PublicKey
));
}
}
}
else
if
(
doDecrypt
)
{
// 如果需要解密处理
//System.out.println("CSV 解密字段名 " + columnName);
...
...
@@ -136,6 +184,11 @@ public class CsvResultSetHelper implements ResultSetHelper {
}
// IF ELSE OVER
}
// FOR OVER
}
// IF OVER
if
(
decyptValue
.
length
>
0
){
for
(
int
k
=
0
;
k
<
decyptValue
.
length
;
k
++){
result
[
result
.
length
+
k
+
1
]
=
decyptValue
[
k
];
}
}
return
result
;
}
...
...
@@ -152,4 +205,18 @@ public class CsvResultSetHelper implements ResultSetHelper {
}
return
false
;
}
private
boolean
isPhoneNumber
(
String
columnName
){
if
(
StringUtils
.
isBlank
(
columnName
)){
return
false
;
}
for
(
FlatQueryCondition
condition
:
allFields
){
if
(
condition
.
getFieldMark
().
equals
(
columnName
)){
if
(
FreeQueryServiceImpl
.
FILTERS_PHONE_ONLY
.
contains
(
condition
.
getFieldName
())){
return
true
;
}
}
}
return
false
;
}
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/DecryptKeyServiceImpl.java
0 → 100644
View file @
9fbf18a8
package
com
.
gic
.
cloud
.
data
.
hook
.
service
.
impl
;
import
com.gic.cloud.data.hook.api.service.DecryptKeyService
;
import
com.gic.cloud.data.hook.service.dao.DhDecryptKeyMapper
;
import
com.gic.cloud.data.hook.api.dto.DhDecryptKey
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Calendar
;
import
java.util.Date
;
@Service
(
"decryptKeyService"
)
public
class
DecryptKeyServiceImpl
implements
DecryptKeyService
{
@Autowired
private
DhDecryptKeyMapper
dhDecryptKeyMapper
;
@Override
public
void
saveDecryKey
(
String
enterpriseId
,
String
publicKey
,
String
privateKey
)
{
DhDecryptKey
key
=
new
DhDecryptKey
();
key
.
setEnterpriseId
(
enterpriseId
);
key
.
setPublicKey
(
publicKey
);
key
.
setPrivateKey
(
privateKey
);
key
.
setCreateTime
(
new
Date
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
calendar
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
Date
time
=
calendar
.
getTime
();
key
.
setExpireTime
(
time
);
dhDecryptKeyMapper
.
insertSelective
(
key
);
}
@Override
public
DhDecryptKey
getKeyByEnterpriseId
(
String
enterpriseId
)
{
return
dhDecryptKeyMapper
.
selectByEnterpriseId
(
enterpriseId
);
}
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
9fbf18a8
...
...
@@ -7,6 +7,7 @@ import com.ctrip.framework.apollo.ConfigService;
import
com.gic.cloud.common.api.base.Page
;
import
com.gic.cloud.data.hook.api.dto.*
;
import
com.gic.cloud.data.hook.api.entity.*
;
import
com.gic.cloud.data.hook.api.service.DecryptKeyService
;
import
com.gic.cloud.data.hook.api.service.IDownloadTaskService
;
import
com.gic.cloud.data.hook.api.service.IFlatQueryResultService
;
import
com.gic.cloud.data.hook.service.*
;
...
...
@@ -65,6 +66,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
FlatQueryTableDao
flatQueryTableDao
;
@Autowired
IDownloadTaskService
downloadTaskService
;
@Autowired
DecryptKeyService
decryptKeyService
;
/** 自助指标查询关联的下载条件列表 */
protected
List
<
FlatQueryTaskCondition
>
taskConditions
=
Lists
.
newArrayList
();
...
...
@@ -569,6 +572,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
// stat.setQueryTimeout(60 * 1000);
stat
.
execute
(
"REFRESH TABLE "
+
condition
.
getTableId
());
// 强制刷新表结构
ResultSet
rs
=
stat
.
executeQuery
(
fullQuery
);
String
queryDataType
=
task
.
getQueryDataType
()
==
QueryDataType
.
FULL
?
CsvDataFilterMode
.
DECRYPT
:
CsvDataFilterMode
.
DESENSI
;
ResultSetHelper
helper
=
new
CsvResultSetHelper
(
queryDataType
,
condition
.
getDecryptFilters
(),
condition
.
getConditions
(),
condition
.
getEnterpriseIds
().
get
(
0
),
decryptKeyService
);
// 生成指定格式下载元文件
String
originalFilePath
=
""
;
if
(
task
.
getFormat
().
equals
(
DownloadFileFormat
.
CSV
))
{
// 如果指定为 CSV 格式
...
...
@@ -580,7 +585,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
//CSVWriter csvWriter = new CSVWriter(new FileWriter(csvPath), '\t');
OutputStreamWriter
out
=
new
OutputStreamWriter
(
new
FileOutputStream
(
originalFilePath
),
Charset
.
forName
(
"GBK"
));
ResultSetHelper
helper
=
new
CsvResultSetHelper
(
task
.
getQueryDataType
()
==
QueryDataType
.
FULL
?
CsvDataFilterMode
.
DECRYPT
:
CsvDataFilterMode
.
DESENSI
,
condition
.
getDecryptFilters
(),
condition
.
getConditions
());
CSVWriter
writer
=
new
CSVWriter
(
out
,
','
);
writer
.
setResultService
(
helper
);
writer
.
writeAll
(
rs
,
true
);
...
...
@@ -594,17 +598,26 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
Sheet
sheet
=
wb
.
createSheet
();
Row
row
=
sheet
.
createRow
(
0
);
Cell
cell
;
for
(
int
j
=
0
;
j
<
rs
.
getMetaData
().
getColumnCount
();
++
j
)
{
// 遍历创建表头
String
[]
columnNames
=
helper
.
getColumnNames
(
rs
);
for
(
int
j
=
0
;
j
<
columnNames
.
length
;
j
++){
cell
=
row
.
createCell
(
j
);
cell
.
setCellValue
(
columnNames
[
j
]);
}
/*for (int j = 0; j < rs.getMetaData().getColumnCount(); ++j) { // 遍历创建表头
String colName = rs.getMetaData().getColumnLabel(j + 1);
cell = row.createCell(j);
cell.setCellValue(colName);
}
}
*/
// 遍历输出行
int
rowCount
=
0
;
while
(
rs
.
next
())
{
rowCount
++;
row
=
sheet
.
createRow
(
rowCount
);
for
(
int
j
=
0
;
j
<
rs
.
getMetaData
().
getColumnCount
();
++
j
)
{
String
[]
columnValues
=
helper
.
getColumnValues
(
rs
,
true
,
""
,
""
);
for
(
int
j
=
0
;
j
<
columnValues
.
length
;
j
++){
row
.
createCell
(
j
).
setCellValue
(
columnValues
[
j
]);
}
/*for (int j = 0; j < rs.getMetaData().getColumnCount(); ++j) {
//String c = rs.getString(j + 1);
//row.createCell(j).setCellValue(c);
String cName = rs.getMetaData().getColumnName(j+1);
...
...
@@ -636,7 +649,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
break;
}
} // IF ELSE OVER
}
// FOR OVER
} // FOR OVER
*/
}
// WHILE OVER
FileOutputStream
fileOut
=
new
FileOutputStream
(
originalFilePath
);
wb
.
write
(
fileOut
);
...
...
@@ -760,6 +773,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
// stat.setQueryTimeout(60 * 1000);
stat
.
execute
(
"REFRESH TABLE "
+
condition
.
getTableId
());
// 强制刷新表结构
ResultSet
rs
=
stat
.
executeQuery
(
fullQuery
);
String
queryDataType
=
task
.
getQueryDataType
()
==
QueryDataType
.
FULL
?
CsvDataFilterMode
.
DECRYPT
:
CsvDataFilterMode
.
DESENSI
;
ResultSetHelper
helper
=
new
CsvResultSetHelper
(
queryDataType
,
condition
.
getDecryptFilters
(),
condition
.
getConditions
(),
condition
.
getEnterpriseIds
().
get
(
0
),
decryptKeyService
);
// 生成指定格式下载元文件
String
originalFilePath
=
""
;
if
(
task
.
getFormat
().
equals
(
DownloadFileFormat
.
CSV
))
{
// 如果指定为 CSV 格式
...
...
@@ -771,7 +786,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
//CSVWriter csvWriter = new CSVWriter(new FileWriter(csvPath), '\t');
OutputStreamWriter
out
=
new
OutputStreamWriter
(
new
FileOutputStream
(
originalFilePath
),
Charset
.
forName
(
"GBK"
));
ResultSetHelper
helper
=
new
CsvResultSetHelper
(
task
.
getQueryDataType
()
==
QueryDataType
.
FULL
?
CsvDataFilterMode
.
DECRYPT
:
CsvDataFilterMode
.
DESENSI
,
condition
.
getDecryptFilters
(),
condition
.
getConditions
());
//
ResultSetHelper helper = new CsvResultSetHelper(task.getQueryDataType() == QueryDataType.FULL ? CsvDataFilterMode.DECRYPT : CsvDataFilterMode.DESENSI, condition.getDecryptFilters(), condition.getConditions());
CSVWriter
writer
=
new
CSVWriter
(
out
,
','
);
writer
.
setResultService
(
helper
);
writer
.
writeAll
(
rs
,
true
);
...
...
@@ -785,17 +800,26 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
Sheet
sheet
=
wb
.
createSheet
();
Row
row
=
sheet
.
createRow
(
0
);
Cell
cell
;
for
(
int
j
=
0
;
j
<
rs
.
getMetaData
().
getColumnCount
();
++
j
)
{
// 遍历创建表头
String
[]
columnNames
=
helper
.
getColumnNames
(
rs
);
for
(
int
j
=
0
;
j
<
columnNames
.
length
;
j
++){
cell
=
row
.
createCell
(
j
);
cell
.
setCellValue
(
columnNames
[
j
]);
}
/*for (int j = 0; j < rs.getMetaData().getColumnCount(); ++j) { // 遍历创建表头
String colName = rs.getMetaData().getColumnLabel(j + 1);
cell = row.createCell(j);
cell.setCellValue(colName);
}
}
*/
// 遍历输出行
int
rowCount
=
0
;
while
(
rs
.
next
())
{
rowCount
++;
row
=
sheet
.
createRow
(
rowCount
);
for
(
int
j
=
0
;
j
<
rs
.
getMetaData
().
getColumnCount
();
++
j
)
{
String
[]
columnValues
=
helper
.
getColumnValues
(
rs
,
true
,
""
,
""
);
for
(
int
j
=
0
;
j
<
columnValues
.
length
;
j
++){
row
.
createCell
(
j
).
setCellValue
(
columnValues
[
j
]);
}
/*for (int j = 0; j < rs.getMetaData().getColumnCount(); ++j) {
//String c = rs.getString(j + 1);
//row.createCell(j).setCellValue(c);
String cName = rs.getMetaData().getColumnName(j+1);
...
...
@@ -827,7 +851,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
break;
}
} // IF ELSE OVER
}
// FOR OVER
} // FOR OVER
*/
}
// WHILE OVER
FileOutputStream
fileOut
=
new
FileOutputStream
(
originalFilePath
);
wb
.
write
(
fileOut
);
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
View file @
9fbf18a8
...
...
@@ -611,4 +611,8 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
public
static
void
main
(
String
[]
args
){
long
startTs
=
(
System
.
currentTimeMillis
()
/
60
*
1000
+
1
)
*
60
*
1000
-
System
.
currentTimeMillis
();
System
.
out
.
println
(
"startTs = "
+
startTs
);
}
}
gic-cloud-data-hook-service/src/main/resources/mapper/DhDecryptKeyMapper.xml
0 → 100644
View file @
9fbf18a8
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.gic.cloud.data.hook.service.dao.DhDecryptKeyMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.cloud.data.hook.api.dto.DhDecryptKey"
>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"enterprise_id"
jdbcType=
"VARCHAR"
property=
"enterpriseId"
/>
<result
column=
"public_key"
jdbcType=
"VARCHAR"
property=
"publicKey"
/>
<result
column=
"private_key"
jdbcType=
"VARCHAR"
property=
"privateKey"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"expire_time"
jdbcType=
"TIMESTAMP"
property=
"expireTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, enterprise_id, public_key, private_key, create_time, expire_time, update_time
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from dh_decrypt_key
where id = #{id,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from dh_decrypt_key
where id = #{id,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.cloud.data.hook.api.dto.DhDecryptKey"
>
insert into dh_decrypt_key (id, enterprise_id, public_key,
private_key, create_time, expire_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{enterpriseId,jdbcType=VARCHAR}, #{publicKey,jdbcType=VARCHAR},
#{privateKey,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{expireTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.cloud.data.hook.api.dto.DhDecryptKey"
>
insert into dh_decrypt_key
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
</if>
<if
test=
"publicKey != null"
>
public_key,
</if>
<if
test=
"privateKey != null"
>
private_key,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"expireTime != null"
>
expire_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id,jdbcType=INTEGER},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if
test=
"publicKey != null"
>
#{publicKey,jdbcType=VARCHAR},
</if>
<if
test=
"privateKey != null"
>
#{privateKey,jdbcType=VARCHAR},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"expireTime != null"
>
#{expireTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.cloud.data.hook.api.dto.DhDecryptKey"
>
update dh_decrypt_key
<set>
<if
test=
"enterpriseId != null"
>
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if
test=
"publicKey != null"
>
public_key = #{publicKey,jdbcType=VARCHAR},
</if>
<if
test=
"privateKey != null"
>
private_key = #{privateKey,jdbcType=VARCHAR},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"expireTime != null"
>
expire_time = #{expireTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.cloud.data.hook.api.dto.DhDecryptKey"
>
update dh_decrypt_key
set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
public_key = #{publicKey,jdbcType=VARCHAR},
private_key = #{privateKey,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
expire_time = #{expireTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select
id=
"selectByEnterpriseId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from dh_decrypt_key
where enterprise_id=#{enterpriseId} and now()
<
expire_time
</select>
</mapper>
\ 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