Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
fangxinjiang
yifu-mvp
Commits
e8eab790
Commit
e8eab790
authored
Jun 23, 2025
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.7.12-对接瓜子接口
parent
504be995
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
40 deletions
+47
-40
TGzOfferInfo.java
...yifu/cloud/plus/v1/yifu/archives/entity/TGzOfferInfo.java
+2
-0
GzConfig.java
...com/yifu/cloud/plus/v1/yifu/archives/config/GzConfig.java
+16
-16
TGzController.java
...cloud/plus/v1/yifu/archives/controller/TGzController.java
+28
-23
GZSign.java
...va/com/yifu/cloud/plus/v1/yifu/archives/utils/GZSign.java
+1
-1
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/entity/TGzOfferInfo.java
View file @
e8eab790
...
...
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
...
...
@@ -249,6 +250,7 @@ public class TGzOfferInfo extends BaseEntity {
@ExcelAttribute
(
name
=
"预计入职日期:yyyy-MM-dd"
,
isDate
=
true
)
@ExcelProperty
(
"预计入职日期:yyyy-MM-dd"
)
@Schema
(
description
=
"预计入职日期:yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
expEntryDate
;
/**
* 部门名称
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/config/GzConfig.java
View file @
e8eab790
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
config
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
lombok.Data
;
...
...
@@ -41,33 +42,32 @@ public class GzConfig {
private
static
final
String
X_REQ_NONCE
=
"xReqNonce"
;
private
static
final
String
VERSION
=
"version"
;
public
boolean
getGzBankInfo
(
RestTemplate
restTemplate
,
long
expires
,
String
signature
,
String
pageNum
,
String
pageSize
,
String
startTime
,
String
endTime
)
{
String
gzBankUrl
=
appUrl
+
"/eim-hr-induction/api/hr/induction/open/base/bank-branch?pageNum=%s&pageSize=%s&startTime=%s&endTime=%s&appkey=%s&expires=%s&signature=%s"
;
String
requestUrl
=
String
.
format
(
gzBankUrl
,
pageNum
,
pageSize
,
startTime
,
endTime
,
appkey
,
expires
,
signature
);
//String result = restTemplate.getForObject(requestUrl, String.class);
public
boolean
getGzBankInfo
(
RestTemplate
restTemplate
,
String
sortedParams
)
{
String
gzBankUrl
=
appUrl
+
"/eim-hr-induction/api/hr/induction/open/base/bank-branch?"
+
sortedParams
;
// 创建请求头并添加Authorization
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"00000000"
);
// 设置Authorization头
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
HttpEntity
<
String
>
entity
=
new
HttpEntity
<>(
null
,
headers
);
// 发送GET请求
String
result
=
restTemplate
.
exchange
(
request
Url
,
HttpMethod
.
GET
,
entity
,
String
.
class
).
getBody
();
String
result
=
restTemplate
.
exchange
(
gzBank
Url
,
HttpMethod
.
GET
,
entity
,
String
.
class
).
getBody
();
if
(
result
!=
null
&&
result
.
contains
(
"code"
)
&&
result
.
contains
(
"data"
))
{
JSONObject
resultObject
=
JSON
.
parseObject
(
result
);
String
code
=
resultObject
.
getString
(
"code"
);
if
(
Common
.
isNotNull
(
code
)
&&
"S00000"
.
equals
(
code
))
{
String
data
=
resultObject
.
getString
(
"data"
);
JSONObject
dataObject
=
JSON
.
parseObject
(
data
);
String
bankCd
=
dataObject
.
getString
(
"bankCd"
);
String
cnapsId
=
dataObject
.
getString
(
"cnapsId"
);
// TODO - 继续解析参数并存储
System
.
out
.
println
(
"bankCd="
+
bankCd
);
System
.
out
.
println
(
"cnapsId="
+
cnapsId
);
JSONArray
dataArray
=
(
JSONArray
)
resultObject
.
get
(
"data"
);
JSONObject
dataObject
;
String
bankCd
;
String
cnapsId
;
for
(
int
i
=
0
;
i
<
dataArray
.
size
();
i
++)
{
dataObject
=
(
JSONObject
)
dataArray
.
get
(
i
);
bankCd
=
dataObject
.
getString
(
"bankCd"
);
cnapsId
=
dataObject
.
getString
(
"cnapsId"
);
// TODO - 继续解析参数并存储
System
.
out
.
println
(
"bankCd="
+
bankCd
);
System
.
out
.
println
(
"cnapsId="
+
cnapsId
);
}
return
true
;
}
}
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TGzController.java
View file @
e8eab790
...
...
@@ -22,6 +22,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TGzOfferInfo;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TGzOfferInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.utils.GZSign
;
import
com.yifu.cloud.plus.v1.yifu.archives.utils.ReturnGz
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -30,6 +32,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.HashMap
;
...
...
@@ -54,6 +57,7 @@ public class TGzController {
private
final
TGzOfferInfoService
tGzOfferInfoService
;
private
RestTemplate
restTemplate
=
new
RestTemplate
();
/**
* @Description: 接收瓜子推送过来的Offer信息
* @Author: hgw
...
...
@@ -61,32 +65,24 @@ public class TGzController {
* @return: com.yifu.cloud.plus.v1.yifu.archives.utils.ReturnGz<java.lang.String>
**/
@PostMapping
(
"/saveOfferInfo"
)
public
ReturnGz
<
String
>
saveOfferInfo
(
@RequestBody
TGzOfferInfo
tG
zOfferInfo
,
@RequestParam
String
appkey
,
@RequestParam
String
expires
,
@RequestParam
String
signature
)
{
public
ReturnGz
<
String
>
saveOfferInfo
(
@RequestBody
TGzOfferInfo
g
zOfferInfo
,
@RequestParam
String
expires
,
@RequestParam
String
signature
,
@RequestParam
String
requestId
,
@RequestParam
String
appkey
,
@RequestParam
String
nonce
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"appkey"
,
appkey
);
params
.
put
(
"expires"
,
expires
);
params
.
put
(
"signature"
,
signature
);
params
.
put
(
"requestId"
,
requestId
);
params
.
put
(
"appkey"
,
appkey
);
params
.
put
(
"nonce"
,
nonce
);
// 2. 计算期望的签名
String
expectedSignature
=
GZSign
.
getSignature
(
params
,
gzConfig
.
getAppsecret
());
// 3. 比较签名是否一致
if
(!
signature
.
equals
(
expectedSignature
))
{
if
(!
params
.
get
(
"signature"
)
.
equals
(
expectedSignature
))
{
return
ReturnGz
.
failed
(
"签名验证失败"
);
}
try
{
long
expiresLong
=
Long
.
parseLong
(
expires
);
long
currentTime
=
System
.
currentTimeMillis
()
/
1000
;
if
(
currentTime
>
expiresLong
)
{
return
ReturnGz
.
failed
(
"请求已过期"
);
}
}
catch
(
NumberFormatException
e
)
{
return
ReturnGz
.
failed
(
"过期时间格式错误"
);
}
// 5. 签名验证通过,处理业务逻辑
return
this
.
saveData
(
tG
zOfferInfo
);
return
this
.
saveData
(
g
zOfferInfo
);
}
/**
...
...
@@ -94,11 +90,15 @@ public class TGzController {
* @return 处理结果
*/
private
ReturnGz
<
String
>
saveData
(
TGzOfferInfo
tGzOfferInfo
)
{
//TGzOfferInfo tGzOfferInfo = new TGzOfferInfo();
// 这里实现你的业务逻辑
// 例如:解析参数、保存数据、触发后续处理等
tGzOfferInfo
.
setCreateBy
(
"3"
);
tGzOfferInfo
.
setCreateName
(
"瓜子推送"
);
tGzOfferInfo
.
setCreateTime
(
LocalDateTime
.
now
());
/*tGzOfferInfo.setBizId(String.valueOf(params.get("bizId")));
tGzOfferInfo.setNationalId(String.valueOf(params.get("nationalId")));
tGzOfferInfo.setName(String.valueOf(params.get("name")));*/
tGzOfferInfoService
.
save
(
tGzOfferInfo
);
return
ReturnGz
.
ok
();
}
...
...
@@ -109,16 +109,21 @@ public class TGzController {
* @Date: 2025/6/23 15:28
* @return: boolean
**/
@
Pos
tMapping
(
"/getGzBank"
)
@
Ge
tMapping
(
"/getGzBank"
)
public
boolean
getGzBank
(
@RequestParam
String
pageNum
,
@RequestParam
String
pageSize
,
@RequestParam
String
startTime
,
@RequestParam
String
endTime
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"appkey"
,
gzConfig
.
getAppkey
());
long
expires
=
new
Date
().
getTime
()
+
30000
;
params
.
put
(
"expires"
,
expires
);
// 2. 计算期望的签名
String
signature
=
GZSign
.
getSignature
(
params
,
gzConfig
.
getAppsecret
());
return
gzConfig
.
getGzBankInfo
(
restTemplate
,
expires
,
signature
,
pageNum
,
pageSize
,
startTime
,
endTime
);
params
.
put
(
"pageNum"
,
pageNum
);
params
.
put
(
"pageSize"
,
pageSize
);
params
.
put
(
"startTime"
,
startTime
);
params
.
put
(
"endTime"
,
endTime
);
GZSign
.
addSignature
(
params
,
gzConfig
.
getAppkey
(),
gzConfig
.
getAppsecret
());
params
.
remove
(
"startTime"
,
startTime
);
params
.
remove
(
"endTime"
,
endTime
);
String
sortedParams
=
GZSign
.
getEncodeString
(
params
);
sortedParams
+=
"&startTime="
+
startTime
+
"&endTime="
+
endTime
;
return
gzConfig
.
getGzBankInfo
(
restTemplate
,
sortedParams
);
}
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/utils/GZSign.java
View file @
e8eab790
...
...
@@ -175,7 +175,7 @@ public class GZSign {
}
// 通过参数集合map 组装成需要签名的字符串id=123&name=456
p
rivate
static
String
getEncodeString
(
Map
<
String
,
Object
>
params
)
{
p
ublic
static
String
getEncodeString
(
Map
<
String
,
Object
>
params
)
{
if
(
params
==
null
||
params
.
size
()
==
0
)
{
return
""
;
}
...
...
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