query data base rather than redis
This commit is contained in:
parent
8174d29f4b
commit
a324ef502f
@ -8,6 +8,7 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.baogutang.admin.dao.entity.NoticeLogEntity;
|
||||
import top.baogutang.admin.domain.AnnouncementsDto;
|
||||
import top.baogutang.admin.services.INoticeLogService;
|
||||
import top.baogutang.admin.services.IWxMsgPushService;
|
||||
@ -19,6 +20,7 @@ import top.baogutang.common.properties.WxMsgPushProperties;
|
||||
import top.baogutang.common.utils.OkHttpUtil;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -70,10 +72,9 @@ public class NoticeSchedule {
|
||||
return;
|
||||
}
|
||||
AnnouncementsDto announcementsDto = results.getData().getList().get(0);
|
||||
String cacheKey = String.format(MSG_PUSH_PREFIX_KEY, "edge_x", announcementsDto.getId());
|
||||
|
||||
Boolean result = redisTemplate.opsForValue().setIfAbsent(cacheKey, 1, 5, TimeUnit.DAYS);
|
||||
if (!Boolean.TRUE.equals(result)) {
|
||||
List<NoticeLogEntity> noticeLogList = noticeLogService.queryLogByConditions(announcementsDto.getId(), NoticeTypeEnum.EDGE_X);
|
||||
if (CollectionUtils.isNotEmpty(noticeLogList)) {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
@ -103,10 +104,9 @@ public class NoticeSchedule {
|
||||
return;
|
||||
}
|
||||
AnnouncementsDto announcementsDto = results.getData().getList().get(0);
|
||||
String cacheKey = String.format(MSG_PUSH_PREFIX_KEY, "edge", announcementsDto.getId());
|
||||
|
||||
Boolean result = redisTemplate.opsForValue().setIfAbsent(cacheKey, 1, 5, TimeUnit.DAYS);
|
||||
if (!Boolean.TRUE.equals(result)) {
|
||||
List<NoticeLogEntity> noticeLogList = noticeLogService.queryLogByConditions(announcementsDto.getId(), NoticeTypeEnum.EDGE);
|
||||
if (CollectionUtils.isNotEmpty(noticeLogList)) {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package top.baogutang.admin.services;
|
||||
|
||||
import top.baogutang.admin.dao.entity.NoticeLogEntity;
|
||||
import top.baogutang.common.constants.NoticeTypeEnum;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
@ -24,4 +26,14 @@ public interface INoticeLogService {
|
||||
* @param noticeCreatedAt 公告创建时间
|
||||
*/
|
||||
void saveNotice(NoticeTypeEnum noticeType, Long noticeId, String type, String title, String coverUrl, String detailUrl, String noticeCreator, Date noticeCreatedAt);
|
||||
|
||||
/**
|
||||
* 根据notice id 和 notice type 查询未删除的数据
|
||||
*
|
||||
* @param noticeId notice id
|
||||
* @param noticeType notice type
|
||||
* @return notice数据
|
||||
*/
|
||||
List<NoticeLogEntity> queryLogByConditions(Long noticeId, NoticeTypeEnum noticeType);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package top.baogutang.admin.services.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@ -12,6 +13,7 @@ import top.baogutang.common.constants.NoticeTypeEnum;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
@ -40,4 +42,13 @@ public class NoticeLogServiceImpl extends ServiceImpl<NoticeLogMapper, NoticeLog
|
||||
noticeLog.setNoticeCreatedAt(noticeCreatedAt);
|
||||
noticeLogMapper.insert(noticeLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NoticeLogEntity> queryLogByConditions(Long noticeId, NoticeTypeEnum noticeType) {
|
||||
return new LambdaQueryChainWrapper<>(noticeLogMapper)
|
||||
.eq(NoticeLogEntity::getNoticeId, noticeId)
|
||||
.eq(NoticeLogEntity::getNoticeType, noticeType.getDesc())
|
||||
.eq(NoticeLogEntity::getDeleted, Boolean.FALSE)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +110,7 @@ var JSONFormat = (function(){
|
||||
'.json_null{color: #f1592a;font-weight:bold;}',
|
||||
'.json_string{ color: #3ab54a;font-weight:bold;}',
|
||||
'.json_number{ color: #25aae2;font-weight:bold;}',
|
||||
'.json_boolean{ color: #ffa500;font-weight:bold;}',
|
||||
'.json_link{ color: #717171;font-weight:bold;}',
|
||||
'.json_array_brackets{}');
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user