From 4aa1832301c3111abe5daf81466187643efadf28 Mon Sep 17 00:00:00 2001 From: sunflower2014 Date: Fri, 28 Nov 2025 19:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E8=A7=84=E5=88=99=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reference/admin/AdminApplication.java | 2 +- .../admin/controller/NewsController.java | 30 +++- .../admin/job/NewsCompanyCollectJob.java | 54 +++++++ .../admin/job/NewsDeduplicationJob.java | 1 - .../admin/job/NewsSignalRuleCheckJob.java | 39 +++++ .../job/NewsTagsIndustryLabelRepairJob.java | 2 +- .../admin/mapper/AdminUserMapper.java | 2 +- admin/src/main/resources/application.yml | 15 +- admin/src/main/resources/sql/20251111.sql | 2 + .../reference/core/mapper/IndustryMapper.java | 26 ++-- .../core/mapper/ListedCompanyMapper.java | 44 ++++++ .../reference/core/mapper/NewsMapper.java | 140 +++++++++++++----- .../core/mapper/NewsSignalRuleRelMapper.java | 33 +++++ .../core/mapper/SignalRuleMapper.java | 24 +++ .../reference/core/mapper/TagMapper.java | 41 +++-- .../core/mapper/UserOperationLogMapper.java | 5 +- .../core/model/dto/news/SaveNewsDTO.java | 19 +++ .../core/model/entity/ListedCompany.java | 42 ++++++ .../reference/core/model/entity/News.java | 21 +++ .../core/model/entity/NewsSignalRuleRel.java | 49 ++++++ .../core/model/entity/SignalRule.java | 49 ++++++ .../core/model/vo/news/NewsDetailVO.java | 11 ++ .../reference/core/model/vo/news/NewsVO.java | 88 ++++++++++- .../core/model/vo/news/SignalRuleVO.java | 19 +++ .../core/service/NewsInfoService.java | 25 ++++ .../reference/core/service/NewsService.java | 104 ++++++++----- 26 files changed, 771 insertions(+), 116 deletions(-) create mode 100644 admin/src/main/java/com/jinrui/reference/admin/job/NewsCompanyCollectJob.java create mode 100644 admin/src/main/java/com/jinrui/reference/admin/job/NewsSignalRuleCheckJob.java create mode 100644 admin/src/main/resources/sql/20251111.sql create mode 100644 core/src/main/java/com/jinrui/reference/core/mapper/ListedCompanyMapper.java create mode 100644 core/src/main/java/com/jinrui/reference/core/mapper/NewsSignalRuleRelMapper.java create mode 100644 core/src/main/java/com/jinrui/reference/core/mapper/SignalRuleMapper.java create mode 100644 core/src/main/java/com/jinrui/reference/core/model/entity/ListedCompany.java create mode 100644 core/src/main/java/com/jinrui/reference/core/model/entity/NewsSignalRuleRel.java create mode 100644 core/src/main/java/com/jinrui/reference/core/model/entity/SignalRule.java create mode 100644 core/src/main/java/com/jinrui/reference/core/model/vo/news/SignalRuleVO.java diff --git a/admin/src/main/java/com/jinrui/reference/admin/AdminApplication.java b/admin/src/main/java/com/jinrui/reference/admin/AdminApplication.java index 5c8603e..6a734ae 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/AdminApplication.java +++ b/admin/src/main/java/com/jinrui/reference/admin/AdminApplication.java @@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.scheduling.annotation.EnableScheduling; + @SpringBootApplication(scanBasePackages = { "com.jinrui.reference.admin", "com.jinrui.reference.core" @@ -16,7 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling @EnableAspectJAutoProxy(proxyTargetClass = true) public class AdminApplication { - public static void main(String[] args) { SpringApplication.run(AdminApplication.class, args); } diff --git a/admin/src/main/java/com/jinrui/reference/admin/controller/NewsController.java b/admin/src/main/java/com/jinrui/reference/admin/controller/NewsController.java index 243231b..a1f68bc 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/controller/NewsController.java +++ b/admin/src/main/java/com/jinrui/reference/admin/controller/NewsController.java @@ -1,10 +1,13 @@ package com.jinrui.reference.admin.controller; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.apache.ibatis.annotations.Param; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.DeleteMapping; @@ -23,6 +26,8 @@ import com.jinrui.reference.admin.model.dto.news.PublishNewsDTO; import com.jinrui.reference.admin.model.entity.AdminUser; import com.jinrui.reference.admin.service.AdminJwtService; import com.jinrui.reference.core.model.dto.news.SaveNewsDTO; +import com.jinrui.reference.core.model.entity.ListedCompany; +import com.jinrui.reference.core.model.entity.SignalRule; import com.jinrui.reference.core.model.vo.PageObject; import com.jinrui.reference.core.model.vo.ResultObject; import com.jinrui.reference.core.model.vo.news.NewsDetailVO; @@ -30,6 +35,7 @@ import com.jinrui.reference.core.model.vo.news.NewsLogVO; import com.jinrui.reference.core.model.vo.news.NewsScoreVO; import com.jinrui.reference.core.model.vo.news.NewsTranslatorVO; import com.jinrui.reference.core.model.vo.news.NewsVO; +import com.jinrui.reference.core.model.vo.news.SignalRuleVO; import com.jinrui.reference.core.service.NewsService; import redis.clients.jedis.Jedis; @@ -321,6 +327,10 @@ public class NewsController { @RequestParam(value = "dateline_to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date datelineTo, @RequestParam(value = "deleted", required = false) Integer deleted, @RequestParam(value = "rating", required = false) Byte rating, + @RequestParam(value = "exclusive", required = false) Integer exclusive, + @RequestParam(value = "includeRuleIds", required = false) String includeRuleIds, + @RequestParam(value = "excludeRuleIds", required = false) String excludeRuleIds, + @RequestParam(value = "companyName", required = false) String companyName, @RequestParam(value = "range", required = false, defaultValue = "all") String range ) { if (!StringUtils.hasText(token)) { @@ -356,7 +366,7 @@ public class NewsController { } isSecondReviewRange = true; } - return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, minScore, maxScore, tag, industry, mediaId, datelineFrom, datelineTo, deleted, rating, isReviewRange, isSecondReviewRange); + return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, minScore, maxScore, tag, industry, mediaId, datelineFrom, datelineTo, deleted, rating, exclusive, isReviewRange, isSecondReviewRange, includeRuleIds, excludeRuleIds, companyName); } catch (Exception e) { log.error("解析登陆Token出错!", e); return PageObject.failedPage(500, "服务端错误,请联系系统管理员!"); @@ -523,6 +533,24 @@ public class NewsController { } } + @GetMapping("/getSignalRulesList") + public ResultObject> getSignalRulesList() { + List signalRules = newsService.getSignalRulesList(); + List signalRulesList = new ArrayList<>(signalRules.size()); + for (SignalRule signalRule: signalRules) { + SignalRuleVO signalRuleVO = new SignalRuleVO(); + BeanUtils.copyProperties(signalRule, signalRuleVO); + signalRulesList.add(signalRuleVO); + } + return ResultObject.success(signalRulesList); + } + + @GetMapping("/getCompanyNames") + public ResultObject> getCompanyNames(@Param("companyName") String companyName) { + List listedCompanyList = newsService.getAllListedCompany(companyName); + return ResultObject.success(listedCompanyList); + } + /** * * @param newsId diff --git a/admin/src/main/java/com/jinrui/reference/admin/job/NewsCompanyCollectJob.java b/admin/src/main/java/com/jinrui/reference/admin/job/NewsCompanyCollectJob.java new file mode 100644 index 0000000..b26939a --- /dev/null +++ b/admin/src/main/java/com/jinrui/reference/admin/job/NewsCompanyCollectJob.java @@ -0,0 +1,54 @@ +package com.jinrui.reference.admin.job; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import com.jinrui.reference.core.mapper.ListedCompanyMapper; +import com.jinrui.reference.core.mapper.NewsMapper; +import com.jinrui.reference.core.model.entity.ListedCompany; +import com.jinrui.reference.core.model.entity.News; + +@Component +public class NewsCompanyCollectJob { + @Autowired + private ListedCompanyMapper listedCompanyMappr; + @Autowired + private NewsMapper newsMapper; + + @Scheduled(fixedDelay=5, initialDelay=0, timeUnit = TimeUnit.MINUTES) + public void collectNewsCompany() { + ListedCompany listdCompany = listedCompanyMappr.getLastCollectedCompany(); + List newsList = newsMapper.getCompanyRelatedNews(listdCompany.getCollectTime()); + for (News news: newsList) { + String companyNameStr = news.getCompanyName(); + String[] companyNames = companyNameStr.split("[,|、|;]"); + if (companyNames.length > 1) { + for (String companyName: companyNames) { + listedCompanyMappr.saveNewsCompany(companyName.trim(), news.getCreateTime()); + } + continue; + } + if (companyNameStr.contains("和")) { + String[] companyNames2 = companyNameStr.split("和"); + boolean existed = false; + for (String companyName:companyNames2) { + ListedCompany listedCompany = listedCompanyMappr.getByCompanyName(companyName); + if (listedCompany != null) { + existed = true; + } + } + if (existed) { + for (String companyName:companyNames2) { + listedCompanyMappr.saveNewsCompany(companyName.trim(), news.getCreateTime()); + } + continue; + } + } + listedCompanyMappr.saveNewsCompany(companyNameStr.trim(), news.getCreateTime()); + } + } +} diff --git a/admin/src/main/java/com/jinrui/reference/admin/job/NewsDeduplicationJob.java b/admin/src/main/java/com/jinrui/reference/admin/job/NewsDeduplicationJob.java index f9eba18..fb88d58 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/job/NewsDeduplicationJob.java +++ b/admin/src/main/java/com/jinrui/reference/admin/job/NewsDeduplicationJob.java @@ -16,7 +16,6 @@ import com.jinrui.reference.core.service.NewsService; @Component public class NewsDeduplicationJob { - @Autowired private NewsService newsService; @Autowired diff --git a/admin/src/main/java/com/jinrui/reference/admin/job/NewsSignalRuleCheckJob.java b/admin/src/main/java/com/jinrui/reference/admin/job/NewsSignalRuleCheckJob.java new file mode 100644 index 0000000..b3014eb --- /dev/null +++ b/admin/src/main/java/com/jinrui/reference/admin/job/NewsSignalRuleCheckJob.java @@ -0,0 +1,39 @@ +package com.jinrui.reference.admin.job; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import com.jinrui.reference.core.mapper.NewsMapper; +import com.jinrui.reference.core.mapper.NewsSignalRuleRelMapper; +import com.jinrui.reference.core.mapper.SignalRuleMapper; +import com.jinrui.reference.core.model.entity.News; +import com.jinrui.reference.core.model.entity.NewsSignalRuleRel; +import com.jinrui.reference.core.model.entity.SignalRule; + +@Component +public class NewsSignalRuleCheckJob { + @Autowired + private NewsSignalRuleRelMapper newsSignalRuleRelMapper; + @Autowired + private SignalRuleMapper signalRuleMapper; + @Autowired + private NewsMapper newsMapper; + + + @Scheduled(fixedDelay=5, initialDelay=0, timeUnit = TimeUnit.MINUTES) + public void checkNewsSigalRule() { + + List signalRules = signalRuleMapper.queryAll(); + NewsSignalRuleRel newsSignalRuleRel = newsSignalRuleRelMapper.getLastCheckedSignalRule(); + for (SignalRule signalRule: signalRules) { + List signalRuleNewsList = newsMapper.getSignalRuleNews(newsSignalRuleRel.getCheckTime(), signalRule.getRuleTrigger()); + for (News news: signalRuleNewsList) { + newsSignalRuleRelMapper.saveNewsSignalRuleRel(news.getId(), signalRule.getId(), news.getCreateTime()); + } + } + } +} diff --git a/admin/src/main/java/com/jinrui/reference/admin/job/NewsTagsIndustryLabelRepairJob.java b/admin/src/main/java/com/jinrui/reference/admin/job/NewsTagsIndustryLabelRepairJob.java index f1ae941..9d17788 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/job/NewsTagsIndustryLabelRepairJob.java +++ b/admin/src/main/java/com/jinrui/reference/admin/job/NewsTagsIndustryLabelRepairJob.java @@ -53,7 +53,7 @@ public class NewsTagsIndustryLabelRepairJob { @Autowired private NewsTagsMapper newsTagsMapper; -// @Scheduled(fixedDelay=15, initialDelay=0, timeUnit = TimeUnit.MINUTES) + @Scheduled(fixedDelay=15, initialDelay=0, timeUnit = TimeUnit.MINUTES) public void startToRepair() { List filters = new ArrayList<>(); filters.add(ExistsQuery.of(e -> e.field("news_tags.industry_label"))._toQuery()); diff --git a/admin/src/main/java/com/jinrui/reference/admin/mapper/AdminUserMapper.java b/admin/src/main/java/com/jinrui/reference/admin/mapper/AdminUserMapper.java index 013edf2..b6de13e 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/mapper/AdminUserMapper.java +++ b/admin/src/main/java/com/jinrui/reference/admin/mapper/AdminUserMapper.java @@ -59,7 +59,7 @@ public interface AdminUserMapper { void delete(@Param("id") long id); @Insert("") + List getByIds(@Param("ids") List ids); + @Select("select id, draft_id as draftId, industry_id as industryId " + "from draft_industry_rel where draft_id = #{draftId}") List getDraftIndustryRelList(@Param("draftId") Long draftId); @@ -77,14 +92,7 @@ public interface IndustryMapper { @Insert("insert into news_industry_rel(news_id, industry_id) values (#{newsId}, #{industryId})") void saveNewsIndustryRel(@Param("newsId") Long newsId, @Param("industryId") Long industryId); - @Results({ - @Result(column = "id", property = "id", id = true), - @Result(column = "parent_id", property = "parentId"), - @Result(column = "primary_name", property = "primaryName"), - @Result(column = "secondary_name", property = "secondaryName"), - @Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), - @Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP) - }) + @ResultMap("industryMap") @Select("") + List queryAll(@Param("companyName") String companyName); + + @ResultMap("listedCompanyMap") + @Select("select * from listed_company order by collect_time desc limit 1") + ListedCompany getLastCollectedCompany(); + + @ResultMap("listedCompanyMap") + @Select("select * from listed_company where company_name = #{companyName}") + ListedCompany getByCompanyName(@Param("companyName") String companyName); + + @Insert("insert into listed_company(company_name, collect_time, create_time, update_time) values (#{companyName}, #{newsCreateTime}, now(), now()) on duplicate key update collect_time = #{newsCreateTime}, update_time = now()") + void saveNewsCompany(@Param("companyName") String companyName, @Param("newsCreateTime") Date newsCreateTime); +} diff --git a/core/src/main/java/com/jinrui/reference/core/mapper/NewsMapper.java b/core/src/main/java/com/jinrui/reference/core/mapper/NewsMapper.java index 164e347..b02421c 100644 --- a/core/src/main/java/com/jinrui/reference/core/mapper/NewsMapper.java +++ b/core/src/main/java/com/jinrui/reference/core/mapper/NewsMapper.java @@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.type.JdbcType; import com.jinrui.reference.core.model.entity.News; import com.jinrui.reference.core.model.entity.NewsDraft; @@ -39,6 +40,7 @@ public interface NewsMapper { "update_time as updateTime, " + "is_delete as deleted, " + "rating, " + + "exclusive, " + "revision, " + "newsinfo_id as newsinfoId " + "from news where id = #{id}") @@ -58,12 +60,13 @@ public interface NewsMapper { "status = #{news.status}," + "newsinfo_id = #{news.newsinfoId}," + "rating = #{news.rating}," + + "exclusive = #{news.exclusive}," + "revision = #{news.revision}," + "update_time = now()" + "where id = #{news.id} and status = #{oldStatus}") int updateNews(News news, Integer oldStatus); - @Select("select id, draft_id as draftId, status, newsinfo_id as newsinfoId, is_delete as deleted, rating, revision from news where id = #{id}") + @Select("select id, draft_id as draftId, status, newsinfo_id as newsinfoId, is_delete as deleted, rating, exclusive, revision from news where id = #{id}") News getById(@Param("id") Long id); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -72,8 +75,8 @@ public interface NewsMapper { void saveDraft(NewsDraft newsDraft); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("insert into news(draft_id, title, summary, picture, type, content, create_time, update_time, status, publish_time, content_text, newsinfo_id, llm_title, llm_content, rating, overseas_event, overseas_macro, china_macro, industry_news, company_news, reprint_source, company_name)" + - "values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating}, #{overseasEvent}, #{overseasMacro}, #{chinaMacro}, #{industryNews}, #{companyNews}, #{reprintSource}, #{companyName})") + @Insert("insert into news(draft_id, title, summary, picture, type, content, create_time, update_time, status, publish_time, content_text, newsinfo_id, llm_title, llm_content, rating, exclusive, overseas_event, overseas_macro, china_macro, industry_news, company_news, reprint_source, company_name)" + + "values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating},#{exclusive}, #{overseasEvent}, #{overseasMacro}, #{chinaMacro}, #{industryNews}, #{companyNews}, #{reprintSource}, #{companyName})") void saveNews(News news); @Select("") int queryTotal(@Param("keywords") List keywords, @Param("minScore") Double minScore, @@ -246,8 +300,12 @@ public interface NewsMapper { @Param("datelineTo") Date datelineTo, @Param("deleted") Integer deleted, @Param("rating") Byte rating, + @Param("exclusive") Integer exclusive, @Param("isReviewer") boolean isReviewer, - @Param("isSecondReviewRange") boolean isSecondReviewRange); + @Param("isSecondReviewRange") boolean isSecondReviewRange, + @Param("includeRuleIds") List includeRuleIds, + @Param("excludeRuleIds") List excludeRuleIds, + @Param("companyName") String companyName); @Select("select id, llm_title as title, summary, picture, llm_content as content, status, " + "create_time as createTime, " + @@ -320,4 +378,20 @@ public interface NewsMapper { " limit ${limit}" + "") List queryNewsByApi(@Param("last") Long last, @Param("limit") int limit, @Param("clientType") int clientType); + + @Results({ + @Result(column = "id", property = "id", id = true), + @Result(column = "company_name", property = "companyName"), + @Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + }) + @Select("select id, company_name, create_time from news where is_delete = 0 and company_name is not null and length(company_name) > 0 and create_time > #{lastCollectTime}") + List getCompanyRelatedNews(@Param("lastCollectTime") Date lastCollectTime); + + @Results({ + @Result(column = "id", property = "id", id = true), + @Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + }) + @Select(" select id, create_time from news " + + " where is_delete = 0 and create_time > #{lastCheckTime} and ${signalRule} ") + List getSignalRuleNews(@Param("lastCheckTime") Date lastCheckTime, @Param("signalRule") String signalRule); } diff --git a/core/src/main/java/com/jinrui/reference/core/mapper/NewsSignalRuleRelMapper.java b/core/src/main/java/com/jinrui/reference/core/mapper/NewsSignalRuleRelMapper.java new file mode 100644 index 0000000..9b797bf --- /dev/null +++ b/core/src/main/java/com/jinrui/reference/core/mapper/NewsSignalRuleRelMapper.java @@ -0,0 +1,33 @@ +package com.jinrui.reference.core.mapper; + +import java.util.Date; +import java.util.List; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + +import com.jinrui.reference.core.model.entity.NewsSignalRuleRel; + +public interface NewsSignalRuleRelMapper { + @Results({ + @Result(column = "id", property = "id", id = true), + @Result(column = "news_id", property = "newsId"), + @Result(column = "signal_rule_id", property = "signalRuleId"), + @Result(column = "check_time", property = "checkTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP) + }) + @Select("select * from news_signal_rule_rel order by check_time desc limit 1") + NewsSignalRuleRel getLastCheckedSignalRule(); + + + @Select("select signal_rule.rule_name from news_signal_rule_rel, signal_rule where news_signal_rule_rel.news_id = #{newsId} and news_signal_rule_rel.signal_rule_id = signal_rule.id") + List getNewsSignalRuleNames(@Param("newsId") Long newsId); + + @Insert("insert into news_signal_rule_rel(news_id, signal_rule_id, check_time, create_time, update_time) values (#{newsId}, #{signalRuleId}, #{checkTime}, now(), now())") + void saveNewsSignalRuleRel(@Param("newsId") Long newsId, @Param("signalRuleId") Long signalRuleId, @Param("checkTime") Date checkTime); +} diff --git a/core/src/main/java/com/jinrui/reference/core/mapper/SignalRuleMapper.java b/core/src/main/java/com/jinrui/reference/core/mapper/SignalRuleMapper.java new file mode 100644 index 0000000..04af47e --- /dev/null +++ b/core/src/main/java/com/jinrui/reference/core/mapper/SignalRuleMapper.java @@ -0,0 +1,24 @@ +package com.jinrui.reference.core.mapper; + +import java.util.Date; +import java.util.List; + +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + +import com.jinrui.reference.core.model.entity.SignalRule; + +public interface SignalRuleMapper { + @Results({ + @Result(column = "id", property = "id", id = true), + @Result(column = "rule_name", property = "ruleName"), + @Result(column = "rule_trigger", property = "ruleTrigger"), + @Result(column = "disabled", property = "disabled"), + @Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), + @Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP) + }) + @Select("select * from signal_rule where disabled = 0") + List queryAll(); +} diff --git a/core/src/main/java/com/jinrui/reference/core/mapper/TagMapper.java b/core/src/main/java/com/jinrui/reference/core/mapper/TagMapper.java index 2553538..a34ddc6 100644 --- a/core/src/main/java/com/jinrui/reference/core/mapper/TagMapper.java +++ b/core/src/main/java/com/jinrui/reference/core/mapper/TagMapper.java @@ -1,23 +1,25 @@ package com.jinrui.reference.core.mapper; -import com.jinrui.reference.core.model.entity.DraftTagRel; -import com.jinrui.reference.core.model.entity.NewsTagRel; -import com.jinrui.reference.core.model.entity.Tag; +import java.util.Date; +import java.util.List; + import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.type.JdbcType; -import java.util.Date; -import java.util.List; +import com.jinrui.reference.core.model.entity.DraftTagRel; +import com.jinrui.reference.core.model.entity.NewsTagRel; +import com.jinrui.reference.core.model.entity.Tag; public interface TagMapper { - @Results({ + @Results(id = "tagMap", value = { @Result(column = "id", property = "id", id = true), @Result(column = "parent_id", property = "parentId"), @Result(column = "parent_name", property = "parentName"), @@ -28,6 +30,20 @@ public interface TagMapper { @Select("select * from tag") List queryAll(); + @ResultMap("tagMap") + @Select("") + List getByIds(@Param("ids") List ids); + @Select("select id, parent_id as parentId, name from tag where id = #{id}") Tag queryById(@Param("id") Long id); @@ -56,10 +72,10 @@ public interface TagMapper { @Delete("delete from draft_tag_rel where draft_id = #{draftId}") void deleteDraft(@Param("draftId") Long draftId); - @Insert("insert into draft_tag_rel(draft_id, tag_id) values (#{draftId}, #{tagId})") + @Insert("insert into draft_tag_rel(draft_id, tag_id) values (#{draftId}, #{tagId}) on duplicate key update tag_id = #{tagId}") void saveDraftTagRel(@Param("draftId") Long draftId, @Param("tagId") Long tagId); - @Insert("insert into news_tag_rel(news_id, tag_id) values (#{newsId}, #{tagId})") + @Insert("insert into news_tag_rel(news_id, tag_id) values (#{newsId}, #{tagId}) on duplicate key update tag_id = #{tagId}") void saveNewsTagRel(@Param("newsId") Long newsId, @Param("tagId") Long tagId); // @Insert("insert into tag(parent_id, name, create_time, update_time) values (#{parentId},#{name}, now(), now())") @@ -76,14 +92,7 @@ public interface TagMapper { @Delete("delete from tag where id = #{id}") void deleteTag(@Param("id") Long id); - @Results({ - @Result(column = "id", property = "id", id = true), - @Result(column = "parent_id", property = "parentId"), - @Result(column = "parent_name", property = "parentName"), - @Result(column = "name", property = "name"), - @Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP), - @Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP) - }) + @ResultMap("tagMap") @Select("