| | |
| | | package com.xiaopeng.operation.utils.task; |
| | | |
| | | import com.xiaopeng.api.model.operation.XpBanner; |
| | | import com.xiaopeng.api.vo.operation.XpLogMessage; |
| | | import com.xiaopeng.common.core.constant.CacheConstants; |
| | | import com.xiaopeng.operation.service.XpBannerService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author 无关风月 |
| | |
| | | |
| | | @Autowired |
| | | private XpBannerService bannerService; |
| | | |
| | | @Resource |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除移动端日志 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void removeLogMessage() { |
| | | //删除大于2天的日志记录 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime twoDayAgo = now.minusDays(2); |
| | | mongoTemplate.remove(new Query(Criteria.where("timestamp").lt(twoDayAgo.toEpochSecond(ZoneOffset.of("+8")))), XpLogMessage.class); |
| | | } |
| | | } |