Commit f20dbd51 authored by hongguangwu's avatar hongguangwu

MVP1.7.12-保存人员档案1

parent 49d87fdf
......@@ -18,18 +18,18 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.yifu.cloud.plus.v1.yifu.archives.config.GzConfig;
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.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.archives.utils.ReturnGz;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -56,40 +56,33 @@ public class TGzController {
* @param params 包含业务参数和签名的Map
* @return 处理结果
*/
@PostMapping("/receive")
public R<String> receivePush(@RequestBody Map<String, Object> params) {
// 1. 验证签名
String receivedSignature = (String) params.get("signature");
if (receivedSignature == null) {
return R.failed("签名参数缺失");
}
@PostMapping("/saveOfferInfo")
public ReturnGz<String> saveOfferInfo(@RequestBody TGzOfferInfo tGzOfferInfo
, @RequestParam String appkey, @RequestParam String expires, @RequestParam String signature) {
Map<String, Object> params = new HashMap<>();
params.put("appkey", appkey);
params.put("expires", expires);
params.put("signature", signature);
// 2. 计算期望的签名
String expectedSignature = GZSign.getSignature(params, gzConfig.getAppsecret());
// 3. 比较签名是否一致
if (!receivedSignature.equals(expectedSignature)) {
return R.failed("签名验证失败");
}
// 4. 验证时间戳是否过期
String expiresStr = (String) params.get("expires");
if (expiresStr == null) {
return R.failed("过期时间参数缺失");
if (!signature.equals(expectedSignature)) {
return ReturnGz.failed("签名验证失败");
}
try {
long expires = Long.parseLong(expiresStr);
long expiresLong = Long.parseLong(expires);
long currentTime = System.currentTimeMillis() / 1000;
if (currentTime > expires) {
return R.failed("请求已过期");
if (currentTime > expiresLong) {
return ReturnGz.failed("请求已过期");
}
} catch (NumberFormatException e) {
return R.failed("过期时间格式错误");
return ReturnGz.failed("过期时间格式错误");
}
// 5. 签名验证通过,处理业务逻辑
return processPushData(params);
return this.saveData(tGzOfferInfo);
}
/**
......@@ -98,11 +91,14 @@ public class TGzController {
* @param params 业务参数
* @return 处理结果
*/
private R<String> processPushData(Map<String, Object> params) {
private ReturnGz<String> saveData(TGzOfferInfo tGzOfferInfo) {
// 这里实现你的业务逻辑
// 例如:解析参数、保存数据、触发后续处理等
return R.ok();
tGzOfferInfo.setCreateBy("3");
tGzOfferInfo.setCreateName("瓜子推送");
tGzOfferInfo.setCreateTime(LocalDateTime.now());
tGzOfferInfoService.save(tGzOfferInfo);
return ReturnGz.ok();
}
......
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.archives.utils;
import lombok.*;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 响应瓜子
* @author lengleng
*/
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ReturnGz<T> implements Serializable {
private static final long serialVersionUID = 1L;
private static final String GZ_OK_MSG = "成功";
private static final String GZ_OK = "S00000";
private static final String GZ_FAIL = "1";
@Getter
@Setter
private String code;
@Getter
@Setter
private String message;
@Getter
@Setter
private String redirectUrl;
@Getter
@Setter
private T data;
public ReturnGz(T data) {
super();
this.data = data;
this.code = "S00000";
}
public static <T> ReturnGz<T> ok() {
return restResult(null, "S00000", GZ_OK_MSG);
}
public static <T> ReturnGz<T> ok(T data) {
return restResult(data, GZ_OK, GZ_OK_MSG);
}
public static <T> ReturnGz<T> ok(T data, String msg) {
return restResult(data, GZ_OK, msg);
}
public static <T> ReturnGz<T> failed() {
return restResult(null, GZ_FAIL, null);
}
public static <T> ReturnGz<T> failed(String msg) {
return restResult(null, GZ_FAIL, msg);
}
public static <T> ReturnGz<T> failed(T data) {
return restResult(data, GZ_FAIL, null);
}
public static <T> ReturnGz<T> failed(T data, String msg) {
return restResult(data, GZ_FAIL, msg);
}
private static <T> ReturnGz<T> restResult(T data, String code, String msg) {
ReturnGz<T> apiResult = new ReturnGz<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMessage(msg);
apiResult.setRedirectUrl(null);
return apiResult;
}
}
......@@ -57,6 +57,7 @@ security:
- /employeeregistrationpre/getGzEmployeeInfo
- /employeeregistrationpre/judgeIsSimple
- /tgzempinfo/getInfoByOfferId
- /gz/core/saveOfferInfo
# 文件上传相关 支持阿里云、华为云、腾讯、minio
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment