如果全量资讯的媒体来源不存在则新建媒体来源
This commit is contained in:
parent
2cda46fe21
commit
3f0155dc0d
|
|
@ -0,0 +1,30 @@
|
||||||
|
CREATE TABLE `industry` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '行业分类主键',
|
||||||
|
`parent_id` bigint(20) NOT NULL,
|
||||||
|
`primary_name` varchar(200) NOT NULL COMMENT '一级行业名称',
|
||||||
|
`secondary_name` varchar(200) DEFAULT NULL COMMENT '二级行业名称',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COMMENT='行业分类表';
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `draft_industry_rel` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
`draft_id` bigint(20) NOT NULL COMMENT '资讯草稿ID',
|
||||||
|
`industry_id` bigint(20) NOT NULL COMMENT '行业分类ID',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `IDX_DRAFT_ID` (`draft_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COMMENT='资讯草稿行业关联表';
|
||||||
|
|
||||||
|
CREATE TABLE `news_industry_rel` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '资讯精选行业关联表主键',
|
||||||
|
`news_id` bigint(20) NOT NULL COMMENT '资讯ID',
|
||||||
|
`industry_id` bigint(20) NOT NULL COMMENT '行业分类ID',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `IDX_NEWS_ID` (`news_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COMMENT='资讯精选行业关联表';
|
||||||
|
|
||||||
|
alter table news add column `newsinfo_id` varchar(20) character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
|
alter table news_tags add column `newsinfo_id` varchar(20) COLLATE utf8mb4_unicode_ci GENERATED ALWAYS AS (cast(`news_id` as char charset utf8mb4)) VIRTUAL;
|
||||||
|
CREATE INDEX idx_news_tags_newsinfo_id ON news_tags(newsinfo_id);
|
||||||
|
|
@ -105,18 +105,25 @@ public class NewsInfoService {
|
||||||
for (Industry industryItem: industries) {
|
for (Industry industryItem: industries) {
|
||||||
if (industry.equals(industryItem.getPrimaryName()) || industryItem.equals(industryItem.getSecondaryName())) {
|
if (industry.equals(industryItem.getPrimaryName()) || industryItem.equals(industryItem.getSecondaryName())) {
|
||||||
industryMapper.saveNewsIndustryRel(relNews.getId(), industryItem.getId());
|
industryMapper.saveNewsIndustryRel(relNews.getId(), industryItem.getId());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String sourcename = newsInfo.getSourcename();
|
String sourcename = newsInfo.getSourcename();
|
||||||
if (!ObjectUtils.isEmpty(sourcename)) {
|
if (!ObjectUtils.isEmpty(sourcename)) {
|
||||||
|
boolean isFound = false;
|
||||||
List<Tag> matchedTags = tagMapper.queryTag(1L, sourcename, null, "create_time", null);
|
List<Tag> matchedTags = tagMapper.queryTag(1L, sourcename, null, "create_time", null);
|
||||||
for (Tag tag: matchedTags) {
|
for (Tag tag: matchedTags) {
|
||||||
if (tag.getName().equals(sourcename)) {
|
if (tag.getName().equals(sourcename)) {
|
||||||
tagMapper.saveNewsTagRel(relNews.getId(), tag.getId());
|
tagMapper.saveNewsTagRel(relNews.getId(), tag.getId());
|
||||||
|
isFound = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isFound) {
|
||||||
|
tagMapper.saveTag(1L, sourcename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue