Merge branch '20250924_news_add_columns'
This commit is contained in:
commit
dbe691ec67
|
|
@ -215,6 +215,46 @@ public class AdminUserController {
|
||||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return adminUserService.create(name, phone);
|
return adminUserService.create(name, phone, adminUserCreateDTO.getUserType());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理后台创建用户接口
|
||||||
|
*
|
||||||
|
* @param token 登陆Token
|
||||||
|
* @param adminUserCreateDTO 要创建的用户昵称及手机号
|
||||||
|
* @return 创建结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/h5")
|
||||||
|
public ResultObject<Void> createH5User(@RequestHeader("auth-token") String token,
|
||||||
|
@RequestParam(value = "phone", required = true) String phone) {
|
||||||
|
if (!StringUtils.hasText(token)) {
|
||||||
|
return ResultObject.failed("登陆Token为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.hasText(phone)) {
|
||||||
|
return ResultObject.failed("手机号不可为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
AdminUser adminUser = AdminJwtService.parseToken(token);
|
||||||
|
if (adminUser == null) {
|
||||||
|
log.warn("解析token {}拿不到AdminUser对象!", token);
|
||||||
|
return ResultObject.failed("登陆Token有误,请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!adminUser.isActive()) {
|
||||||
|
log.warn("当前用户已被封禁! id = {}", adminUser.getId());
|
||||||
|
return ResultObject.failed("当前用户已被封禁!请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("path: /admin/user/h5, method: POST, request user id: {}, name: {}, phone: {}",
|
||||||
|
adminUser.getId(), adminUser.getName(), phone);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("解析登陆Token出错!", e);
|
||||||
|
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return adminUserService.createH5User(phone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.jinrui.reference.admin.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
@ -34,18 +36,39 @@ 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) {
|
public ResultObject<List<NewsApiVO>> getNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) {
|
||||||
return newsService.requestNewsByApi(num, last);
|
String accessKey = request.getHeader("X-Api-Key");
|
||||||
|
Integer clientType = apiKeyService.getClientType(accessKey);
|
||||||
|
if (clientType == null||clientType == 0) {
|
||||||
|
return ResultObject.failed("非法操作!");
|
||||||
|
}
|
||||||
|
return newsService.requestNewsByApi(num, last, clientType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
public ResultObject<List<NewsApiVO>> queryNews(@RequestParam(name = "num", required = true, defaultValue = "10") Integer num, @RequestParam(name = "last", required = false) Long last, HttpServletRequest request) {
|
||||||
return newsService.requestNewsByApi(num, last);
|
String accessKey = request.getHeader("X-Api-Key");
|
||||||
|
Integer clientType = apiKeyService.getClientType(accessKey);
|
||||||
|
if (clientType == null||clientType == 0) {
|
||||||
|
return ResultObject.failed("非法操作!");
|
||||||
|
}
|
||||||
|
return newsService.requestNewsByApi(num, last, clientType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
String accessKey = request.getHeader("X-Api-Key");
|
||||||
|
Integer clientType = apiKeyService.getClientType(accessKey);
|
||||||
|
if (clientType == null) {
|
||||||
|
return ResultObject.failed("非法操作,用户不存在!");
|
||||||
|
}
|
||||||
|
return newsService.requestNewsByApi(num, last, clientType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,
|
||||||
|
@RequestParam(name = "clientType", required = true) Integer clientType) {
|
||||||
if (!StringUtils.hasText(token)) {
|
if (!StringUtils.hasText(token)) {
|
||||||
return ResultObject.failed("登陆Token为空!");
|
return ResultObject.failed("登陆Token为空!");
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +87,7 @@ public class ApiController {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("path: /api/key, method: POST, request user id: {}, clientName: {}", adminUserId, clientName);
|
log.info("path: /api/key, method: POST, request user id: {}, clientName: {}", adminUserId, clientName);
|
||||||
return apiKeyService.generateApiKey(clientName);
|
return apiKeyService.generateApiKey(clientName, clientType);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("解析登陆Token出错!", e);
|
log.error("解析登陆Token出错!", e);
|
||||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||||
|
|
@ -74,7 +97,8 @@ public class ApiController {
|
||||||
|
|
||||||
@GetMapping("/key")
|
@GetMapping("/key")
|
||||||
public ResultObject<Map<String, Object>> getApiKey(@RequestHeader("auth-token") String token,
|
public ResultObject<Map<String, Object>> getApiKey(@RequestHeader("auth-token") String token,
|
||||||
@RequestParam(name = "clientName", required = true) String clientName) {
|
@RequestParam(name = "clientName", required = true) String clientName,
|
||||||
return generateApiKey(token, clientName);
|
@RequestParam(name = "clientType", required = true) Integer clientType) {
|
||||||
|
return generateApiKey(token, clientName, clientType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,15 +59,22 @@ public interface AdminUserMapper {
|
||||||
void delete(@Param("id") long id);
|
void delete(@Param("id") long id);
|
||||||
|
|
||||||
@Insert("<script>" +
|
@Insert("<script>" +
|
||||||
"insert into admin_user(phone, create_time, update_time" +
|
"insert into admin_user(phone, password, userType, create_time, update_time" +
|
||||||
"<if test=\"name != null and !name.isEmpty()\">" +
|
"<if test=\"name != null and !name.isEmpty()\">" +
|
||||||
", name" +
|
", name" +
|
||||||
"</if>" +
|
"</if>" +
|
||||||
") values (#{phone}, now(), now()" +
|
") values (#{phone}, #{password},#{userType}, now(), now()" +
|
||||||
"<if test=\"name != null and !name.isEmpty()\">" +
|
"<if test=\"name != null and !name.isEmpty()\">" +
|
||||||
", #{name}" +
|
", #{name}" +
|
||||||
"</if>" +
|
"</if>" +
|
||||||
")" +
|
")" +
|
||||||
"</script>")
|
"</script>")
|
||||||
void create(@Param("name") String name, @Param("phone") String phone);
|
void create(@Param("name") String name, @Param("phone") String phone, @Param("password") String password, @Param("userType") String userType);
|
||||||
|
|
||||||
|
@Insert("<script>" +
|
||||||
|
"insert into allowlist_detail(mobile, create_time, update_time" +
|
||||||
|
") values (#{phone}, now(), now()" +
|
||||||
|
")" +
|
||||||
|
"</script>")
|
||||||
|
void createH5User(@Param("phone") String phone);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ public class AdminUserCreateDTO {
|
||||||
*/
|
*/
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
|
private String userType;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
@ -30,4 +32,12 @@ public class AdminUserCreateDTO {
|
||||||
public void setPhone(String phone) {
|
public void setPhone(String phone) {
|
||||||
this.phone = phone;
|
this.phone = phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUserType() {
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserType(String userType) {
|
||||||
|
this.userType = userType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
@ -245,7 +246,7 @@ public class AdminUserService {
|
||||||
return ResultObject.success();
|
return ResultObject.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultObject<Void> create(String name, String phone) {
|
public ResultObject<Void> create(String name, String phone, String userType) {
|
||||||
try {
|
try {
|
||||||
AdminUser adminUser = adminUserMapper.getAdminUserByPhone(phone);
|
AdminUser adminUser = adminUserMapper.getAdminUserByPhone(phone);
|
||||||
if (adminUser != null) {
|
if (adminUser != null) {
|
||||||
|
|
@ -256,9 +257,11 @@ public class AdminUserService {
|
||||||
log.error("根据手机号查询用户出错!", e);
|
log.error("根据手机号查询用户出错!", e);
|
||||||
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
|
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
|
||||||
}
|
}
|
||||||
|
if (ObjectUtils.isEmpty(userType)) {
|
||||||
|
userType = "00";
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
adminUserMapper.create(name, phone);
|
adminUserMapper.create(name, phone, "111111", userType);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("注册用户报错!", e);
|
log.error("注册用户报错!", e);
|
||||||
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
|
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
|
||||||
|
|
@ -293,4 +296,14 @@ public class AdminUserService {
|
||||||
private static String getLoginLockKey(String phone) {
|
private static String getLoginLockKey(String phone) {
|
||||||
return REDIS_LOGIN_LOCK_KEY + phone;
|
return REDIS_LOGIN_LOCK_KEY + phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResultObject<Void> createH5User(String phone) {
|
||||||
|
try {
|
||||||
|
adminUserMapper.createH5User(phone);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("注册用户报错!", e);
|
||||||
|
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
|
||||||
|
}
|
||||||
|
return ResultObject.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,13 @@ 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")
|
||||||
|
Integer getClientType(@Param("ak") String ak);
|
||||||
|
|
||||||
@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);
|
||||||
|
|
||||||
@Insert("insert into api_user(client_name, access_key, secret_key)" +
|
@Insert("insert into api_user(client_name, access_key, secret_key, fulled)" +
|
||||||
"values (#{clientName}, #{accessKey}, #{secretKey})")
|
"values (#{clientName}, #{accessKey}, #{secretKey}, #{fulled})")
|
||||||
void save(@Param("clientName") String clientName, @Param("accessKey") String accessKey, @Param("secretKey") String secretKey);
|
void save(@Param("clientName") String clientName, @Param("accessKey") String accessKey, @Param("secretKey") String secretKey, @Param("fulled") Integer fulled);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ public interface NewsMapper {
|
||||||
void saveDraft(NewsDraft newsDraft);
|
void saveDraft(NewsDraft newsDraft);
|
||||||
|
|
||||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
@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)" +
|
@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})")
|
"values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating}, #{overseasEvent}, #{overseasMacro}, #{chinaMacro}, #{industryNews}, #{companyNews}, #{reprintSource}, #{companyName})")
|
||||||
void saveNews(News news);
|
void saveNews(News news);
|
||||||
|
|
||||||
@Select("<script>" +
|
@Select("<script>" +
|
||||||
|
|
@ -305,7 +305,13 @@ public interface NewsMapper {
|
||||||
" from news " +
|
" from news " +
|
||||||
" left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
|
" left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
|
||||||
"<where>" +
|
"<where>" +
|
||||||
" news.status in (1, 2, 3) and news.is_delete = 0 and news.publish_time >= adddate(date(now()), -2) " +
|
"<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 and news.publish_time >= adddate(date(now()), -2) " +
|
||||||
"<if test=\"last != null\">" +
|
"<if test=\"last != null\">" +
|
||||||
" and news.id > #{last}" +
|
" and news.id > #{last}" +
|
||||||
"</if>" +
|
"</if>" +
|
||||||
|
|
@ -313,5 +319,5 @@ public interface NewsMapper {
|
||||||
" order by id asc " +
|
" order by id asc " +
|
||||||
" limit ${limit}" +
|
" limit ${limit}" +
|
||||||
"</script>")
|
"</script>")
|
||||||
List<NewsApiVO> queryNewsByApi(@Param("last") Long last, @Param("limit") int limit);
|
List<NewsApiVO> queryNewsByApi(@Param("last") Long last, @Param("limit") int limit, @Param("clientType") int clientType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import org.apache.ibatis.annotations.Result;
|
||||||
import org.apache.ibatis.annotations.Results;
|
import org.apache.ibatis.annotations.Results;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import com.jinrui.reference.core.model.entity.News;
|
|
||||||
import com.jinrui.reference.core.model.entity.NewsTags;
|
import com.jinrui.reference.core.model.entity.NewsTags;
|
||||||
import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler;
|
import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.jinrui.reference.core.model.entity;
|
package com.jinrui.reference.core.model.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.jinrui.reference.core.model.dto.news.SaveNewsDTO;
|
import com.jinrui.reference.core.model.dto.news.SaveNewsDTO;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -88,6 +89,20 @@ public class News {
|
||||||
|
|
||||||
private String revision;
|
private String revision;
|
||||||
|
|
||||||
|
private Integer overseasEvent;
|
||||||
|
|
||||||
|
private Integer overseasMacro;
|
||||||
|
|
||||||
|
private Integer chinaMacro;
|
||||||
|
|
||||||
|
private Integer industryNews;
|
||||||
|
|
||||||
|
private Integer companyNews;
|
||||||
|
|
||||||
|
private String reprintSource;
|
||||||
|
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
public News() {}
|
public News() {}
|
||||||
|
|
||||||
public News(SaveNewsDTO saveNewsDTO) {
|
public News(SaveNewsDTO saveNewsDTO) {
|
||||||
|
|
@ -267,4 +282,60 @@ public class News {
|
||||||
public String getRevision() {
|
public String getRevision() {
|
||||||
return revision;
|
return revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getOverseasEvent() {
|
||||||
|
return overseasEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverseasEvent(Integer overseasEvent) {
|
||||||
|
this.overseasEvent = overseasEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOverseasMacro() {
|
||||||
|
return overseasMacro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverseasMacro(Integer overseasMacro) {
|
||||||
|
this.overseasMacro = overseasMacro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getChinaMacro() {
|
||||||
|
return chinaMacro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChinaMacro(Integer chinaMacro) {
|
||||||
|
this.chinaMacro = chinaMacro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIndustryNews() {
|
||||||
|
return industryNews;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndustryNews(Integer industryNews) {
|
||||||
|
this.industryNews = industryNews;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCompanyNews() {
|
||||||
|
return companyNews;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyNews(Integer companyNews) {
|
||||||
|
this.companyNews = companyNews;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReprintSource() {
|
||||||
|
return reprintSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReprintSource(String reprintSource) {
|
||||||
|
this.reprintSource = reprintSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCompanyName() {
|
||||||
|
return companyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyName(String companyName) {
|
||||||
|
this.companyName = companyName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class NewsTags {
|
public class NewsTags {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
@ -66,6 +68,27 @@ public class NewsTags {
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Shanghai")
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Shanghai")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
// @JsonProperty("overseas_event")
|
||||||
|
// private Boolean overseasEvent;
|
||||||
|
//
|
||||||
|
// @JsonProperty("overseas_macro")
|
||||||
|
// private Boolean overseasMacro;
|
||||||
|
//
|
||||||
|
// @JsonProperty("china_macro")
|
||||||
|
// private Boolean chinaMacro;
|
||||||
|
//
|
||||||
|
// @JsonProperty("industry_news")
|
||||||
|
// private Boolean industryNews;
|
||||||
|
//
|
||||||
|
// @JsonProperty("company_news")
|
||||||
|
// private Boolean companyNews;
|
||||||
|
//
|
||||||
|
// @JsonProperty("reprint_source")
|
||||||
|
// private String reprintSource;
|
||||||
|
//
|
||||||
|
// @JsonProperty("company_name")
|
||||||
|
// private String companyName;
|
||||||
|
|
||||||
public List<Double> getIndustryScore() {
|
public List<Double> getIndustryScore() {
|
||||||
return industryScore;
|
return industryScore;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,13 @@ public class ApiKeyService {
|
||||||
return secretKey;
|
return secretKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultObject<Map<String, Object>> generateApiKey(String clientName) {
|
public ResultObject<Map<String, Object>> generateApiKey(String clientName, Integer clientType) {
|
||||||
Map<String, Object> clientKeyMap = apiUserMapper.getClientKey(clientName);
|
Map<String, Object> clientKeyMap = apiUserMapper.getClientKey(clientName);
|
||||||
if (ObjectUtils.isEmpty(clientKeyMap)) {
|
if (ObjectUtils.isEmpty(clientKeyMap)) {
|
||||||
String accessKey = ApiKeyGenerator.generateAK();
|
String accessKey = ApiKeyGenerator.generateAK();
|
||||||
String secretKey = ApiKeyGenerator.generateSK();
|
String secretKey = ApiKeyGenerator.generateSK();
|
||||||
try {
|
try {
|
||||||
apiUserMapper.save(clientName, accessKey, secretKey);
|
apiUserMapper.save(clientName, accessKey, secretKey, clientType);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("产生客户API密钥对失败", e);
|
LOGGER.error("产生客户API密钥对失败", e);
|
||||||
ResultObject.failed("客户已存在!");
|
ResultObject.failed("客户已存在!");
|
||||||
|
|
@ -46,4 +46,8 @@ public class ApiKeyService {
|
||||||
return ResultObject.success(clientKeyMap);
|
return ResultObject.success(clientKeyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getClientType(String ak) {
|
||||||
|
return apiUserMapper.getClientType(ak);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1109,8 +1109,8 @@ public class NewsService {
|
||||||
* @param last
|
* @param last
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResultObject<List<NewsApiVO>> requestNewsByApi(Integer num, Long last) {
|
public ResultObject<List<NewsApiVO>> requestNewsByApi(Integer num, Long last, Integer clientType) {
|
||||||
List<NewsApiVO> result = newsMapper.queryNewsByApi(last, Integer.min(num, 1000));
|
List<NewsApiVO> result = newsMapper.queryNewsByApi(last, Integer.min(num, 1000), clientType);
|
||||||
|
|
||||||
Map<Long, Industry> industryMap = industryMapper.queryAll().stream().collect(Collectors.toMap(Industry::getId, Function.identity()));
|
Map<Long, Industry> industryMap = industryMapper.queryAll().stream().collect(Collectors.toMap(Industry::getId, Function.identity()));
|
||||||
result.stream().forEach( e -> {
|
result.stream().forEach( e -> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue