tao.mo

manager-server | 修改 | 基础功能调整

mt
2024年11月6日19:18:06
Showing 32 changed files with 327 additions and 184 deletions
package com.fedex.connect.customer.controller.base;
import com.fedex.connect.common.dependencies.common.BasicController;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.service.biz.IAttachmentService;
import com.fedex.connect.customer.service.biz.IConsignmentService;
import com.fedex.connect.customer.validate.controller.biz.AttachmentValidate;
import com.fedex.connect.customer.validate.controller.biz.ConsignmentValidate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import javax.annotation.Resource;
import java.net.URI;
import java.util.Objects;
/**
* @author EDY
*/
public class BaseController {
@Slf4j
public class BaseController extends BasicController {
@Resource
protected LocaleMessageUtil localeMessageUtil;
......@@ -37,82 +38,8 @@ public class BaseController {
@Autowired
protected ConsignmentValidate consignmentValidate;
public <T> ResponseEntity<T> seeOther(String url) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(URI.create(url));
return result(HttpStatus.SEE_OTHER, httpHeaders);
}
public <T> ResponseEntity<T> temporaryRedirect(String url) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(URI.create(url));
return result(HttpStatus.TEMPORARY_REDIRECT, httpHeaders);
}
public <T> ResponseEntity<T> permanentRedirect(String url) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(URI.create(url));
return result(HttpStatus.PERMANENT_REDIRECT, httpHeaders);
}
public <T> ResponseEntity<T> result(HttpStatus status, T data) {
return new ResponseEntity<>(data, status);
}
public <T> ResponseEntity<T> result(HttpStatus status, HttpHeaders headers) {
return new ResponseEntity<>(headers, status);
}
public <T> ResponseEntity<T> ok(T data) {
return new ResponseEntity<>(data, HttpStatus.OK);
}
public <T> ResponseEntity<T> ok(MultiValueMap<String, String> headers, T data) {
return new ResponseEntity<>(data, headers, HttpStatus.OK);
}
public <T> ResponseEntity<T> error(HttpStatus code) {
return new ResponseEntity<>(code);
public User getCurrentUserInfo(){
User user = this.getUserInfo(localeMessageUtil);
return user;
}
public <T> ResponseEntity<T> error(HttpStatus code, MultiValueMap<String, String> headers) {
return new ResponseEntity<>(headers, code);
}
/**
* 通过自定义的错误码,转换为对应的HttpStatus
* @param response
* @return
*/
public HttpStatus errorMappingStatus(ResponseVo response) {
if (Objects.isNull(response)) {
return HttpStatus.BAD_REQUEST; //400
}
return HttpStatus.BAD_REQUEST; //400
}
/**
* 判定是否返回成功
* @param responseEntity
* @param <T>
* @return
*/
public <T> boolean isSuccess(ResponseEntity<ResponseVo<T>> responseEntity) {
return responseEntity != null && responseEntity.getBody() != null && responseEntity.getBody().isSuccess();
}
/**
* 判定是否返回成功
* @param response
* @param <T>
* @return
*/
public <T> boolean isSuccess(ResponseVo<T> response) {
return response != null && response.isSuccess();
}
}
\ No newline at end of file
......
package com.fedex.connect.customer.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.customer.data.bo.LongBo;
public interface IAttachmentQueryController {
ResponseVo findHistory(LongBo bo);
}
......@@ -2,8 +2,8 @@ package com.fedex.connect.customer.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.customer.data.query.ConsignmentQuery;
import org.springframework.web.bind.annotation.RequestBody;
public interface IConsignmentQueryController {
ResponseVo findConsignmentList(@RequestBody ConsignmentQuery consignmentQuery);
ResponseVo findConsignmentList(ConsignmentQuery consignmentQuery);
ResponseVo findConsignmentInfo(Long id);
}
\ No newline at end of file
......
......@@ -6,6 +6,7 @@ import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IAttachmentController;
import com.fedex.connect.customer.controller.biz.IAttachmentQueryController;
import com.fedex.connect.customer.data.bo.LongBo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -24,10 +25,11 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/attachment/query", name = "附件查询相关")
@Api(value = "AttachmentQueryController", tags = {"附件查询相关"})
public class AttachmentQueryController extends BaseController implements IAttachmentController {
public class AttachmentQueryController extends BaseController implements IAttachmentQueryController {
@PostMapping("/history")
@ApiOperation(value = "历史上传记录查询")
@Override
public ResponseVo findHistory(@RequestBody LongBo bo) {
ResponseVo responseResultVo = attachmentValidate.preCheckForFindHistory(bo);
if (responseResultVo != null){
......
......@@ -32,6 +32,7 @@ public class ConsignmentController extends BaseController implements IConsignmen
@PostMapping("/add")
@ApiOperation("上传运单")
@OperationMethodLog(describe = "con_add_oper")
@Override
public ResponseVo addConsignment(@RequestBody AddBo bo){
ResponseVo responseResultVo = consignmentValidate.preCheckAdd(bo);
if (responseResultVo != null){
......
......@@ -7,45 +7,53 @@ import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IConsignmentQueryController;
import com.fedex.connect.customer.data.query.ConsignmentInfoQuery;
import com.fedex.connect.customer.data.query.ConsignmentQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
* @Author Szl
* @Description 类说明 运单查询相关接口
* @Date 2024/10/30
*/
@Slf4j
@RestController
@RequestMapping(value = "/consignment/query", name = "运单查询相关")
@Api(value = "ConsignmentQueryController", tags = {"运单查询相关"})
public class ConsignmentQueryController extends BaseController implements IConsignmentQueryController {
private static final Logger logger = LoggerFactory.getLogger(ConsignmentQueryController.class);
@PostMapping("/list")
@ApiOperation(value = "运单查询")
@Override
public ResponseVo findConsignmentList(@RequestBody ConsignmentQuery consignmentQuery) {
User user = null;
try {
user = CurrentUserInfo.getUser();
//userId = 0L;
} catch (Exception e) {
logger.error(LogShowModel.showException("Exception", e));
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
}
if (user == null) {
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.OVERDUE_TOKEN_CODE.getMsg()));
}
/**
* 获取当前用户信息
*/
User user = this.getCurrentUserInfo();
ConsignmentQuery query = ConsignmentQuery.dataProcessing(consignmentQuery);
query.setUserId(user.getId());
query.setUuid(user.getUserUuid());
return consignmentService.findConsignments(query);
}
@PostMapping("/info/{id}")
@ApiOperation(value = "运单详细信息查询")
@Override
public ResponseVo findConsignmentInfo(@ApiParam(value="运单ID",required = true) @PathVariable(value = "id") Long id) {
/**
* 获取当前用户信息
*/
User user = this.getCurrentUserInfo();
ConsignmentInfoQuery detailQuery = new ConsignmentInfoQuery();
detailQuery.setUserId(user.getId());
detailQuery.setUuid(user.getUserUuid());
detailQuery.setConsignmentId(id);
// return consignmentService.findConsignmentInfo(detailQuery);
return null;
}
}
......
package com.fedex.connect.customer.data.query;
import lombok.Data;
/**
* @Author mt
* @Description 查询运单详情
* @Date 2024/11/6
*/
@Data
public class ConsignmentInfoQuery {
//用户id
private Long userId;
//用户uuid
private String uuid;
//运单id
private Long consignmentId;
}
package com.fedex.connect.customer.data.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fedex.connect.common.dependencies.util.DateUtil;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.customer.data.PageBase;
import lombok.Data;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
......@@ -16,6 +16,7 @@ import java.util.List;
* @Description 类说明 运单查询条件对象
* @Date 2024/10/31
*/
@Data
public class ConsignmentQuery extends PageBase {
public static ConsignmentQuery dataProcessing(ConsignmentQuery query){
......@@ -45,68 +46,9 @@ public class ConsignmentQuery extends PageBase {
private Long sort;
@JsonIgnore
private List<String> consignmentCodeList;
@JsonIgnore
private Long userId;
@JsonIgnore
private String uuid;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getCreateTimeFrom() {
return createTimeFrom;
}
public void setCreateTimeFrom(String createTimeFrom) {
this.createTimeFrom = createTimeFrom;
}
public String getCreateTimeTo() {
return createTimeTo;
}
public void setCreateTimeTo(String createTimeTo) {
this.createTimeTo = createTimeTo;
}
public String getConsignmentCode() {
return consignmentCode;
}
public void setConsignmentCode(String consignmentCode) {
this.consignmentCode = consignmentCode;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public List<String> getConsignmentCodeList() {
return consignmentCodeList;
}
public void setConsignmentCodeList(List<String> consignmentCodeList) {
this.consignmentCodeList = consignmentCodeList;
}
public Long getSort() {
return sort;
}
public void setSort(Long sort) {
this.sort = sort;
}
}
......
......@@ -4,6 +4,7 @@ import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.customer.data.bo.LongBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
......@@ -15,7 +16,7 @@ import javax.annotation.Resource;
*/
@Component
public class AttachmentValidate {
@Resource
@Autowired
protected LocaleMessageUtil localeMessageUtil;
/**
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.customer.data.bo.AddBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Objects;
/**
* @Author mt
* @Description 运单信息校验
* @Date 2024/11/6
*/
@Component
public class ConsignmentInfoValidate {
@Autowired
protected LocaleMessageUtil localeMessageUtil;
/**
* @Author mt
* @Description 验证运单ID是否为空
* @Date 2024/11/6
* @param consignmentId
* @return void
*/
public void validateConsignmentId(Long consignmentId){
if (Objects.isNull(consignmentId)){
ResponseVo rsVo = ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.REQUEST_PARAM_NULL.getMsg()));
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg());
}
}
}
......@@ -4,11 +4,10 @@ import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.customer.data.bo.AddBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
/**
* @Author Szl
* @Description 类说明 运单校验类
......@@ -16,7 +15,7 @@ import javax.annotation.Resource;
*/
@Component
public class ConsignmentValidate {
@Resource
@Autowired
protected LocaleMessageUtil localeMessageUtil;
/**
......
conl_cus_declare_count_max=單次最多可查詢1000個運單號碼
#authentication包
auth_exc_no_auth=沒有訪問許可權
auth_exc_no_pass_auth=沒有通過許可權認證
auth_filter_user_error=登錄身份異常
auth_filter_timeout=登錄超過8小時,請重新登錄
auth_filter_stale_dated=登錄已過期
enum_res_code_301=登錄身份異常
enum_res_code_305=登錄已過期,請重新登錄
......
......@@ -63,7 +63,7 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
//返回客户端发出请求完整URL
String reqeustUrl = request.getRequestURL().toString();
logger.info("------------- FROM NETWORK :{}", requestUri);
if (reqeustUrl.indexOf("/sysUser/logout") > 0) {
if (reqeustUrl.indexOf("/user/logout") > 0) {
//退出登录接口,不验token
chain.doFilter(request, response);
return;
......
package com.fedex.connect.common.dependencies.common;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
/**
* @Author mt
* @Description controller基础类
* @Date 2024/11/6
*/
public class BasicController {
public User getUserInfo(LocaleMessageUtil localeMessageUtil){
User user;
try {
user = CurrentUserInfo.getUser();
} catch (Exception e) {
ResponseVo rsVo = ResponseVo.fail(ResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()),null);
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg(),e);
}
if (user == null) {
ResponseVo rsVo = ResponseVo.fail(ResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(ResponseCode.OVERDUE_TOKEN_CODE.getMsg()),null);
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg());
}
return user;
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ package com.fedex.connect.common.dependencies.contants;
*/
public class RedisConstants {
public static final String REDIS_KEY_TOKEN = "tw_user:token:";
public static final String REDIS_KEY_TOKEN = "user:token:";
public static final int REDIS_EXPIRE_TIME_2H = 7200;
public static final int REDIS_EXPIRE_TIME_8H = 28800;
......
......@@ -56,6 +56,10 @@ public enum ResponseCode {
CONSIGNMENT_CREATOR_ERR(601,"enum_res_code_601"),
CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC(602,"enum_res_code_602"),
CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC(603,"enum_res_code_603"),
//********************biz_customer模块
//********************manager-server模块
;
private Integer code;
private String msg;
......
package com.fedex.connect.manager.controller.base;
import com.fedex.connect.common.dependencies.common.BasicController;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.config.PropertiesConfig;
import com.fedex.connect.manager.service.bi.IDicEntriesService;
import com.fedex.connect.manager.service.log.ILogLoginService;
......@@ -14,7 +16,7 @@ import javax.annotation.Resource;
/**
* @author EDY
*/
public class BaseController {
public class BaseController extends BasicController {
@Resource
protected LocaleMessageUtil localeMessageUtil;
@Autowired
......@@ -27,4 +29,9 @@ public class BaseController {
protected ILogLoginService logLoginService;
@Autowired
protected IDicEntriesService dicEntriesService;
public User getCurrentUserInfo(){
User user = this.getUserInfo(localeMessageUtil);
return user;
}
}
......
#authentication包
auth_exc_no_auth=沒有訪問許可權
auth_exc_no_pass_auth=沒有通過許可權認證
auth_filter_user_error=登錄身份異常
auth_filter_timeout=登錄超過8小時,請重新登錄
auth_filter_stale_dated=登錄已過期
\ No newline at end of file
......
package com.fedex.connect.task.job;
import com.fedex.connect.task.annotation.ProcessingTime;
import com.fedex.connect.task.service.sys.IRedisSlabExtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @Author mt
* @Description 基础定时任务,存放系统相关操作,与具体业务无关
* @Date 2024/11/6
*/
@Component
public class BaseJob {
@Autowired
protected IRedisSlabExtService redisUtilService;
/**
* 30秒一次作废失效token
*/
@ProcessingTime
@Scheduled(cron="0/30 * * * * ?")
public void validRedisMsgJob(){
redisUtilService.validRedisMsg();
}
}
......@@ -3,16 +3,18 @@ package com.fedex.connect.task.repository.base;
import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper;
import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper;
import com.fedex.connect.task.repository.dao.KafkaTemporaryStorageMapperExt;
import com.fedex.connect.task.repository.dao.RedisSlabMapperExt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class AbstractDaoRepository {
protected Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
protected KafkaTemporaryStorageMapperExt kafkaTemporaryStorageMapperExt;
@Autowired
protected KafkaTemporaryStorageMapper kafkaTemporaryStorageMapper;
@Autowired
protected KafkaStorageHistoryMapper kafkaStorageHistoryMapper;
@Autowired
protected RedisSlabMapperExt redisSlabMapperExt;
}
\ No newline at end of file
......
package com.fedex.connect.task.repository.dao;
import com.fedex.connect.common.model.sys.RedisSlab;
import org.apache.ibatis.annotations.Mapper;
import java.util.Date;
import java.util.List;
@Mapper
public interface RedisSlabMapperExt {
List<RedisSlab> findValidRedisMsgList(Date curDate);
}
\ No newline at end of file
<?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.fedex.connect.task.repository.dao.RedisSlabMapperExt">
<resultMap id="BaseResultMap" type="com.fedex.connect.common.model.sys.RedisSlab">
<id column="ID" jdbcType="NUMERIC" property="id" />
<result column="REDIS_KEY" jdbcType="VARCHAR" property="redisKey" />
<result column="REDIS_MSG" jdbcType="VARCHAR" property="redisMsg" />
<result column="VALID_DURATION" jdbcType="NUMERIC" property="validDuration" />
<result column="DIS_TIME" jdbcType="TIMESTAMP" property="disTime" />
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
ID, REDIS_KEY, REDIS_MSG, VALID_DURATION, DIS_TIME, CREATE_TIME
</sql>
<select id="findValidRedisMsgList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" /> FROM T_REDIS_SLAB WHERE DIS_TIME &lt; #{curDate,jdbcType=TIMESTAMP}
</select>
</mapper>
\ No newline at end of file
package com.fedex.connect.task.repository.repo;
package com.fedex.connect.task.repository.repo.sys;
import com.fedex.connect.common.model.sys.KafkaStorageHistory;
......
package com.fedex.connect.task.repository.repo;
package com.fedex.connect.task.repository.repo.sys;
import com.fedex.connect.common.model.sys.KafkaTemporaryStorage;
......
package com.fedex.connect.task.repository.repo.sys;
import com.fedex.connect.common.model.sys.RedisSlab;
import java.util.Date;
import java.util.List;
public interface IRedisSlabExtRepository {
List<RedisSlab> findValidRedisMsgList(Date curDate);
}
\ No newline at end of file
package com.fedex.connect.task.repository.repo.impl;
package com.fedex.connect.task.repository.repo.sys.impl;
import com.fedex.connect.common.model.sys.KafkaStorageHistory;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaStorageHistoryRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
......
package com.fedex.connect.task.repository.repo.impl;
package com.fedex.connect.task.repository.repo.sys.impl;
import com.fedex.connect.common.model.sys.KafkaTemporaryStorage;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.IKafkaTemporaryStorageRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaTemporaryStorageRepository;
import org.springframework.stereotype.Repository;
import java.util.Date;
......
package com.fedex.connect.task.repository.repo.sys.impl;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.sys.IRedisSlabExtRepository;
import java.util.Date;
import java.util.List;
/**
* @Author mt
* @Description redis平替操作类
* @Date 2024/11/6
*/
public class RedisSlabExtRepositoryImpl extends AbstractDaoRepository implements IRedisSlabExtRepository {
/**
* @Author mt
* @Description 根据日期查找有效用户信息
* @Date 2024/11/6
* @param curDate
* @return java.util.List<com.fedex.connect.common.model.sys.RedisSlab>
*/
public List<RedisSlab> findValidRedisMsgList(Date curDate){
return redisSlabMapperExt.findValidRedisMsgList(curDate);
}
}
package com.fedex.connect.task.service.base;
import com.fedex.connect.task.repository.repo.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.IKafkaTemporaryStorageRepository;
import com.fedex.connect.common.dependencies.repository.repo.sys.IRedisSlabRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaTemporaryStorageRepository;
import com.fedex.connect.task.repository.repo.sys.IRedisSlabExtRepository;
import org.springframework.beans.factory.annotation.Autowired;
/**
......@@ -14,4 +16,8 @@ public class BaseService {
protected IKafkaTemporaryStorageRepository kafKaTemporaryStorageRepository;
@Autowired
protected IKafkaStorageHistoryRepository kafkaStorageHistoryRepository;
@Autowired
protected IRedisSlabRepository redisSlabRepository;
@Autowired
protected IRedisSlabExtRepository redisRepository;
}
\ No newline at end of file
......
package com.fedex.connect.task.service.sys;
import com.fedex.connect.common.model.sys.RedisSlab;
import java.util.List;
public interface IRedisSlabExtService {
void validRedisMsg();
}
package com.fedex.connect.task.service.sys.impl;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.task.service.base.BaseService;
import com.fedex.connect.task.service.sys.IRedisSlabExtService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
@Slf4j
@Service
public class RedisSlabExtServiceImpl extends BaseService implements IRedisSlabExtService {
/**
* 查询已经失效的数据
* @return
*/
@Override
public void validRedisMsg(){
Date curDate = new Date();
List<RedisSlab> redisSlabList = redisRepository.findValidRedisMsgList(curDate);
if (CollectionUtils.isEmpty(redisSlabList)){
return;
}
Optional.ofNullable(redisSlabList).orElse(new ArrayList<>()).stream().filter(Objects::nonNull).map(RedisSlab::getId)
.distinct().forEach(id ->{
log.info("定时作废RedisSlab-id:{}",id);
redisSlabRepository.deleteByPrimaryKey(id);
});
}
}
......@@ -6,8 +6,8 @@ import com.fedex.connect.common.dependencies.util.RPCUtils;
import com.fedex.connect.common.model.sys.KafkaStorageHistory;
import com.fedex.connect.common.model.sys.KafkaTemporaryStorage;
import com.fedex.connect.task.config.PropertiesConfig;
import com.fedex.connect.task.repository.repo.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.IKafkaTemporaryStorageRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaTemporaryStorageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......