用户管理
This commit is contained in:
parent
4aa1832301
commit
3cf0c68bfa
|
|
@ -17,6 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
@EnableScheduling
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
|
|
@ -257,4 +258,38 @@ public class AdminUserController {
|
|||
|
||||
return adminUserService.createH5User(phone);
|
||||
}
|
||||
|
||||
@PostMapping("/password/reset")
|
||||
public ResultObject<Void> resetPasswrod(@RequestHeader("auth-token") String token,
|
||||
@RequestBody Map<String, Object> params) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
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/password/reset, method: POST, request user id: {}, name: {}",
|
||||
adminUser.getId(), adminUser.getName());
|
||||
|
||||
Object password = params.get("password");
|
||||
if (password == null) {
|
||||
return ResultObject.failed("修改密码接口缺少相关参数!");
|
||||
}
|
||||
return adminUserService.resetPassword(adminUser.getId(), (String)password);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import com.jinrui.reference.admin.model.entity.AdminUser;
|
||||
import com.jinrui.reference.admin.service.AdminJwtService;
|
||||
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.NewsApiVO;
|
||||
import com.jinrui.reference.core.service.ApiKeyService;
|
||||
import com.jinrui.reference.core.service.NewsService;
|
||||
|
|
@ -45,6 +46,7 @@ public class ApiController {
|
|||
return newsService.requestNewsByApi(num, last, clientType);
|
||||
}
|
||||
|
||||
|
||||
@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) {
|
||||
String accessKey = request.getHeader("X-Api-Key");
|
||||
|
|
@ -65,6 +67,16 @@ public class ApiController {
|
|||
return newsService.requestNewsByApi(num, last, clientType);
|
||||
}
|
||||
|
||||
@GetMapping("/news/v2")
|
||||
public ResultObject<List<NewsApi2VO>> getNewsV2(HttpServletRequest request) {
|
||||
String accessKey = request.getHeader("X-Api-Key");
|
||||
Integer clientType = apiKeyService.getClientType(accessKey);
|
||||
if (clientType == null||clientType == 0) {
|
||||
return ResultObject.failed("非法操作!");
|
||||
}
|
||||
return newsService.requestNewsByApi2();
|
||||
}
|
||||
|
||||
@PostMapping("/key")
|
||||
public ResultObject<Map<String, Object>> generateApiKey(@RequestHeader("auth-token") String token,
|
||||
@RequestParam(name = "clientName", required = true) String clientName,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,184 @@
|
|||
package com.jinrui.reference.admin.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jinrui.reference.admin.model.entity.AdminUser;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserDTO;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserQueryParam;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserVO;
|
||||
import com.jinrui.reference.admin.service.AdminJwtService;
|
||||
import com.jinrui.reference.admin.service.H5UserService;
|
||||
import com.jinrui.reference.core.model.vo.PageObject;
|
||||
import com.jinrui.reference.core.model.vo.ResultObject;
|
||||
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/jnh")
|
||||
public class JiangnanBankController {
|
||||
private static final Logger log = LoggerFactory.getLogger(JiangnanBankController.class);
|
||||
|
||||
|
||||
private final H5UserService h5UserService;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final JedisPool jedisPool;
|
||||
|
||||
public JiangnanBankController(H5UserService h5UserService,
|
||||
ObjectMapper objectMapper,
|
||||
JedisPool jedisPool) {
|
||||
this.h5UserService = h5UserService;
|
||||
this.objectMapper = objectMapper;
|
||||
this.jedisPool = jedisPool;
|
||||
}
|
||||
|
||||
@PostMapping("/accounts/page")
|
||||
public PageObject<H5UserVO> queryNews(@RequestHeader("auth-token") String token,@RequestBody H5UserQueryParam h5UserQueryParam) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return PageObject.failedPage("登陆Token为空!");
|
||||
}
|
||||
|
||||
try {
|
||||
AdminUser adminUser = AdminJwtService.parseToken(token);
|
||||
if (adminUser == null) {
|
||||
log.warn("解析token {}拿不到AdminUser对象!", token);
|
||||
return PageObject.failedPage("登陆Token有误,请联系系统管理员!");
|
||||
}
|
||||
|
||||
if (!adminUser.isActive()) {
|
||||
log.warn("当前用户已被封禁! id = {}", adminUser.getId());
|
||||
return PageObject.failedPage("当前用户已被封禁!请联系系统管理员!");
|
||||
}
|
||||
|
||||
log.info("path: /accounts/page, method: POST, request user id: {}, request params: {}",
|
||||
adminUser.getId(), objectMapper.writeValueAsString(h5UserQueryParam));
|
||||
|
||||
h5UserQueryParam.setCreateBy(adminUser.getName());
|
||||
return h5UserService.queryH5User(h5UserQueryParam);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/accounts/addOrUpdate")
|
||||
public ResultObject<Void> addOrUpdate(@RequestHeader("auth-token") String token, @RequestBody H5UserDTO h5UserDTO) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
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: /accounts/addOrUpdate, method: POST, request user id: {}, request params: {}",
|
||||
adminUser.getId(), objectMapper.writeValueAsString(h5UserDTO));
|
||||
|
||||
h5UserDTO.setCreateBy(adminUser.getName());
|
||||
return h5UserService.addOrUpdate(h5UserDTO);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/accounts/remove")
|
||||
public ResultObject<Void> remove(@RequestHeader("auth-token") String token, @RequestBody H5UserDTO h5UserDTO) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
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: /accounts/addOrUpdate, method: POST, request user id: {}, request params: {}",
|
||||
adminUser.getId(), objectMapper.writeValueAsString(h5UserDTO));
|
||||
return h5UserService.remove(h5UserDTO.getId());
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/accounts/status")
|
||||
public ResultObject<Void> resetStatus(@RequestHeader("auth-token") String token, @RequestBody H5UserDTO h5UserDTO) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
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: /accounts/addOrUpdate, method: POST, request user id: {}, request params: {}",
|
||||
adminUser.getId(), objectMapper.writeValueAsString(h5UserDTO));
|
||||
return h5UserService.resetStatus(h5UserDTO);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/accounts/import")
|
||||
public ResultObject<String> importAccounts(@RequestHeader("auth-token") String token, @RequestParam("file") MultipartFile file) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
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: /accounts/import, method: POST, request user id: {}", adminUser.getId());
|
||||
if (file.isEmpty()) {
|
||||
return ResultObject.failed("上传的批量导入文件为空!");
|
||||
}
|
||||
return h5UserService.importAccounts(file, adminUser.getName());
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -331,7 +331,8 @@ public class NewsController {
|
|||
@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
|
||||
@RequestParam(value = "range", required = false, defaultValue = "all") String range,
|
||||
@RequestParam(value = "clusterSwitch", defaultValue = "false") Boolean clusterSwitch
|
||||
) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
return PageObject.failedPage("登陆Token为空!");
|
||||
|
|
@ -366,7 +367,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, exclusive, isReviewRange, isSecondReviewRange, includeRuleIds, excludeRuleIds, companyName);
|
||||
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, clusterSwitch);
|
||||
} catch (Exception e) {
|
||||
log.error("解析登陆Token出错!", e);
|
||||
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||
|
|
@ -551,6 +552,71 @@ public class NewsController {
|
|||
return ResultObject.success(listedCompanyList);
|
||||
}
|
||||
|
||||
@GetMapping("/getRealTotal")
|
||||
public ResultObject<Integer> getRealTotal(@RequestHeader("auth-token") String token,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "tag", required = false) String tag,
|
||||
@RequestParam(value = "industry", required = false) String industry,
|
||||
@RequestParam(value = "minScore", required = false) Double minScore,
|
||||
@RequestParam(value = "maxScore", required = false) Double maxScore,
|
||||
@RequestParam(value = "column", required = false) String columnList,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
||||
@RequestParam(value = "size", required = false, defaultValue = "10") int size,
|
||||
@RequestParam(value = "last", required = false) Integer last,
|
||||
@RequestParam(value = "current", required = false) Integer current,
|
||||
@RequestParam(value = "orderBy", required = false) String orderBy,
|
||||
@RequestParam(value = "mediaId", required = false) Long mediaId,
|
||||
@RequestParam(value = "dateline_from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date datelineFrom,
|
||||
@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)) {
|
||||
return ResultObject.failed("登陆Token为空!");
|
||||
}
|
||||
|
||||
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: /news, method: GET, request user id: {}, keyword: {}, column: {}, status: {}, " +
|
||||
"page: {}, size: {}, last: {}, current: {}, orderBy: {}, tag: {}, industry: {}",
|
||||
adminUser.getId(), keyword, columnList, status, page, size, last, current, orderBy, tag, industry);
|
||||
|
||||
boolean isReviewRange = false;
|
||||
boolean isSecondReviewRange = false;
|
||||
if ("review".equals(range)) {
|
||||
if (!adminUser.isReviewer()) {
|
||||
return ResultObject.failed(500, "非审核员用户查看范围权限!");
|
||||
}
|
||||
isReviewRange = true;
|
||||
} else if ("secondReview".equals(range)) {
|
||||
if (!adminUser.isSecondReviewer()) {
|
||||
return ResultObject.failed(500, "非二审用户无查看此范围权限!");
|
||||
}
|
||||
isSecondReviewRange = true;
|
||||
}
|
||||
return newsService.getRealTotal(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 ResultObject.failed(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param newsId
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.jinrui.reference.admin.mapper;
|
||||
|
||||
import com.jinrui.reference.admin.model.entity.AdminUser;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserVO;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -55,6 +57,9 @@ public interface AdminUserMapper {
|
|||
@Update("update admin_user set active = 0, update_time = now() where id = #{id}")
|
||||
void ban(@Param("id") long id);
|
||||
|
||||
@Update("update admin_user set password = #{password}, update_time = now() where id = #{id}")
|
||||
void resetPassword(@Param("id") long id, @Param("password") String password);
|
||||
|
||||
@Delete("delete from admin_user where id = #{id}")
|
||||
void delete(@Param("id") long id);
|
||||
|
||||
|
|
@ -71,10 +76,6 @@ public interface AdminUserMapper {
|
|||
"</script>")
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
package com.jinrui.reference.admin.mapper;
|
||||
|
||||
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.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.annotations.Update;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserDTO;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserQueryParam;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserVO;
|
||||
|
||||
public interface H5UserMapper {
|
||||
@Insert("<script>" +
|
||||
"insert into allowlist_detail(mobile, create_time, update_time" +
|
||||
") values (#{phone}, now(), now()" +
|
||||
")" +
|
||||
"</script>")
|
||||
void createH5UserByPhone(@Param("phone") String phone);
|
||||
|
||||
@Insert("<script>" +
|
||||
"insert into allowlist_detail(mobile, department, name, create_by, create_time, update_time" +
|
||||
") values (#{mobile}, #{department},#{name}, #{createBy}, now(), now()" +
|
||||
")" +
|
||||
"</script>")
|
||||
void createH5User(H5UserDTO h5UserDTO);
|
||||
|
||||
@Results(id="h5UserMap", value = {
|
||||
@Result(column = "id", property = "id", id = true),
|
||||
@Result(column = "mobile", property = "mobile"),
|
||||
@Result(column = "name", property = "name"),
|
||||
@Result(column = "department", property = "department"),
|
||||
@Result(column = "status", property = "status"),
|
||||
@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 allowlist_detail where mobile = #{mobile}")
|
||||
H5UserVO selectByMobile(@Param("mobile") String mobile);
|
||||
|
||||
@Update("<script>" +
|
||||
"update allowlist_detail " +
|
||||
" <set>" +
|
||||
"<if test=\"name != null and name.trim().length() > 0 \">" +
|
||||
" name = #{name}, " +
|
||||
"</if>" +
|
||||
"<if test=\"department != null and department.trim().length() > 0 \">" +
|
||||
" department = #{department}, " +
|
||||
"</if>" +
|
||||
"<if test=\"mobile != null and mobile.trim().length() > 0 \">" +
|
||||
" mobile = #{mobile}, " +
|
||||
"</if>" +
|
||||
"<if test=\"status != null \">" +
|
||||
" status = #{status}, " +
|
||||
"</if>" +
|
||||
" update_time = now() " +
|
||||
" </set>" +
|
||||
" where id = #{id} " +
|
||||
"</script>" )
|
||||
void updateH5User(H5UserDTO h5UserDTO);
|
||||
|
||||
|
||||
@ResultMap("h5UserMap")
|
||||
@Select("<script>" +
|
||||
"select * from allowlist_detail " +
|
||||
"<where>" +
|
||||
"<if test=\"mobile != null and mobile.trim().length() > 0 \">" +
|
||||
" and mobile = #{mobile} " +
|
||||
"</if>" +
|
||||
"<if test=\"department != null and department.trim().length() > 0 \">" +
|
||||
" and department like concat('%', #{department}, '%') " +
|
||||
"</if>" +
|
||||
"<if test=\"status != null \">" +
|
||||
" and status = #{status} " +
|
||||
"</if>" +
|
||||
"<if test=\"createBy != null and createBy.trim().length() > 0 \">" +
|
||||
" and create_by = #{createBy} " +
|
||||
"</if>" +
|
||||
"</where>" +
|
||||
"<if test=\"orderBy != null\">" +
|
||||
"order by ${orderBy} " +
|
||||
"</if>" +
|
||||
"limit ${size} offset ${offset}" +
|
||||
"</script>")
|
||||
List<H5UserVO> queryH5User(H5UserQueryParam h5UserQueryParam);
|
||||
|
||||
@Select("<script>" +
|
||||
"select count(*) from allowlist_detail " +
|
||||
"<where>" +
|
||||
"<if test=\"mobile != null and mobile.trim().length() > 0 \">" +
|
||||
" and mobile = #{mobile} " +
|
||||
"</if>" +
|
||||
"<if test=\"department != null and department.trim().length() > 0 \">" +
|
||||
" and department like concat('%', #{department}, '%') " +
|
||||
"</if>" +
|
||||
"<if test=\"status != null \">" +
|
||||
" and status = #{status} " +
|
||||
"</if>" +
|
||||
"<if test=\"createBy != null and createBy.trim().length() > 0 \">" +
|
||||
" and create_by = #{createBy} " +
|
||||
"</if>" +
|
||||
"</where>" +
|
||||
"</script>")
|
||||
int queryTotal(H5UserQueryParam h5UserQueryParam);
|
||||
|
||||
@Delete("delete from allowlist_detail where id = #{id}")
|
||||
void deleteById(@Param("id") Long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.jinrui.reference.admin.model.vo.admin.user;
|
||||
|
||||
public class H5UserDTO {
|
||||
private Long id;
|
||||
private String mobile;
|
||||
private String name;
|
||||
private String department;
|
||||
private Integer status;
|
||||
private String createBy;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.jinrui.reference.admin.model.vo.admin.user;
|
||||
|
||||
public class H5UserQueryParam {
|
||||
private int page;
|
||||
private int size;
|
||||
private int offset;
|
||||
private Integer last;
|
||||
private Integer current;
|
||||
private String orderBy;
|
||||
private String mobile;
|
||||
private String department;
|
||||
private Integer status;
|
||||
private String createBy;
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
public Integer getLast() {
|
||||
return last;
|
||||
}
|
||||
public void setLast(Integer last) {
|
||||
this.last = last;
|
||||
}
|
||||
public Integer getCurrent() {
|
||||
return current;
|
||||
}
|
||||
public void setCurrent(Integer current) {
|
||||
this.current = current;
|
||||
}
|
||||
public String getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
public void setOrderBy(String orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.jinrui.reference.admin.model.vo.admin.user;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
|
||||
public class H5UserUploadData {
|
||||
@ExcelProperty(index = 0)
|
||||
private String name;
|
||||
@ExcelProperty(index = 1)
|
||||
private String mobile;
|
||||
@ExcelProperty(index = 2)
|
||||
private String department;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.jinrui.reference.admin.model.vo.admin.user;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import cn.idev.excel.context.AnalysisContext;
|
||||
import cn.idev.excel.event.AnalysisEventListener;
|
||||
|
||||
public class H5UserUploadDataListener extends AnalysisEventListener<H5UserUploadData> {
|
||||
private static final Logger log = LoggerFactory.getLogger(H5UserUploadDataListener.class);
|
||||
|
||||
|
||||
private final List<H5UserUploadData> list = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void invoke(H5UserUploadData data, AnalysisContext context) {
|
||||
// log.info("读取到一条数据: {}", JSON.toJSONString(data));
|
||||
list.add(data);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<H5UserUploadData> getExcelData() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.jinrui.reference.admin.model.vo.admin.user;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
public class H5UserVO {
|
||||
private Long id;
|
||||
private String mobile;
|
||||
private String name;
|
||||
private String department;
|
||||
private Integer status;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
||||
private Date updateTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import java.util.Objects;
|
|||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -15,6 +16,7 @@ import org.springframework.util.StringUtils;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jinrui.reference.admin.mapper.AdminUserMapper;
|
||||
import com.jinrui.reference.admin.mapper.H5UserMapper;
|
||||
import com.jinrui.reference.admin.model.dto.login.LoginDTO;
|
||||
import com.jinrui.reference.admin.model.entity.AdminUser;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.AdminUserVO;
|
||||
|
|
@ -35,14 +37,17 @@ public class AdminUserService {
|
|||
|
||||
private final JedisPool jedisPool;
|
||||
private final AdminUserMapper adminUserMapper;
|
||||
private final H5UserMapper h5UserMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AdminUserService(JedisPool jedisPool,
|
||||
AdminUserMapper adminUserMapper,
|
||||
ObjectMapper objectMapper) {
|
||||
ObjectMapper objectMapper,
|
||||
H5UserMapper h5UserMapper) {
|
||||
this.jedisPool = jedisPool;
|
||||
this.adminUserMapper = adminUserMapper;
|
||||
this.objectMapper = objectMapper;
|
||||
this.h5UserMapper = h5UserMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -299,11 +304,17 @@ public class AdminUserService {
|
|||
|
||||
public ResultObject<Void> createH5User(String phone) {
|
||||
try {
|
||||
adminUserMapper.createH5User(phone);
|
||||
h5UserMapper.createH5UserByPhone(phone);
|
||||
} catch (Exception e) {
|
||||
log.error("注册用户报错!", e);
|
||||
return ResultObject.failed(500, "服务端错误!请联系系统管理员!");
|
||||
}
|
||||
return ResultObject.success();
|
||||
}
|
||||
|
||||
public ResultObject<Void> resetPassword(Long id, String password) {
|
||||
String newPassword = new String(Base64.decodeBase64(password));
|
||||
adminUserMapper.resetPassword(id, newPassword);
|
||||
return ResultObject.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,158 @@
|
|||
package com.jinrui.reference.admin.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jinrui.reference.admin.mapper.H5UserMapper;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserDTO;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserQueryParam;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserUploadData;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserUploadDataListener;
|
||||
import com.jinrui.reference.admin.model.vo.admin.user.H5UserVO;
|
||||
import com.jinrui.reference.core.model.vo.PageObject;
|
||||
import com.jinrui.reference.core.model.vo.ResultObject;
|
||||
|
||||
import cn.idev.excel.FastExcel;
|
||||
import cn.idev.excel.read.listener.PageReadListener;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
@Service
|
||||
public class H5UserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(H5UserService.class);
|
||||
|
||||
private final JedisPool jedisPool;
|
||||
private final H5UserMapper h5UserMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public H5UserService(JedisPool jedisPool,
|
||||
H5UserMapper h5UserMapper,
|
||||
ObjectMapper objectMapper) {
|
||||
this.jedisPool = jedisPool;
|
||||
this.h5UserMapper = h5UserMapper;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
|
||||
public PageObject<H5UserVO> queryH5User(H5UserQueryParam h5UserQueryParam) {
|
||||
int offset = 0;
|
||||
Integer current = h5UserQueryParam.getCurrent();
|
||||
int size = h5UserQueryParam.getSize();
|
||||
if (current != null) {
|
||||
offset = (Math.max(0, current - 1)) * size;
|
||||
}
|
||||
int page = h5UserQueryParam.getPage();
|
||||
h5UserQueryParam.setOffset(offset);
|
||||
|
||||
List<H5UserVO> h5UserList;
|
||||
try {
|
||||
h5UserList = h5UserMapper.queryH5User(h5UserQueryParam);
|
||||
} catch (Exception e) {
|
||||
log.error("搜索新闻异常!", e);
|
||||
return PageObject.failedPage(500, "服务器错误,请联系系统管理员!");
|
||||
}
|
||||
|
||||
PageObject<H5UserVO> pageObject = new PageObject<>();
|
||||
if (page == 1) {
|
||||
try {
|
||||
int total = h5UserMapper.queryTotal(h5UserQueryParam);
|
||||
pageObject.setTotal(total);
|
||||
} catch (Exception e) {
|
||||
log.error("获取新闻总数异常!", e);
|
||||
return PageObject.failedPage(500, "服务器错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
pageObject.setCode(200);
|
||||
pageObject.setCurrent(page);
|
||||
size = Math.min(h5UserList.size(), size);
|
||||
pageObject.setSize(size);
|
||||
if (CollectionUtils.isEmpty(h5UserList)) {
|
||||
log.info("搜索结果为空!");
|
||||
pageObject.setData(Collections.emptyList());
|
||||
return pageObject;
|
||||
}
|
||||
pageObject.setData(h5UserList);
|
||||
return pageObject;
|
||||
}
|
||||
|
||||
|
||||
public ResultObject<Void> addOrUpdate(H5UserDTO h5UserDTO) {
|
||||
if (h5UserDTO.getId() == null) {
|
||||
h5UserMapper.createH5User(h5UserDTO);
|
||||
} else {
|
||||
h5UserMapper.updateH5User(h5UserDTO);
|
||||
}
|
||||
return ResultObject.success();
|
||||
}
|
||||
|
||||
public ResultObject<Void> remove(Long id) {
|
||||
h5UserMapper.deleteById(id);
|
||||
return ResultObject.success();
|
||||
}
|
||||
|
||||
|
||||
public ResultObject<Void> resetStatus(H5UserDTO h5UserDTO) {
|
||||
h5UserMapper.updateH5User(h5UserDTO);
|
||||
return ResultObject.success();
|
||||
}
|
||||
|
||||
|
||||
public ResultObject<String> importAccounts(MultipartFile file, String createBy) {
|
||||
try {
|
||||
H5UserUploadDataListener h5UserUploadDataListener = new H5UserUploadDataListener();
|
||||
FastExcel.read(file.getInputStream(), H5UserUploadData.class, h5UserUploadDataListener)
|
||||
.sheet()
|
||||
.doRead();
|
||||
List<H5UserUploadData> h5Users = h5UserUploadDataListener.getExcelData();
|
||||
int size = h5Users.size();
|
||||
if (size == 0) {
|
||||
return ResultObject.failed("上传的数据为空!");
|
||||
}
|
||||
String msg = "";
|
||||
Map<String, H5UserUploadData> h5UserMobileMap = new HashMap<>();
|
||||
for (int i = 0; i < h5Users.size(); i++) {
|
||||
H5UserUploadData h5User = h5Users.get(i);
|
||||
if (!(StringUtils.hasText(h5User.getName()) && StringUtils.hasText(h5User.getMobile()))) {
|
||||
msg += "第" + (i+2) + "行数据缺少必填内容!\n";
|
||||
continue;
|
||||
}
|
||||
if (h5UserMobileMap.containsKey(h5User.getMobile())) {
|
||||
msg += "手机号" + h5User.getMobile() + "的数据重复!\n";
|
||||
h5UserMobileMap.remove(h5User.getMobile());
|
||||
continue;
|
||||
}
|
||||
h5UserMobileMap.put(h5User.getMobile(), h5User);
|
||||
}
|
||||
if (h5UserMobileMap.size() > 0) {
|
||||
for (H5UserUploadData h5UserUploadData:h5UserMobileMap.values()) {
|
||||
H5UserVO h5UserVO = h5UserMapper.selectByMobile(h5UserUploadData.getMobile());
|
||||
if (h5UserVO == null) {
|
||||
H5UserDTO h5UserDTO = new H5UserDTO();
|
||||
BeanUtils.copyProperties(h5UserUploadData, h5UserDTO);
|
||||
h5UserDTO.setCreateBy(createBy);
|
||||
h5UserMapper.createH5User(h5UserDTO);
|
||||
continue;
|
||||
}
|
||||
msg += "手机号为" + h5UserUploadData.getMobile() + "的用户之前已经添加过!\n";
|
||||
}
|
||||
}
|
||||
return ResultObject.success(msg);
|
||||
} catch (IOException e) {
|
||||
log.error("文件处理失败", e);
|
||||
return ResultObject.failed("文件处理失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
<jwt.version>4.4.0</jwt.version>
|
||||
<elasticsearch.version>8.12.2</elasticsearch.version>
|
||||
<jakartajson.version>2.0.1</jakartajson.version>
|
||||
<fesod.version>1.3.0</fesod.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -95,6 +96,11 @@
|
|||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.idev.excel</groupId>
|
||||
<artifactId>fastexcel</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import org.apache.ibatis.type.JdbcType;
|
|||
|
||||
import com.jinrui.reference.core.model.entity.News;
|
||||
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.NewsApiVO;
|
||||
import com.jinrui.reference.core.typehandler.JsonArrayTypeHandler;
|
||||
|
||||
|
|
@ -94,13 +95,18 @@ public interface NewsMapper {
|
|||
"news.exclusive, " +
|
||||
"news.company_name as companyName," +
|
||||
"news_tags.news_score as score, " +
|
||||
"news_tags.source as sourceName " +
|
||||
"news_tags.source as sourceName, " +
|
||||
"news.has_center as hasCenter, " +
|
||||
"news.center_id as centerId " +
|
||||
"from news " +
|
||||
"<if test=\"column != null and !column.isEmpty()\">" +
|
||||
"inner join news_column_rel on news.id = news_column_rel.news_id " +
|
||||
"</if>" +
|
||||
" left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
|
||||
"<where>" +
|
||||
"<if test=\"clusterSwitch == true\">" +
|
||||
" and not (news.has_center = 1 and news.newsinfo_id != news.center_id) " +
|
||||
"</if>" +
|
||||
"<if test=\"tags != null and tags.isEmpty()\">" +
|
||||
" and 1 = 2 " +
|
||||
"</if>" +
|
||||
|
|
@ -203,7 +209,8 @@ public interface NewsMapper {
|
|||
@Param("isSecondReviewRange") boolean isSecondReviewRange,
|
||||
@Param("includeRuleIds") List<Long> includeRuleIds,
|
||||
@Param("excludeRuleIds") List<Long> excludeRuleIds,
|
||||
@Param("companyName") String companyName);
|
||||
@Param("companyName") String companyName,
|
||||
@Param("clusterSwitch") Boolean clusterSwitch);
|
||||
|
||||
@Select("<script>" +
|
||||
"select count(*) from news " +
|
||||
|
|
@ -214,6 +221,9 @@ public interface NewsMapper {
|
|||
"left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
|
||||
"</if>" +
|
||||
"<where>" +
|
||||
"<if test=\"clusterSwitch == true\">" +
|
||||
" and not (news.has_center = 1 and news.newsinfo_id != news.center_id) " +
|
||||
"</if>" +
|
||||
"<if test=\"tags != null and tags.isEmpty()\">" +
|
||||
" and 1 = 2 " +
|
||||
"</if>" +
|
||||
|
|
@ -301,11 +311,12 @@ public interface NewsMapper {
|
|||
@Param("deleted") Integer deleted,
|
||||
@Param("rating") Byte rating,
|
||||
@Param("exclusive") Integer exclusive,
|
||||
@Param("isReviewer") boolean isReviewer,
|
||||
@Param("isSecondReviewRange") boolean isSecondReviewRange,
|
||||
@Param("isReviewer") Boolean isReviewer,
|
||||
@Param("isSecondReviewRange") Boolean isSecondReviewRange,
|
||||
@Param("includeRuleIds") List<Long> includeRuleIds,
|
||||
@Param("excludeRuleIds") List<Long> excludeRuleIds,
|
||||
@Param("companyName") String companyName);
|
||||
@Param("companyName") String companyName,
|
||||
@Param("clusterSwitch") Boolean clusterSwitch);
|
||||
|
||||
@Select("select id, llm_title as title, summary, picture, llm_content as content, status, " +
|
||||
"create_time as createTime, " +
|
||||
|
|
@ -314,10 +325,10 @@ public interface NewsMapper {
|
|||
"from news where newsinfo_id = #{newsinfoId}")
|
||||
News getNewsDetailByNewsInfoId(@Param("newsinfoId") String newsinfoId);
|
||||
|
||||
@Select("SELECT cluster_id FROM news WHERE newsinfo_id IS NOT NULL AND cluster_id IS NOT NULL GROUP BY cluster_id HAVING COUNT(*) > 1")
|
||||
@Select("SELECT cluster_id FROM news WHERE newsinfo_id IS NOT NULL AND cluster_id IS NOT NULL and publish_time >= curdate() GROUP BY cluster_id HAVING COUNT(*) > 1")
|
||||
List<String> getDuplicatedCluster();
|
||||
|
||||
@Select("select id, draft_id as draftId, newsinfo_id as newsinfoId, is_delete as deleted, editor_id as editorId, status from news where cluster_id = #{clusterId} and newsinfo_id IS NOT NULL")
|
||||
@Select("select id, draft_id as draftId, newsinfo_id as newsinfoId, is_delete as deleted, editor_id as editorId, status from news where cluster_id = #{clusterId} and newsinfo_id IS NOT NULL and publish_time >= curdate()")
|
||||
List<News> getDuplicatedNews(@Param("clusterId") String clusterId);
|
||||
|
||||
@Delete("delete from news where id = #{id}")
|
||||
|
|
@ -394,4 +405,90 @@ public interface NewsMapper {
|
|||
@Select(" select id, create_time from news " +
|
||||
" where is_delete = 0 and create_time > #{lastCheckTime} and ${signalRule} ")
|
||||
List<News> getSignalRuleNews(@Param("lastCheckTime") Date lastCheckTime, @Param("signalRule") String signalRule);
|
||||
|
||||
@Select(" select news.id as id, news.draft_id as draftId,news.llm_title as title, news.status as status, news.create_time as createTime, news.publish_time as publishTime, news.update_time as updateTime, news.newsinfo_id as newsinfoId, news.is_delete as deleted, news.rating, news.exclusive, news.company_name as companyName,news_tags.news_score as score, news_tags.source as sourceName "
|
||||
+ " from news left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
|
||||
" where has_center = 1 and news.newsinfo_id <> news.center_id and publish_time > #{publishTime} and center_id = #{centerId} order by publishTime")
|
||||
List<News> getClusterNews(@Param("publishTime") Date publishTime, @Param("centerId") String centerId);
|
||||
|
||||
|
||||
@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 = "published", property = "published"),
|
||||
@Result(column = "stock_codes", property = "stockCodes", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "stock_names", property = "stockNames", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "tdx_industry", property = "tdxIndustry", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "tdx_industry_confidence", property = "tdxIndustryConfidence", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "company_name", property = "companyName"),
|
||||
@Result(column = "news_score", property = "newsScore"),
|
||||
})
|
||||
@Select("<script>" +
|
||||
"select " +
|
||||
"news.id as id," +
|
||||
"news.llm_title," +
|
||||
"news.llm_content," +
|
||||
"news.summary, " +
|
||||
"news.publish_time," +
|
||||
"IF(news.status = 2, 1, 0) as published, " +
|
||||
"news.stock_codes," +
|
||||
"news.stock_names," +
|
||||
"news.tdx_industry," +
|
||||
"news.tdx_industry_confidence," +
|
||||
"news.company_name," +
|
||||
"(select news_tags.news_score from news_tags where news.newsinfo_id = news_tags.newsinfo_id) as news_score " +
|
||||
" from news " +
|
||||
"<where>" +
|
||||
" and news.status = 2 " +
|
||||
" and news.is_delete = 0 " +
|
||||
" and news.update_time >= (DATE_SUB(CURDATE(), INTERVAL 1 DAY) + INTERVAL 22 HOUR) " +
|
||||
" and news.update_time < adddate(date(now()), 1) " +
|
||||
"</where>" +
|
||||
" order by update_time desc " +
|
||||
" limit 200" +
|
||||
"</script>")
|
||||
List<NewsApi2VO> queryNewsByApi2();
|
||||
|
||||
@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 = "published", property = "published"),
|
||||
@Result(column = "stock_codes", property = "stockCodes", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "stock_names", property = "stockNames", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "tdx_industry", property = "tdxIndustry", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "tdx_industry_confidence", property = "tdxIndustryConfidence", typeHandler = JsonArrayTypeHandler.class),
|
||||
@Result(column = "company_name", property = "companyName"),
|
||||
@Result(column = "news_score", property = "newsScore"),
|
||||
})
|
||||
@Select("<script>" +
|
||||
"select " +
|
||||
"news.id as id," +
|
||||
"news.llm_title," +
|
||||
"news.llm_content," +
|
||||
"news.summary, " +
|
||||
"news.publish_time," +
|
||||
"IF(news.status = 2, 1, 0) as published, " +
|
||||
"news.stock_codes," +
|
||||
"news.stock_names," +
|
||||
"news.tdx_industry," +
|
||||
"news.tdx_industry_confidence," +
|
||||
"news.company_name," +
|
||||
"(select news_tags.news_score from news_tags where news.newsinfo_id = news_tags.newsinfo_id) as news_score " +
|
||||
" from news " +
|
||||
"<where>" +
|
||||
" and news.status != 2 " +
|
||||
" and news.is_delete = 0 and news.publish_time >= adddate(date(now()), -2) " +
|
||||
" and news.update_time >= CURDATE()" +
|
||||
" and news.update_time < adddate(date(now()), 1) " +
|
||||
"</where>" +
|
||||
" order by update_time desc " +
|
||||
" limit ${limit}" +
|
||||
"</script>")
|
||||
List<NewsApi2VO> queryNewsByApi3(@Param("limit") int limit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import com.jinrui.reference.core.model.dto.news.SaveNewsDTO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 新闻
|
||||
|
|
@ -107,6 +108,10 @@ public class News {
|
|||
|
||||
private String sourceName;
|
||||
|
||||
private Integer hasCenter;
|
||||
|
||||
private String centerId;
|
||||
|
||||
public News() {}
|
||||
|
||||
public News(SaveNewsDTO saveNewsDTO) {
|
||||
|
|
@ -359,4 +364,24 @@ public class News {
|
|||
public void setSourceName(String sourceName) {
|
||||
this.sourceName = sourceName;
|
||||
}
|
||||
|
||||
public Integer getHasCenter() {
|
||||
return hasCenter;
|
||||
}
|
||||
|
||||
public void setHasCenter(Integer hasCenter) {
|
||||
this.hasCenter = hasCenter;
|
||||
}
|
||||
|
||||
public String getCenterId() {
|
||||
return centerId;
|
||||
}
|
||||
|
||||
public void setCenterId(String centerId) {
|
||||
this.centerId = centerId;
|
||||
}
|
||||
|
||||
public boolean isCenter() {
|
||||
return Objects.equals(hasCenter, 1) && Objects.equals(newsinfoId, centerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,231 @@
|
|||
package com.jinrui.reference.core.model.vo.news;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
public class NewsApi2VO {
|
||||
/**
|
||||
* 资讯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<String> 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<String> getTdxIndustryConfidence() {
|
||||
return tdxIndustryConfidence;
|
||||
}
|
||||
|
||||
public void setTdxIndustryConfidence(List<String> 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,12 @@ public class NewsVO {
|
|||
|
||||
private List<String> ruleName;
|
||||
|
||||
private List<NewsVO> clusterNews;
|
||||
|
||||
private Integer index;
|
||||
|
||||
private Boolean isChild;
|
||||
|
||||
public NewsVO(News news) {
|
||||
this.id = news.getId();
|
||||
this.title = news.getTitle();
|
||||
|
|
@ -229,4 +235,28 @@ public class NewsVO {
|
|||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
public List<NewsVO> getClusterNews() {
|
||||
return clusterNews;
|
||||
}
|
||||
|
||||
public void setClusterNews(List<NewsVO> clusterNews) {
|
||||
this.clusterNews = clusterNews;
|
||||
}
|
||||
|
||||
public Boolean getIsChild() {
|
||||
return isChild;
|
||||
}
|
||||
|
||||
public void setIsChild(Boolean isChild) {
|
||||
this.isChild = isChild;
|
||||
}
|
||||
|
||||
public Integer getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(Integer index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import java.net.URLDecoder;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -63,6 +62,7 @@ import com.jinrui.reference.core.model.entity.Tag;
|
|||
import com.jinrui.reference.core.model.entity.UserOperationLog;
|
||||
import com.jinrui.reference.core.model.vo.PageObject;
|
||||
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.NewsApiVO;
|
||||
import com.jinrui.reference.core.model.vo.news.NewsDetailColumn;
|
||||
import com.jinrui.reference.core.model.vo.news.NewsDetailColumnVip;
|
||||
|
|
@ -852,7 +852,8 @@ public class NewsService {
|
|||
boolean isSecondReviewRange,
|
||||
String includeRuleIds,
|
||||
String excludeRuleIds,
|
||||
String companyName) {
|
||||
String companyName,
|
||||
Boolean clusterSwitch) {
|
||||
String orderByClause = null;
|
||||
if (StringUtils.hasText(orderBy)) {
|
||||
String orderByStr = orderBy;
|
||||
|
|
@ -927,7 +928,7 @@ public class NewsService {
|
|||
|
||||
List<News> newsList;
|
||||
try {
|
||||
newsList = newsMapper.queryNews(keywords, minScore, maxScore, columnParam, status, last, orderByClause, size, offset, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, isReviewer, isSecondReviewRange, includeSignalRules, excludeSignalRules, companyName);
|
||||
newsList = newsMapper.queryNews(keywords, minScore, maxScore, columnParam, status, last, orderByClause, size, offset, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, isReviewer, isSecondReviewRange, includeSignalRules, excludeSignalRules, companyName, clusterSwitch);
|
||||
} catch (Exception e) {
|
||||
log.error("搜索新闻异常!", e);
|
||||
return PageObject.failedPage(500, "服务器错误,请联系系统管理员!");
|
||||
|
|
@ -936,7 +937,7 @@ public class NewsService {
|
|||
PageObject<NewsVO> pageObject = new PageObject<>();
|
||||
if (page == 1) {
|
||||
try {
|
||||
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, isReviewer, isSecondReviewRange, includeSignalRules, excludeSignalRules, companyName);
|
||||
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, isReviewer, isSecondReviewRange, includeSignalRules, excludeSignalRules, companyName, clusterSwitch);
|
||||
pageObject.setTotal(total);
|
||||
} catch (Exception e) {
|
||||
log.error("获取新闻总数异常!", e);
|
||||
|
|
@ -954,18 +955,40 @@ public class NewsService {
|
|||
return pageObject;
|
||||
}
|
||||
|
||||
Map<Long, NewsVO> newsMap = new HashMap<>();
|
||||
Map<Long, NewsVO> draftMap = new HashMap<>();
|
||||
List<NewsVO> resultList = new ArrayList<>();
|
||||
for (News news : newsList) {
|
||||
NewsVO newsVO = new NewsVO(news);
|
||||
Long draftId = news.getDraftId();
|
||||
if (draftId != null) {
|
||||
draftMap.put(draftId, newsVO);
|
||||
} else {
|
||||
newsMap.put(newsVO.getId(), newsVO);
|
||||
NewsVO newsVO = toNewsVO(news, isReviewer);
|
||||
if (clusterSwitch != null && clusterSwitch == true) {
|
||||
if (news.isCenter()) {
|
||||
List<News> clusterNewsList = newsMapper.getClusterNews(news.getPublishTime(), news.getCenterId());
|
||||
if (!CollectionUtils.isEmpty(clusterNewsList)) {
|
||||
List<NewsVO> clusterNews = new ArrayList<>();
|
||||
for (int i = 0; i < clusterNewsList.size(); i++) {
|
||||
NewsVO clusterNewsVO = toNewsVO(clusterNewsList.get(i), isReviewer);
|
||||
clusterNewsVO.setIsChild(true);
|
||||
clusterNewsVO.setIndex(i);
|
||||
clusterNews.add(clusterNewsVO);
|
||||
}
|
||||
newsVO.setClusterNews(clusterNews);
|
||||
}
|
||||
}
|
||||
}
|
||||
resultList.add(newsVO);
|
||||
}
|
||||
|
||||
pageObject.setData(resultList);
|
||||
try {
|
||||
String pageString = objectMapper.writeValueAsString(pageObject);
|
||||
log.info("分页搜索结果: {}", pageString);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("json解析异常!", e);
|
||||
}
|
||||
return pageObject;
|
||||
}
|
||||
|
||||
private NewsVO toNewsVO(News news, boolean isReviewer) {
|
||||
NewsVO newsVO = new NewsVO(news);
|
||||
|
||||
newsVO.setSubmitter(this.getNewsLastEditor(news.getId()));
|
||||
if (isReviewer) {
|
||||
newsVO.setSubmitterSecond(this.getNewsLastReviewer(news.getId()));
|
||||
|
|
@ -985,16 +1008,7 @@ public class NewsService {
|
|||
|
||||
List<String> newsSignalRuleNames = newsSignalRuleRelMapper.getNewsSignalRuleNames(news.getId());
|
||||
newsVO.setRuleName(newsSignalRuleNames);
|
||||
}
|
||||
|
||||
pageObject.setData(resultList);
|
||||
try {
|
||||
String pageString = objectMapper.writeValueAsString(pageObject);
|
||||
log.info("分页搜索结果: {}", pageString);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("json解析异常!", e);
|
||||
}
|
||||
return pageObject;
|
||||
return newsVO;
|
||||
}
|
||||
|
||||
private String getNewsLastEditor(Long newsId) {
|
||||
|
|
@ -1275,4 +1289,114 @@ public class NewsService {
|
|||
public List<ListedCompany> getAllListedCompany(String companyName) {
|
||||
return listedCompanyMapper.queryAll(companyName);
|
||||
}
|
||||
|
||||
public ResultObject<Integer> getRealTotal(String keyword, String columnParam, Integer status, int page, int size,
|
||||
Integer last, Integer current, String orderBy, Double minScore, Double maxScore,
|
||||
String tag, String industry, Long mediaId,
|
||||
Date datelineFrom, Date datelineTo, Integer deleted, Byte rating,
|
||||
Integer exclusive,
|
||||
boolean isReviewer,
|
||||
boolean isSecondReviewRange,
|
||||
String includeRuleIds,
|
||||
String excludeRuleIds,
|
||||
String companyName) {
|
||||
|
||||
String orderByClause = null;
|
||||
if (StringUtils.hasText(orderBy)) {
|
||||
String orderByStr = orderBy;
|
||||
try {
|
||||
orderByStr = URLDecoder.decode(orderByStr, "UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
return ResultObject.failed(400, "排序参数异常! orderBy = " + orderBy);
|
||||
}
|
||||
orderByStr = orderByStr.replace("publishTime", "publish_time").replace("updateTime", "update_time").replace("createTime", "create_time");
|
||||
orderByClause = Stream.of(orderByStr.split(";")).map(e -> {
|
||||
String[] params = e.split("\\$");
|
||||
return "news." + params[0] + " " + params[1];
|
||||
}).collect(Collectors.joining(","));
|
||||
// 处理空值排在最后面的情况
|
||||
if (orderByStr.contains("score")) {
|
||||
orderByClause = orderByClause.replace("news.score", "news_tags.news_score");
|
||||
orderByClause = " IF(ISNULL(news_tags.news_score), 1, 0) asc, " + orderByClause;
|
||||
}
|
||||
} else {
|
||||
orderByClause = (deleted != null && (deleted.intValue() == 1))? "news.update_time desc":"news.publish_time desc";
|
||||
}
|
||||
int offset = 0;
|
||||
if (current != null) {
|
||||
// offset = (Math.max(0, page - current)) * size;
|
||||
offset = (Math.max(0, current - 1)) * size;
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(columnParam)) {
|
||||
String[] split = columnParam.split(",");
|
||||
for (String item : split) {
|
||||
try {
|
||||
Integer.parseInt(item);
|
||||
} catch (NumberFormatException e) {
|
||||
return ResultObject.failed(400, "栏目列表ID异常! column = " + columnParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Long> tags = this.getMatchTags(tag);
|
||||
if (mediaId != null) {
|
||||
if (ObjectUtils.isEmpty(tags)) {
|
||||
tags = new ArrayList<>();
|
||||
}
|
||||
tags.add(mediaId);
|
||||
}
|
||||
List<Long> industries = null;
|
||||
if (!ObjectUtils.isEmpty(industry)) {
|
||||
try {
|
||||
String industryStr = URLDecoder.decode(industry, "UTF-8");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
industries = objectMapper.readValue(industryStr, new TypeReference<List<Long>>() {});
|
||||
} catch (UnsupportedEncodingException|JsonProcessingException e) {
|
||||
log.error("资讯精选列表页面的行业分类参数异常!", e);
|
||||
return ResultObject.failed(500, "服务器错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> keywords = new ArrayList<>();
|
||||
if (StringUtils.hasText(keyword)) {
|
||||
keywords.addAll(Arrays.asList(keyword.trim().split("\\s+")));
|
||||
}
|
||||
|
||||
List<Long> includeSignalRules = null;
|
||||
if (StringUtils.hasText(includeRuleIds)) {
|
||||
includeSignalRules = Arrays.stream(includeRuleIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
List<Long> excludeSignalRules = null;
|
||||
if (StringUtils.hasText(excludeRuleIds)) {
|
||||
excludeSignalRules = Arrays.stream(excludeRuleIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
try {
|
||||
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, null, null, includeSignalRules, excludeSignalRules, companyName, false);
|
||||
return ResultObject.success(total);
|
||||
} catch (Exception e) {
|
||||
log.error("获取新闻总数异常!", e);
|
||||
return ResultObject.failed(500, "服务器错误,请联系系统管理员!");
|
||||
}
|
||||
}
|
||||
|
||||
public ResultObject<List<NewsApi2VO>> requestNewsByApi2() {
|
||||
List<NewsApi2VO> result = newsMapper.queryNewsByApi2();
|
||||
if (result.size() < 200) {
|
||||
int limit = 200 - result.size();
|
||||
result.addAll(newsMapper.queryNewsByApi3(limit));
|
||||
}
|
||||
|
||||
for(NewsApi2VO newsApi2VO: result) {
|
||||
if (newsApi2VO.getPublished()) {
|
||||
newsApi2VO.setSource("中国证券报");
|
||||
}
|
||||
List<String> newsSignalRuleNames = newsSignalRuleRelMapper.getNewsSignalRuleNames(newsApi2VO.getId());
|
||||
if (!CollectionUtils.isEmpty(newsSignalRuleNames) && newsSignalRuleNames.contains("海外宏观")) {
|
||||
newsApi2VO.setSignalRule("海外宏观");
|
||||
}
|
||||
}
|
||||
return ResultObject.success(result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue