增加招商证券的资讯信息

This commit is contained in:
sunflower2014 2026-02-10 16:05:41 +08:00
parent 3cf0c68bfa
commit 6206eb7773
7 changed files with 429 additions and 11 deletions

View File

@ -19,6 +19,7 @@ import com.jinrui.reference.admin.model.entity.AdminUser;
import com.jinrui.reference.admin.service.AdminJwtService; import com.jinrui.reference.admin.service.AdminJwtService;
import com.jinrui.reference.core.model.vo.ResultObject; import com.jinrui.reference.core.model.vo.ResultObject;
import com.jinrui.reference.core.model.vo.news.NewsApi2VO; import com.jinrui.reference.core.model.vo.news.NewsApi2VO;
import com.jinrui.reference.core.model.vo.news.NewsApi4VO;
import com.jinrui.reference.core.model.vo.news.NewsApiVO; import com.jinrui.reference.core.model.vo.news.NewsApiVO;
import com.jinrui.reference.core.service.ApiKeyService; import com.jinrui.reference.core.service.ApiKeyService;
import com.jinrui.reference.core.service.NewsService; import com.jinrui.reference.core.service.NewsService;
@ -39,7 +40,7 @@ public class ApiController {
@GetMapping("/news") @GetMapping("/news")
public ResultObject<List<NewsApiVO>> getNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) { public ResultObject<List<NewsApiVO>> getNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) {
String accessKey = request.getHeader("X-Api-Key"); String accessKey = request.getHeader("X-Api-Key");
Integer clientType = apiKeyService.getClientType(accessKey); Integer clientType = apiKeyService.getClientType(accessKey, "v1");
if (clientType == null||clientType == 0) { if (clientType == null||clientType == 0) {
return ResultObject.failed("非法操作!"); return ResultObject.failed("非法操作!");
} }
@ -50,7 +51,7 @@ public class ApiController {
@PostMapping("/news") @PostMapping("/news")
public ResultObject<List<NewsApiVO>> queryNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) { public ResultObject<List<NewsApiVO>> queryNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) {
String accessKey = request.getHeader("X-Api-Key"); String accessKey = request.getHeader("X-Api-Key");
Integer clientType = apiKeyService.getClientType(accessKey); Integer clientType = apiKeyService.getClientType(accessKey, "v1");
if (clientType == null||clientType == 0) { if (clientType == null||clientType == 0) {
return ResultObject.failed("非法操作!"); return ResultObject.failed("非法操作!");
} }
@ -60,7 +61,7 @@ public class ApiController {
@PostMapping("/news/published") @PostMapping("/news/published")
public ResultObject<List<NewsApiVO>> queryPublishedNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) { public ResultObject<List<NewsApiVO>> queryPublishedNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) {
String accessKey = request.getHeader("X-Api-Key"); String accessKey = request.getHeader("X-Api-Key");
Integer clientType = apiKeyService.getClientType(accessKey); Integer clientType = apiKeyService.getClientType(accessKey, "v1");
if (clientType == null) { if (clientType == null) {
return ResultObject.failed("非法操作,用户不存在!"); return ResultObject.failed("非法操作,用户不存在!");
} }
@ -70,13 +71,39 @@ public class ApiController {
@GetMapping("/news/v2") @GetMapping("/news/v2")
public ResultObject<List<NewsApi2VO>> getNewsV2(HttpServletRequest request) { public ResultObject<List<NewsApi2VO>> getNewsV2(HttpServletRequest request) {
String accessKey = request.getHeader("X-Api-Key"); String accessKey = request.getHeader("X-Api-Key");
Integer clientType = apiKeyService.getClientType(accessKey); Integer clientType = apiKeyService.getClientType(accessKey, "v2");
if (clientType == null||clientType == 0) { if (clientType == null||clientType == 0) {
return ResultObject.failed("非法操作!"); return ResultObject.failed("非法操作!");
} }
return newsService.requestNewsByApi2(); return newsService.requestNewsByApi2();
} }
@GetMapping("/news/v3")
public ResultObject<List<NewsApiVO>> getNewsV3(HttpServletRequest request) {
String accessKey = request.getHeader("X-Api-Key");
Integer clientType = apiKeyService.getClientType(accessKey, "v3");
if (clientType == null) {
return ResultObject.failed("非法操作,用户不存在!");
}
ResultObject<List<NewsApiVO>> result = newsService.requestNewsByApi(10, null, clientType);
List<NewsApiVO> newsList = result.getData();
newsList.forEach(e -> e.setSource("中国证券报"));
return result;
}
@GetMapping("/news/v4")
public ResultObject<List<NewsApi4VO>> getNewsV4(@RequestParam(name = "num", required = false, defaultValue = "10000") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) {
String accessKey = request.getHeader("X-Api-Key");
Integer clientType = apiKeyService.getClientType(accessKey, "v4");
if (clientType == null) {
return ResultObject.failed("非法操作,用户不存在!");
}
ResultObject<List<NewsApi4VO>> result = newsService.requestNewsByApi4(num, last, clientType);
List<NewsApi4VO> newsList = result.getData();
newsList.forEach(e -> e.setSource("中国证券报"));
return result;
}
@PostMapping("/key") @PostMapping("/key")
public ResultObject<Map<String, Object>> generateApiKey(@RequestHeader("auth-token") String token, public ResultObject<Map<String, Object>> generateApiKey(@RequestHeader("auth-token") String token,
@RequestParam(name = "clientName", required = true) String clientName, @RequestParam(name = "clientName", required = true) String clientName,

View File

@ -10,8 +10,8 @@ public interface ApiUserMapper {
@Select("select secret_key from api_user where access_key = #{ak} and disabled = 0") @Select("select secret_key from api_user where access_key = #{ak} and disabled = 0")
String getClientSecretkey(@Param("ak") String ak); String getClientSecretkey(@Param("ak") String ak);
@Select("select fulled from api_user where access_key = #{ak} and disabled = 0") @Select("select fulled from api_user where access_key = #{ak} and disabled = 0 and api_version = #{version}")
Integer getClientType(@Param("ak") String ak); Integer getClientType(@Param("ak") String ak, @Param("version") String version);
@Select("select access_key, secret_key from api_user where client_name = #{clientName} and disabled = 0") @Select("select access_key, secret_key from api_user where client_name = #{clientName} and disabled = 0")
Map<String, Object> getClientKey(@Param("clientName") String clientName); Map<String, Object> getClientKey(@Param("clientName") String clientName);

View File

@ -16,6 +16,7 @@ import org.apache.ibatis.type.JdbcType;
import com.jinrui.reference.core.model.entity.News; import com.jinrui.reference.core.model.entity.News;
import com.jinrui.reference.core.model.entity.NewsDraft; import com.jinrui.reference.core.model.entity.NewsDraft;
import com.jinrui.reference.core.model.vo.news.NewsApi2VO; import com.jinrui.reference.core.model.vo.news.NewsApi2VO;
import com.jinrui.reference.core.model.vo.news.NewsApi4VO;
import com.jinrui.reference.core.model.vo.news.NewsApiVO; import com.jinrui.reference.core.model.vo.news.NewsApiVO;
import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler; import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler;
@ -464,6 +465,7 @@ public interface NewsMapper {
@Result(column = "tdx_industry", property = "tdxIndustry", typeHandler = JsonArrayTypeHandler.class), @Result(column = "tdx_industry", property = "tdxIndustry", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "tdx_industry_confidence", property = "tdxIndustryConfidence", typeHandler = JsonArrayTypeHandler.class), @Result(column = "tdx_industry_confidence", property = "tdxIndustryConfidence", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "company_name", property = "companyName"), @Result(column = "company_name", property = "companyName"),
@Result(column = "source", property = "source"),
@Result(column = "news_score", property = "newsScore"), @Result(column = "news_score", property = "newsScore"),
}) })
@Select("<script>" + @Select("<script>" +
@ -479,6 +481,7 @@ public interface NewsMapper {
"news.tdx_industry," + "news.tdx_industry," +
"news.tdx_industry_confidence," + "news.tdx_industry_confidence," +
"news.company_name," + "news.company_name," +
"(select news_tags.source from news_tags where news.newsinfo_id = news_tags.newsinfo_id) as source, " +
"(select news_tags.news_score from news_tags where news.newsinfo_id = news_tags.newsinfo_id) as news_score " + "(select news_tags.news_score from news_tags where news.newsinfo_id = news_tags.newsinfo_id) as news_score " +
" from news " + " from news " +
"<where>" + "<where>" +
@ -491,4 +494,66 @@ public interface NewsMapper {
" limit ${limit}" + " limit ${limit}" +
"</script>") "</script>")
List<NewsApi2VO> queryNewsByApi3(@Param("limit") int limit); List<NewsApi2VO> queryNewsByApi3(@Param("limit") int limit);
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "llm_title", property = "title"),
@Result(column = "llm_content", property = "content"),
@Result(column = "summary", property = "summary"),
@Result(column = "publish_time", property = "publishTime"),
@Result(column = "industry_label", property = "industryLabel", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "industry_confidence", property = "industryConfidence", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "industry_score", property = "industryScore", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "concept_label", property = "conceptLabel", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "concept_confidence", property = "conceptConfidence", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "concept_score", property = "conceptScore", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "source", property = "source"),
@Result(column = "source_impact", property = "sourceImpact"),
@Result(column = "China_factor", property = "chinaFactor"),
@Result(column = "public_opinion_score", property = "publicOpinionScore"),
@Result(column = "news_score", property = "newsScore"),
@Result(column = "stock_codes", property = "stockCodes", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "stock_names", property = "stockNames", typeHandler = JsonArrayTypeHandler.class),
@Result(column = "company_name", property = "companyName"),
})
@Select("<script>" +
"select " +
"news.id as id," +
"news.llm_title," +
"news.llm_content," +
"news.summary, " +
"news.publish_time," +
"news_tags.news_score, " +
"news_tags.source, " +
"news_tags.industry_label, " +
"news_tags.industry_confidence," +
"news_tags.industry_score," +
"news_tags.concept_label," +
"news_tags.concept_confidence," +
"news_tags.concept_score," +
"news_tags.source_impact," +
"news_tags.China_factor," +
"news_tags.public_opinion_score," +
"news.stock_codes," +
"news.stock_names," +
"news.company_name" +
" from news " +
" left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
"<where>" +
"<if test=\"clientType == 1\">" +
"and news.status in (1, 2, 3) " +
"</if>" +
"<if test=\"clientType == 0\">" +
"and news.status = 2 " +
"</if>" +
" and news.is_delete = 0 " +
"<if test=\"last != null\">" +
" and news.id &gt; #{last}" +
"</if>" +
"</where>" +
" order by id asc " +
" limit ${limit}" +
"</script>")
List<NewsApi4VO> queryNewsByApi4(@Param("last") Long last, @Param("limit") int limit, @Param("clientType") int clientType);
} }

View File

@ -100,7 +100,7 @@ public class NewsApi2VO {
private List<String> tdxIndustry; private List<String> tdxIndustry;
private List<String> tdxIndustryConfidence; private List<Double> tdxIndustryConfidence;
private Boolean published; private Boolean published;
@ -197,11 +197,11 @@ public class NewsApi2VO {
this.tdxIndustry = tdxIndustry; this.tdxIndustry = tdxIndustry;
} }
public List<String> getTdxIndustryConfidence() { public List<Double> getTdxIndustryConfidence() {
return tdxIndustryConfidence; return tdxIndustryConfidence;
} }
public void setTdxIndustryConfidence(List<String> tdxIndustryConfidence) { public void setTdxIndustryConfidence(List<Double> tdxIndustryConfidence) {
this.tdxIndustryConfidence = tdxIndustryConfidence; this.tdxIndustryConfidence = tdxIndustryConfidence;
} }

View File

@ -0,0 +1,303 @@
package com.jinrui.reference.core.model.vo.news;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
public class NewsApi4VO {
/**
* 资讯ID
*/
private Long id;
/**
* 资讯标题
*/
private String title;
/**
* 资讯内容
*/
private String content;
/**
* 报道时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private Date publishTime;
/**
* 资讯摘要
*/
private String summary;
/**
* 资讯评分
*/
private Double newsScore;
/**
* 资讯来源
*/
private String source;
// /**
// *
// */
// private Integer exclusive;
/**
* 行业分类标签
*/
private List<String> industryLabel;
/**
* 行业分类置信度
*/
private List<Number> industryConfidence;
/**
* 行业分类评分
*/
private List<Number> industryScore;
/**
* 概念标签
* @return
*/
private List<String> conceptLabel;
/**
* 概念标签置信度
*/
private List<Number> conceptConfidence;
/**
* 概念标签评分
*/
private List<Number> conceptScore;
/**
* 媒体影响力
*/
private Integer sourceImpact;
/**
* 中国股市相关性
*/
private Double chinaFactor;
/**
* 资讯质量
*/
private Integer publicOpinionScore;
private List<String> stockCodes;
private List<String> stockNames;
// private List<String> tdxIndustry;
//
// private List<Double> tdxIndustryConfidence;
// private Boolean published;
private String companyName;
// private String signalRule;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getPublishTime() {
return publishTime;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public Double getNewsScore() {
return newsScore;
}
public void setNewsScore(Double newsScore) {
this.newsScore = newsScore;
}
// public Integer getExclusive() {
// return exclusive;
// }
//
// public void setExclusive(Integer exclusive) {
// this.exclusive = exclusive;
// }
public List<String> getStockCodes() {
return stockCodes;
}
public void setStockCodes(List<String> stockCodes) {
this.stockCodes = stockCodes;
}
public List<String> getStockNames() {
return stockNames;
}
public void setStockNames(List<String> stockNames) {
this.stockNames = stockNames;
}
// public List<String> getTdxIndustry() {
// return tdxIndustry;
// }
//
// public void setTdxIndustry(List<String> tdxIndustry) {
// this.tdxIndustry = tdxIndustry;
// }
//
// public List<Double> getTdxIndustryConfidence() {
// return tdxIndustryConfidence;
// }
//
// public void setTdxIndustryConfidence(List<Double> tdxIndustryConfidence) {
// this.tdxIndustryConfidence = tdxIndustryConfidence;
// }
// public Boolean getPublished() {
// return published;
// }
//
// public void setPublished(Boolean published) {
// this.published = published;
// }
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
// public String getSignalRule() {
// return signalRule;
// }
//
// public void setSignalRule(String signalRule) {
// this.signalRule = signalRule;
// }
public List<String> getIndustryLabel() {
return industryLabel;
}
public void setIndustryLabel(List<String> industryLabel) {
this.industryLabel = industryLabel;
}
public List<Number> getIndustryConfidence() {
return industryConfidence;
}
public void setIndustryConfidence(List<Number> industryConfidence) {
this.industryConfidence = industryConfidence;
}
public List<Number> getIndustryScore() {
return industryScore;
}
public void setIndustryScore(List<Number> industryScore) {
this.industryScore = industryScore;
}
public List<String> getConceptLabel() {
return conceptLabel;
}
public void setConceptLabel(List<String> conceptLabel) {
this.conceptLabel = conceptLabel;
}
public List<Number> getConceptConfidence() {
return conceptConfidence;
}
public void setConceptConfidence(List<Number> conceptConfidence) {
this.conceptConfidence = conceptConfidence;
}
public List<Number> getConceptScore() {
return conceptScore;
}
public void setConceptScore(List<Number> conceptScore) {
this.conceptScore = conceptScore;
}
public Integer getSourceImpact() {
return sourceImpact;
}
public void setSourceImpact(Integer sourceImpact) {
this.sourceImpact = sourceImpact;
}
public Double getChinaFactor() {
return chinaFactor;
}
public void setChinaFactor(Double chinaFactor) {
this.chinaFactor = chinaFactor;
}
public Integer getPublicOpinionScore() {
return publicOpinionScore;
}
public void setPublicOpinionScore(Integer publicOpinionScore) {
this.publicOpinionScore = publicOpinionScore;
}
}

View File

@ -46,8 +46,8 @@ public class ApiKeyService {
return ResultObject.success(clientKeyMap); return ResultObject.success(clientKeyMap);
} }
public Integer getClientType(String ak) { public Integer getClientType(String ak, String apiVersion) {
return apiUserMapper.getClientType(ak); return apiUserMapper.getClientType(ak, apiVersion);
} }
} }

View File

@ -63,6 +63,7 @@ import com.jinrui.reference.core.model.entity.UserOperationLog;
import com.jinrui.reference.core.model.vo.PageObject; import com.jinrui.reference.core.model.vo.PageObject;
import com.jinrui.reference.core.model.vo.ResultObject; import com.jinrui.reference.core.model.vo.ResultObject;
import com.jinrui.reference.core.model.vo.news.NewsApi2VO; import com.jinrui.reference.core.model.vo.news.NewsApi2VO;
import com.jinrui.reference.core.model.vo.news.NewsApi4VO;
import com.jinrui.reference.core.model.vo.news.NewsApiVO; import com.jinrui.reference.core.model.vo.news.NewsApiVO;
import com.jinrui.reference.core.model.vo.news.NewsDetailColumn; import com.jinrui.reference.core.model.vo.news.NewsDetailColumn;
import com.jinrui.reference.core.model.vo.news.NewsDetailColumnVip; import com.jinrui.reference.core.model.vo.news.NewsDetailColumnVip;
@ -1399,4 +1400,26 @@ public class NewsService {
} }
return ResultObject.success(result); return ResultObject.success(result);
} }
/**
* 返回最近两天的数据
* @param num
* @param last
* @return
*/
public ResultObject<List<NewsApi4VO>> requestNewsByApi4(Integer num, Long last, Integer clientType) {
List<NewsApi4VO> result = newsMapper.queryNewsByApi4(last, num, clientType);
Map<Long, Industry> industryMap = industryMapper.queryAll().stream().collect(Collectors.toMap(Industry::getId, Function.identity()));
result.stream().forEach( e -> {
List<Tag> newsTagRels = tagMapper.getNewsTagRelList(e.getId()).stream().map(x -> tagMapper.queryById(x.getTagId())).collect(Collectors.toList());
List<String> conceptLabel = newsTagRels.stream().filter(t -> t != null).map(Tag::getDisplayName).collect(Collectors.toList());
e.setConceptLabel(conceptLabel);
List<String> industryLabel = industryMapper.getNewsIndustryRelList(e.getId()).stream().map(x -> industryMap.get(x.getIndustryId())).filter(i -> i != null).map(n -> n.getDisplayName()).collect(Collectors.toList());
e.setIndustryLabel(industryLabel);
});
return ResultObject.success(result);
}
} }