diff --git a/baogutang-admin/src/main/java/top/baogutang/admin/BaogutangAdminApplication.java b/baogutang-admin/src/main/java/top/baogutang/admin/BaoGuTangAdminApplication.java similarity index 86% rename from baogutang-admin/src/main/java/top/baogutang/admin/BaogutangAdminApplication.java rename to baogutang-admin/src/main/java/top/baogutang/admin/BaoGuTangAdminApplication.java index 199e4fa..ef1f001 100644 --- a/baogutang-admin/src/main/java/top/baogutang/admin/BaogutangAdminApplication.java +++ b/baogutang-admin/src/main/java/top/baogutang/admin/BaoGuTangAdminApplication.java @@ -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后台管理服务启动成功!!!==>>>>>>>>>>>>>>>"); } diff --git a/baogutang-admin/src/main/java/top/baogutang/admin/schedule/NoticeSchedule.java b/baogutang-admin/src/main/java/top/baogutang/admin/schedule/NoticeSchedule.java index c717b66..67e5091 100644 --- a/baogutang-admin/src/main/java/top/baogutang/admin/schedule/NoticeSchedule.java +++ b/baogutang-admin/src/main/java/top/baogutang/admin/schedule/NoticeSchedule.java @@ -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> results = OkHttpUtil.get(EDGE_X_REQUEST_URL, null, null, new TypeReference>>() { - }); - 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 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![](" + announcementsDto.getCover() + ")\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> results = OkHttpUtil.get(EDGE_REQUEST_URL, null, null, new TypeReference>>() { - }); + Arrays.stream(NoticeTypeEnum.values()) + .forEach(noticeType -> { + Results> results = OkHttpUtil.get(noticeType.getListUrl(), null, null, new TypeReference>>() { + }); + 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 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![](" + announcementsDto.getCover() + ")\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 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![](" + announcementsDto.getCover() + ")\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()); } } diff --git a/baogutang-admin/src/test/java/top/baogutang/business/admin/BaogutangAdminAbstractTest.java b/baogutang-admin/src/test/java/top/baogutang/business/admin/BaoGuTangAdminAbstractTest.java similarity index 66% rename from baogutang-admin/src/test/java/top/baogutang/business/admin/BaogutangAdminAbstractTest.java rename to baogutang-admin/src/test/java/top/baogutang/business/admin/BaoGuTangAdminAbstractTest.java index 65ac9c4..cd7ca46 100644 --- a/baogutang-admin/src/test/java/top/baogutang/business/admin/BaogutangAdminAbstractTest.java +++ b/baogutang-admin/src/test/java/top/baogutang/business/admin/BaoGuTangAdminAbstractTest.java @@ -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 { } \ No newline at end of file diff --git a/baogutang-business/src/main/java/top/baogutang/business/BaogutangBusinessApplication.java b/baogutang-business/src/main/java/top/baogutang/business/BaoGuTangBusinessApplication.java similarity index 85% rename from baogutang-business/src/main/java/top/baogutang/business/BaogutangBusinessApplication.java rename to baogutang-business/src/main/java/top/baogutang/business/BaoGuTangBusinessApplication.java index 5621958..6cc0644 100644 --- a/baogutang-business/src/main/java/top/baogutang/business/BaogutangBusinessApplication.java +++ b/baogutang-business/src/main/java/top/baogutang/business/BaoGuTangBusinessApplication.java @@ -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客户端服务启动成功!!!==>>>>>>>>>>>>>>>"); } } diff --git a/baogutang-common/src/main/java/top/baogutang/common/constants/NoticeTypeEnum.java b/baogutang-common/src/main/java/top/baogutang/common/constants/NoticeTypeEnum.java index 57e2d8b..83d835f 100644 --- a/baogutang-common/src/main/java/top/baogutang/common/constants/NoticeTypeEnum.java +++ b/baogutang-common/src/main/java/top/baogutang/common/constants/NoticeTypeEnum.java @@ -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; + } } diff --git a/baogutang-common/src/main/java/top/baogutang/common/controller/CheckServerController.java b/baogutang-common/src/main/java/top/baogutang/common/controller/CheckServerController.java index b15a73d..60a8b72 100644 --- a/baogutang-common/src/main/java/top/baogutang/common/controller/CheckServerController.java +++ b/baogutang-common/src/main/java/top/baogutang/common/controller/CheckServerController.java @@ -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