行业分类列表获取接口增加parentid参数
This commit is contained in:
parent
9555c55cfb
commit
7a844be077
|
|
@ -94,6 +94,7 @@ public class IndustryController {
|
|||
*/
|
||||
@GetMapping
|
||||
public PageObject<IndustryVO> queryIndustry(@RequestHeader("auth-token") String token,
|
||||
@RequestParam(value = "parentId", required = false, defaultValue = "-1") long parentId,
|
||||
@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,
|
||||
|
|
@ -123,7 +124,7 @@ public class IndustryController {
|
|||
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||
}
|
||||
|
||||
return industryService.queryIndustry(keyword, page, size, orderBy, direction);
|
||||
return industryService.queryIndustry(parentId, keyword, page, size, orderBy, direction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,8 +69,11 @@ public interface IndustryMapper {
|
|||
@Select("<script>" +
|
||||
"select * from industry" +
|
||||
"<where>" +
|
||||
"<if test=\"parentId != null\">" +
|
||||
"parent_id = #{parentId} " +
|
||||
"</if>" +
|
||||
"<if test=\"keyword != null and !keyword.isEmpty()\">" +
|
||||
"primay_name like concat('%', #{keyword}, '%') or secondary_name like concat('%', #{keyword}, '%') " +
|
||||
"and primay_name like concat('%', #{keyword}, '%') or secondary_name like concat('%', #{keyword}, '%') " +
|
||||
"</if>" +
|
||||
"</where>" +
|
||||
"order by tag.${orderBy} " +
|
||||
|
|
@ -78,5 +81,5 @@ public interface IndustryMapper {
|
|||
"desc" +
|
||||
"</if>" +
|
||||
"</script>")
|
||||
List<Industry> queryIndustry(@Param("keyword") String keyword, @Param("orderBy") String orderBy, @Param("direction") String direction);
|
||||
List<Industry> queryIndustry(@Param("parentId") Long parentId, @Param("keyword") String keyword, @Param("orderBy") String orderBy, @Param("direction") String direction);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class IndustryService {
|
|||
* @param size 分页参数 当前页长度 默认10条
|
||||
* @return 标签搜索结果
|
||||
*/
|
||||
public PageObject<IndustryVO> queryIndustry(String keyword,int page, int size, String orderBy, String direction) {
|
||||
public PageObject<IndustryVO> queryIndustry(long parentId, String keyword,int page, int size, String orderBy, String direction) {
|
||||
if (StringUtils.hasText(orderBy)) {
|
||||
switch (orderBy) {
|
||||
case "updateTime": {
|
||||
|
|
@ -88,7 +88,13 @@ public class IndustryService {
|
|||
|
||||
List<Industry> industrys;
|
||||
try {
|
||||
industrys = industryMapper.queryIndustry(keyword, orderBy, direction);
|
||||
if (parentId == -1) {
|
||||
industrys = industryMapper.queryIndustry(null, keyword, orderBy, direction);
|
||||
} else {
|
||||
industrys = industryMapper.queryIndustry(parentId, keyword, orderBy, direction);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("搜索行业分类出错!", e);
|
||||
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
|
||||
|
|
|
|||
Loading…
Reference in New Issue