时间戳服务BUG修复
This commit is contained in:
@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -18,6 +19,7 @@ import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TimeServiceConstant {
|
||||
|
||||
public static TSAClient client;
|
||||
@ -25,7 +27,7 @@ public class TimeServiceConstant {
|
||||
@Value("${spring.redis.sentinel.master}")
|
||||
private String redis;
|
||||
|
||||
public TimeServiceConstant(){
|
||||
static {
|
||||
try{
|
||||
Properties prop = new Properties();
|
||||
ClassPathResource classPathResource = new ClassPathResource("cssconfig.properties");
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.timeService.controller;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.mall.ebtp.extend.export.service.ExportServiceFactory;
|
||||
import com.chinaunicom.mall.ebtp.extend.timeService.TimeServiceConstant;
|
||||
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.SystemTime;
|
||||
import com.chinaunicom.mall.ebtp.extend.timeService.tsa.TtsAgent;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -20,6 +22,8 @@ import java.util.Date;
|
||||
@RequestMapping("/v1/timeService")
|
||||
public class TimeServiceController {
|
||||
|
||||
@Autowired
|
||||
private TimeServiceConstant timeServiceConstant;
|
||||
/**
|
||||
* 申请时间戳
|
||||
*
|
||||
@ -29,8 +33,8 @@ public class TimeServiceController {
|
||||
@ApiOperation("申请时间戳")
|
||||
@GetMapping(value = "/signTimeStamp")
|
||||
public BaseResponse<String> signTimeStamp(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data", required = false) String data) {
|
||||
TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(constant.signTimeStamp(data));
|
||||
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(timeServiceConstant.signTimeStamp(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,8 +46,8 @@ public class TimeServiceController {
|
||||
@ApiOperation("解析时间戳加密原文")
|
||||
@PostMapping(value = "/verifyTimeStamp")
|
||||
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
||||
TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(constant.verifyTimeStamp2(timestamp));
|
||||
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(timeServiceConstant.verifyTimeStamp2(timestamp));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,8 +59,8 @@ public class TimeServiceController {
|
||||
@ApiOperation("直接获取时间戳对象(内涵日期)")
|
||||
@PostMapping(value = "/getServiceTimeObj")
|
||||
public BaseResponse<TtsAgent.TtsParseResult> getServiceTimeObj(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data", required = false) String data) {
|
||||
TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(constant.getServiceTimeObj(data));
|
||||
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(timeServiceConstant.getServiceTimeObj(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,8 +72,8 @@ public class TimeServiceController {
|
||||
@ApiOperation("直接获取日期字符串")
|
||||
@GetMapping(value = "/getServiceTime")
|
||||
public BaseResponse<String> getServiceTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data", required = false) String data) {
|
||||
TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(constant.getServiceTime(data));
|
||||
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(timeServiceConstant.getServiceTime(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,8 +85,8 @@ public class TimeServiceController {
|
||||
@ApiOperation("获取日期对象SystemTime")
|
||||
@GetMapping(value = "/getServiceSystemTime")
|
||||
public BaseResponse<SystemTime> getServiceSystemTime(@ApiParam(value = "待申请时间戳的原文", required = false) @RequestParam(name = "data", required = false) String data) {
|
||||
TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(constant.getServiceSystemTime(data));
|
||||
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||
return BaseResponse.success(timeServiceConstant.getServiceSystemTime(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,9 +100,9 @@ public class TimeServiceController {
|
||||
public BaseResponse<SystemTime> getDescOpenRoomTime(@RequestParam(name = "openTime", required = true) String openTime) {
|
||||
try {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
TimeServiceConstant constant = new TimeServiceConstant();
|
||||
//TimeServiceConstant constant = new TimeServiceConstant();
|
||||
|
||||
Date now = constant.getServiceDate("getDescOpenRoomTime");
|
||||
Date now = timeServiceConstant.getServiceDate("getDescOpenRoomTime");
|
||||
;//当前时间
|
||||
Date date = df.parse(openTime);//过去
|
||||
long l = date.getTime() - now.getTime();
|
||||
|
Reference in New Issue
Block a user