行业分类新增删除以及资讯详情页面行业分类接口
This commit is contained in:
parent
1c7632a821
commit
9555c55cfb
|
|
@ -2,9 +2,21 @@ package com.jinrui.reference.admin.controller;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
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.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.dto.news.SaveIndustryDTO;
|
||||||
|
import com.jinrui.reference.core.model.vo.PageObject;
|
||||||
|
import com.jinrui.reference.core.model.vo.ResultObject;
|
||||||
|
import com.jinrui.reference.core.model.vo.tag.IndustryVO;
|
||||||
import com.jinrui.reference.core.service.IndustryService;
|
import com.jinrui.reference.core.service.IndustryService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,5 +32,98 @@ public class IndustryController {
|
||||||
public IndustryController(IndustryService industryService) {
|
public IndustryController(IndustryService industryService) {
|
||||||
this.industryService = industryService;
|
this.industryService = industryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建频道标签
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResultObject<Void> create(@RequestHeader("auth-token") String token,
|
||||||
|
@RequestBody SaveIndustryDTO saveIndustryDTO
|
||||||
|
) {
|
||||||
|
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("当前用户已被封禁!请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return industryService.create(saveIndustryDTO.getPrimaryName(), saveIndustryDTO.getSecondaryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业分类删除
|
||||||
|
* @param token
|
||||||
|
* @param saveTagsDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResultObject<Void> delete(@RequestHeader("auth-token") String token,
|
||||||
|
@RequestBody SaveIndustryDTO saveIndustryDTO
|
||||||
|
) {
|
||||||
|
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("当前用户已被封禁!请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return industryService.delete(saveIndustryDTO.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业分类搜索接口
|
||||||
|
*
|
||||||
|
* @param token 登陆Token
|
||||||
|
* @param keyword 关键字 可以为空
|
||||||
|
* @param page 分页参数 当前页码 默认第一页
|
||||||
|
* @param size 分页参数 当前页长度 默认10条
|
||||||
|
* @param orderBy 排序参数 要排序的字段
|
||||||
|
* @param direction 排序参数 排序方向
|
||||||
|
* @return 标签搜索结果
|
||||||
|
*/
|
||||||
|
@GetMapping
|
||||||
|
public PageObject<IndustryVO> queryIndustry(@RequestHeader("auth-token") String token,
|
||||||
|
@RequestParam(value = "keyword", required = false) String keyword,
|
||||||
|
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
||||||
|
@RequestParam(value = "size", required = false, defaultValue = "10") int size,
|
||||||
|
@RequestParam(value = "orderBy", required = false, defaultValue = "id") String orderBy,
|
||||||
|
@RequestParam(value = "direction", required = false, defaultValue = "asc") String direction) {
|
||||||
|
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: /tag, method: GET, request user id: {}, " +
|
||||||
|
"keyword: {}, exclude: {}, page: {}, size: {}, orderBy: {}, direction: {}",
|
||||||
|
adminUser.getId(), keyword, page, size, orderBy, direction);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("解析登陆Token出错!", e);
|
||||||
|
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return industryService.queryIndustry(keyword, page, size, orderBy, direction);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@ package com.jinrui.reference.core.mapper;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
|
import org.apache.ibatis.annotations.Options;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Result;
|
import org.apache.ibatis.annotations.Result;
|
||||||
import org.apache.ibatis.annotations.Results;
|
import org.apache.ibatis.annotations.Results;
|
||||||
|
|
@ -31,4 +34,49 @@ public interface IndustryMapper {
|
||||||
@Select("select id, news_id as newsId, industry_id as industryId " +
|
@Select("select id, news_id as newsId, industry_id as industryId " +
|
||||||
"from news_industry_rel where news_id = #{newsId}")
|
"from news_industry_rel where news_id = #{newsId}")
|
||||||
List<NewsIndustryRel> getNewsIndustryRelList(@Param("newsId") Long newsId);
|
List<NewsIndustryRel> getNewsIndustryRelList(@Param("newsId") Long newsId);
|
||||||
|
|
||||||
|
@Select("select * from industry where primary_name = #{primayName} and parent_id = 0")
|
||||||
|
Industry queryPrimaryIndustry(String primayName);
|
||||||
|
|
||||||
|
@Select("select * from industry where secondary_name = #{secondaryName} and parent_id = #{parentId}")
|
||||||
|
Industry querySecondaryIndustry(Long parentId,String secondaryName);
|
||||||
|
|
||||||
|
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||||
|
@Insert("insert into industry(parent_id, primary_name, secondary_name, create_time, update_time) values (#{parentId}, #{primaryName}, #{secondaryName}, now(), now())")
|
||||||
|
void saveIndustry(Industry industry);
|
||||||
|
|
||||||
|
@Delete("delete from industry where id = #{id}")
|
||||||
|
void deleteIndustry(@Param("id") Long id);
|
||||||
|
|
||||||
|
// 获取行业分类是否有关联过资讯
|
||||||
|
@Select("SELECT count(id) " +
|
||||||
|
"from news_industry_rel where industry_id = #{industryId}")
|
||||||
|
Long countNewsIndustryRelList(@Param("industryId") Long industryId);
|
||||||
|
|
||||||
|
// 获取行业分类是否有关联过资讯
|
||||||
|
@Select("SELECT count(id) " +
|
||||||
|
"from draft_industry_rel where industry_id = #{industryId}")
|
||||||
|
Long countDraftIndustryRelList(@Param("industryId") Long industryId);
|
||||||
|
|
||||||
|
@Results({
|
||||||
|
@Result(column = "id", property = "id", id = true),
|
||||||
|
@Result(column = "parent_id", property = "parentId"),
|
||||||
|
@Result(column = "primay_name", property = "primayName"),
|
||||||
|
@Result(column = "secondary_name", property = "secondaryName"),
|
||||||
|
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||||
|
@Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
|
||||||
|
})
|
||||||
|
@Select("<script>" +
|
||||||
|
"select * from industry" +
|
||||||
|
"<where>" +
|
||||||
|
"<if test=\"keyword != null and !keyword.isEmpty()\">" +
|
||||||
|
"primay_name like concat('%', #{keyword}, '%') or secondary_name like concat('%', #{keyword}, '%') " +
|
||||||
|
"</if>" +
|
||||||
|
"</where>" +
|
||||||
|
"order by tag.${orderBy} " +
|
||||||
|
"<if test=\"'desc'.equals(direction)\">" +
|
||||||
|
"desc" +
|
||||||
|
"</if>" +
|
||||||
|
"</script>")
|
||||||
|
List<Industry> queryIndustry(@Param("keyword") String keyword, @Param("orderBy") String orderBy, @Param("direction") String direction);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.jinrui.reference.core.model.dto.news;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class SaveIndustryDTO {
|
||||||
|
private Long id;
|
||||||
|
private String primaryName;
|
||||||
|
private String secondaryName;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrimaryName() {
|
||||||
|
return primaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrimaryName(String primaryName) {
|
||||||
|
this.primaryName = primaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecondaryName() {
|
||||||
|
return secondaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecondaryName(String secondaryName) {
|
||||||
|
this.secondaryName = secondaryName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,8 @@ package com.jinrui.reference.core.model.entity;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行业分类
|
* 行业分类
|
||||||
*/
|
*/
|
||||||
|
|
@ -11,6 +13,11 @@ public class Industry {
|
||||||
* 行业分类ID
|
* 行业分类ID
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级分类ID
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一级行业
|
* 一级行业
|
||||||
|
|
@ -39,6 +46,14 @@ public class Industry {
|
||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getParentId() {
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentId(Long parentId) {
|
||||||
|
this.parentId = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPrimayName() {
|
public String getPrimayName() {
|
||||||
return primayName;
|
return primayName;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ package com.jinrui.reference.core.model.vo.news;
|
||||||
public class NewsDetailIndustry {
|
public class NewsDetailIndustry {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String name;
|
private String primayName;
|
||||||
|
|
||||||
|
private String secondaryName;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -14,11 +16,19 @@ public class NewsDetailIndustry {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getPrimayName() {
|
||||||
return name;
|
return primayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setPrimayName(String primayName) {
|
||||||
this.name = name;
|
this.primayName = primayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecondaryName() {
|
||||||
|
return secondaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecondaryName(String secondaryName) {
|
||||||
|
this.secondaryName = secondaryName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.jinrui.reference.core.model.vo.tag;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.jinrui.reference.core.model.entity.Industry;
|
||||||
|
import com.jinrui.reference.core.model.entity.Tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业分类
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class IndustryVO {
|
||||||
|
/**
|
||||||
|
* 行业分类ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级行业名称
|
||||||
|
*/
|
||||||
|
private String primayName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二级行业名称
|
||||||
|
*/
|
||||||
|
private String secondaryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@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 IndustryVO(Industry industry) {
|
||||||
|
this.id = industry.getId();
|
||||||
|
this.parentId = industry.getParentId();
|
||||||
|
this.primayName = industry.getPrimayName();
|
||||||
|
this.secondaryName = industry.getSecondaryName();
|
||||||
|
this.createTime = industry.getCreateTime();
|
||||||
|
this.updateTime = industry.getUpdateTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getParentId() {
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentId(Long parentId) {
|
||||||
|
this.parentId = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrimayName() {
|
||||||
|
return primayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrimayName(String primayName) {
|
||||||
|
this.primayName = primayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecondaryName() {
|
||||||
|
return secondaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecondaryName(String secondaryName) {
|
||||||
|
this.secondaryName = secondaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,22 @@
|
||||||
package com.jinrui.reference.core.service;
|
package com.jinrui.reference.core.service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
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.StringUtils;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jinrui.reference.core.mapper.IndustryMapper;
|
import com.jinrui.reference.core.mapper.IndustryMapper;
|
||||||
|
import com.jinrui.reference.core.model.entity.Industry;
|
||||||
|
import com.jinrui.reference.core.model.vo.PageObject;
|
||||||
|
import com.jinrui.reference.core.model.vo.ResultObject;
|
||||||
|
import com.jinrui.reference.core.model.vo.tag.IndustryVO;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class IndustryService {
|
public class IndustryService {
|
||||||
|
|
@ -18,5 +29,101 @@ public class IndustryService {
|
||||||
this.objectMapper = objectMapper;
|
this.objectMapper = objectMapper;
|
||||||
this.industryMapper = industryMapper;
|
this.industryMapper = industryMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResultObject<Void> create(String primaryName, String secondaryName) {
|
||||||
|
Industry industry = industryMapper.queryPrimaryIndustry(primaryName);
|
||||||
|
if (industry == null) {
|
||||||
|
Industry primaryIndustry = new Industry();
|
||||||
|
primaryIndustry.setParentId(0L);
|
||||||
|
primaryIndustry.setPrimayName(primaryName);
|
||||||
|
industryMapper.saveIndustry(primaryIndustry);
|
||||||
|
industry = primaryIndustry;
|
||||||
|
}
|
||||||
|
|
||||||
|
Industry secondaryIndustry = industryMapper.querySecondaryIndustry(industry.getId(), secondaryName);
|
||||||
|
|
||||||
|
if(secondaryIndustry != null){
|
||||||
|
return ResultObject.failed("该行业分类已存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
secondaryIndustry = new Industry();
|
||||||
|
secondaryIndustry.setParentId(industry.getId());
|
||||||
|
secondaryIndustry.setPrimayName(primaryName);
|
||||||
|
secondaryIndustry.setSecondaryName(secondaryName);
|
||||||
|
industryMapper.saveIndustry(secondaryIndustry);
|
||||||
|
return ResultObject.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultObject<Void> delete(Long id) {
|
||||||
|
|
||||||
|
if(industryMapper.countNewsIndustryRelList(id)> 0 || industryMapper.countDraftIndustryRelList(id)>0){
|
||||||
|
return ResultObject.failed("行业分类已经关联过资讯,无法删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
industryMapper.deleteIndustry(id);
|
||||||
|
return ResultObject.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签搜索接口
|
||||||
|
*
|
||||||
|
* @param keyword 关键字 可以为空
|
||||||
|
* @param page 分页参数 当前页码 默认第一页
|
||||||
|
* @param size 分页参数 当前页长度 默认10条
|
||||||
|
* @return 标签搜索结果
|
||||||
|
*/
|
||||||
|
public PageObject<IndustryVO> queryIndustry(String keyword,int page, int size, String orderBy, String direction) {
|
||||||
|
if (StringUtils.hasText(orderBy)) {
|
||||||
|
switch (orderBy) {
|
||||||
|
case "updateTime": {
|
||||||
|
orderBy = "update_time";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "createTime": {
|
||||||
|
orderBy = "create_time";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Industry> industrys;
|
||||||
|
try {
|
||||||
|
industrys = industryMapper.queryIndustry(keyword, orderBy, direction);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("搜索行业分类出错!", e);
|
||||||
|
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(industrys)) {
|
||||||
|
log.warn("keyword: {}, 找不到对应的行业分类!", keyword);
|
||||||
|
return PageObject.empty(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageObject<IndustryVO> resultPage = new PageObject<>();
|
||||||
|
resultPage.setCode(200);
|
||||||
|
resultPage.setTotal(industrys.size());
|
||||||
|
List<IndustryVO> resultList = industrys.stream()
|
||||||
|
.skip((long) (page - 1) * size)
|
||||||
|
.limit(size)
|
||||||
|
.map(IndustryVO::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(resultList)) {
|
||||||
|
log.info("keyword: {}, page: {}, size: {}, 当前页无数据!", keyword, page, size);
|
||||||
|
resultPage.setCurrent(page);
|
||||||
|
resultPage.setSize(0);
|
||||||
|
resultPage.setData(new ArrayList<>());
|
||||||
|
return resultPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultPage.setData(resultList);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String pageString = objectMapper.writeValueAsString(resultPage);
|
||||||
|
log.info("查询结果: {}", pageString);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.error("查询行业分类返回值json映射出错!", e);
|
||||||
|
}
|
||||||
|
return resultPage;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,8 @@ public class NewsService {
|
||||||
Industry industry = industryMap.get(industryId);
|
Industry industry = industryMap.get(industryId);
|
||||||
NewsDetailIndustry newsDetailIndustry = new NewsDetailIndustry();
|
NewsDetailIndustry newsDetailIndustry = new NewsDetailIndustry();
|
||||||
newsDetailIndustry.setId(industryId);
|
newsDetailIndustry.setId(industryId);
|
||||||
newsDetailIndustry.setName(industry.getPrimayName() + "-" + industry.getSecondaryName());
|
newsDetailIndustry.setPrimayName(industry.getPrimayName());
|
||||||
|
newsDetailIndustry.setSecondaryName(industry.getSecondaryName());
|
||||||
newsIndustryList.add(newsDetailIndustry);
|
newsIndustryList.add(newsDetailIndustry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,7 +302,8 @@ public class NewsService {
|
||||||
Industry industry = industryMap.get(industryId);
|
Industry industry = industryMap.get(industryId);
|
||||||
NewsDetailIndustry newsDetailIndustry = new NewsDetailIndustry();
|
NewsDetailIndustry newsDetailIndustry = new NewsDetailIndustry();
|
||||||
newsDetailIndustry.setId(industryId);
|
newsDetailIndustry.setId(industryId);
|
||||||
newsDetailIndustry.setName(industry.getPrimayName() + "-" + industry.getSecondaryName());
|
newsDetailIndustry.setPrimayName(industry.getPrimayName());
|
||||||
|
newsDetailIndustry.setSecondaryName(industry.getSecondaryName());
|
||||||
newsIndustryList.add(newsDetailIndustry);
|
newsIndustryList.add(newsDetailIndustry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue