upgrade
This commit is contained in:
parent
c18c82aeb0
commit
c7309445e0
@ -13,10 +13,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@EnableScheduling
|
||||
@SpringBootApplication(scanBasePackages = "top.baogutang.*")
|
||||
@MapperScan(basePackages = {"top.baogutang.admin.dao.mapper", "top.baogutang.common.dao.mapper"})
|
||||
public class BaogutangAdminApplication {
|
||||
public class BaoGuTangAdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BaogutangAdminApplication.class, args);
|
||||
SpringApplication.run(BaoGuTangAdminApplication.class, args);
|
||||
log.info("<<<<<<<<<<<<<<<==BAO_GU_TANG后台管理服务启动成功!!!==>>>>>>>>>>>>>>>");
|
||||
}
|
||||
|
||||
@ -20,11 +20,10 @@ import top.baogutang.common.properties.WxMsgPushProperties;
|
||||
import top.baogutang.common.utils.OkHttpUtil;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static top.baogutang.common.constants.CacheConstant.MSG_PUSH_PREFIX_KEY;
|
||||
|
||||
/**
|
||||
* @description: EDGEX公告
|
||||
@ -51,68 +50,36 @@ public class NoticeSchedule {
|
||||
@Resource
|
||||
private INoticeLogService noticeLogService;
|
||||
|
||||
private static final String EDGE_X_REQUEST_URL = "https://art-api.edge-x.cn/api/v1/art/announcements?pageNum=1&pageSize=1";
|
||||
private static final String EDGE_REQUEST_URL = "https://art-api.heishiapp.com/api/v1/art/announcements?pageNum=1&pageSize=1";
|
||||
|
||||
/**
|
||||
* 每分钟查询edgeX公告
|
||||
*/
|
||||
@Scheduled(cron = "0 0/1 * * * ? ")
|
||||
public void edgeXNotice() {
|
||||
Results<Page<AnnouncementsDto>> results = OkHttpUtil.get(EDGE_X_REQUEST_URL, null, null, new TypeReference<Results<Page<AnnouncementsDto>>>() {
|
||||
});
|
||||
log.info(">>>>>>>>>>请求获取edgeX公告返回数据:{}<<<<<<<<<<", JSON.toJSONString(results));
|
||||
if (Objects.isNull(results)) {
|
||||
return;
|
||||
}
|
||||
if (!Boolean.TRUE.equals(results.isSuccess())) {
|
||||
return;
|
||||
}
|
||||
if (Objects.isNull(results.getData()) || CollectionUtils.isEmpty(results.getData().getList())) {
|
||||
return;
|
||||
}
|
||||
AnnouncementsDto announcementsDto = results.getData().getList().get(0);
|
||||
|
||||
List<NoticeLogEntity> noticeLogList = noticeLogService.queryLogByConditions(announcementsDto.getId(), NoticeTypeEnum.EDGE_X);
|
||||
if (CollectionUtils.isNotEmpty(noticeLogList)) {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
String content = "# EDGE-X-" + announcementsDto.getTitle() + "\n\n + ")\n\n>";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), "查看详情", "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId(), content);
|
||||
// wxMsgPushService.msgPush(Message.CONTENT_TYPE_HTML, announcementsDto.getTitle(), announcementsDto.getContent(), wxMsgPushProperties.getTopicIds());
|
||||
noticeLogService.saveNotice(NoticeTypeEnum.EDGE_X, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 每分钟查询edge公告
|
||||
*/
|
||||
@Scheduled(cron = "0 0/1 * * * ? ")
|
||||
public void edgeNotice() {
|
||||
Results<Page<AnnouncementsDto>> results = OkHttpUtil.get(EDGE_REQUEST_URL, null, null, new TypeReference<Results<Page<AnnouncementsDto>>>() {
|
||||
});
|
||||
Arrays.stream(NoticeTypeEnum.values())
|
||||
.forEach(noticeType -> {
|
||||
Results<Page<AnnouncementsDto>> results = OkHttpUtil.get(noticeType.getListUrl(), null, null, new TypeReference<Results<Page<AnnouncementsDto>>>() {
|
||||
});
|
||||
log.info(">>>>>>>>>>请求获取:{}公告返回数据:{}<<<<<<<<<<", noticeType.getDesc(), JSON.toJSONString(results));
|
||||
if (Objects.isNull(results)) {
|
||||
return;
|
||||
}
|
||||
if (!Boolean.TRUE.equals(results.isSuccess())) {
|
||||
return;
|
||||
}
|
||||
if (Objects.isNull(results.getData()) || CollectionUtils.isEmpty(results.getData().getList())) {
|
||||
return;
|
||||
}
|
||||
AnnouncementsDto announcementsDto = results.getData().getList().get(0);
|
||||
List<NoticeLogEntity> noticeLogList = noticeLogService.queryLogByConditions(announcementsDto.getId(), noticeType);
|
||||
if (CollectionUtils.isNotEmpty(noticeLogList)) {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
String content = noticeType.getTitle() + announcementsDto.getTitle() + "\n\n + ")\n\n>";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), "查看详情", noticeType.getDetailUrl() + announcementsDto.getId(), content);
|
||||
noticeLogService.saveNotice(noticeType, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), noticeType.getDetailUrl() + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
|
||||
});
|
||||
|
||||
log.info(">>>>>>>>>>请求获取edge公告返回数据:{}<<<<<<<<<<", JSON.toJSONString(results));
|
||||
if (Objects.isNull(results)) {
|
||||
return;
|
||||
}
|
||||
if (!Boolean.TRUE.equals(results.isSuccess())) {
|
||||
return;
|
||||
}
|
||||
if (Objects.isNull(results.getData()) || CollectionUtils.isEmpty(results.getData().getList())) {
|
||||
return;
|
||||
}
|
||||
AnnouncementsDto announcementsDto = results.getData().getList().get(0);
|
||||
|
||||
List<NoticeLogEntity> noticeLogList = noticeLogService.queryLogByConditions(announcementsDto.getId(), NoticeTypeEnum.EDGE);
|
||||
if (CollectionUtils.isNotEmpty(noticeLogList)) {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
String content = "# EDGE-" + announcementsDto.getTitle() + "\n\n + ")\n\n>";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), "查看详情", "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=" + announcementsDto.getId(), content);
|
||||
// wxMsgPushService.msgPush(Message.CONTENT_TYPE_HTML, announcementsDto.getTitle(), announcementsDto.getContent(), wxMsgPushProperties.getTopicIds());
|
||||
noticeLogService.saveNotice(NoticeTypeEnum.EDGE, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=" + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,10 +4,10 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import top.baogutang.admin.BaogutangAdminApplication;
|
||||
import top.baogutang.admin.BaoGuTangAdminApplication;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = BaogutangAdminApplication.class)
|
||||
@SpringBootTest(classes = BaoGuTangAdminApplication.class)
|
||||
@ActiveProfiles("local")
|
||||
public abstract class BaogutangAdminAbstractTest {
|
||||
public abstract class BaoGuTangAdminAbstractTest {
|
||||
}
|
||||
@ -13,10 +13,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@Slf4j
|
||||
@SpringBootApplication(scanBasePackages = "top.baogutang.*")
|
||||
@MapperScan(basePackages = {"top.baogutang.business.dao.mapper", "top.baogutang.common.dao.mapper"})
|
||||
public class BaogutangBusinessApplication {
|
||||
public class BaoGuTangBusinessApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BaogutangBusinessApplication.class, args);
|
||||
SpringApplication.run(BaoGuTangBusinessApplication.class, args);
|
||||
log.info("<<<<<<<<<<<<<<<==BAO_GU_TANG客户端服务启动成功!!!==>>>>>>>>>>>>>>>");
|
||||
}
|
||||
}
|
||||
@ -10,21 +10,30 @@ public enum NoticeTypeEnum {
|
||||
/**
|
||||
* edge
|
||||
*/
|
||||
EDGE(1, "edge"),
|
||||
EDGE(1, "edge", "https://art-api.heishiapp.com/api/v1/art/announcements?pageNum=1&pageSize=1", "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=", "# EDGE-"),
|
||||
|
||||
/**
|
||||
* edgeX
|
||||
*/
|
||||
EDGE_X(2, "edgeX"),
|
||||
EDGE_X(2, "edgeX", "https://art-api.edge-x.cn/api/v1/art/announcements?pageNum=1&pageSize=1", "https://app.edge-x.cn/#/noticeDetail?noticeId=", "# EDGE-X-"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String desc;
|
||||
|
||||
NoticeTypeEnum(Integer code, String desc) {
|
||||
private final String listUrl;
|
||||
|
||||
private final String detailUrl;
|
||||
|
||||
private final String title;
|
||||
|
||||
NoticeTypeEnum(Integer code, String desc, String listUrl, String detailUrl, String title) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
this.listUrl = listUrl;
|
||||
this.detailUrl = detailUrl;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
@ -34,4 +43,16 @@ public enum NoticeTypeEnum {
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getListUrl() {
|
||||
return listUrl;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDetailUrl() {
|
||||
return detailUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,9 +7,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import top.baogutang.common.domain.Results;
|
||||
|
||||
/**
|
||||
* @author:lichao
|
||||
* @author:niko
|
||||
* @desc: 心跳检测
|
||||
* @time 2022年4月5日21:56:58
|
||||
* @time 2023年12月5日21:56:58
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
||||
Loading…
Reference in New Issue
Block a user