Commit c6a13318 authored by shiyu's avatar shiyu

查询所有叶子类目

parent 78f49de1
...@@ -65,8 +65,6 @@ public class CategoryDaoImpl implements CategoryDao { ...@@ -65,8 +65,6 @@ public class CategoryDaoImpl implements CategoryDao {
return categoryMapper.selectByExample(example); return categoryMapper.selectByExample(example);
} }
public Category findById(Integer id) { public Category findById(Integer id) {
return categoryMapper.selectByPrimaryKey(id); return categoryMapper.selectByPrimaryKey(id);
} }
......
...@@ -3,6 +3,8 @@ package com.wwdz.ch.wx.entity.request; ...@@ -3,6 +3,8 @@ package com.wwdz.ch.wx.entity.request;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class CategoryRequestDto implements Entity { public class CategoryRequestDto implements Entity {
private Integer id; private Integer id;
...@@ -11,4 +13,5 @@ public class CategoryRequestDto implements Entity { ...@@ -11,4 +13,5 @@ public class CategoryRequestDto implements Entity {
private Integer size; private Integer size;
private String name; private String name;
private Integer pid; private Integer pid;
private List<Integer> pidList;
} }
...@@ -8,7 +8,6 @@ import com.wwdz.ch.db.dto.request.CategorySearchRequestDto; ...@@ -8,7 +8,6 @@ import com.wwdz.ch.db.dto.request.CategorySearchRequestDto;
import com.wwdz.ch.wx.entity.TransverseCategory; import com.wwdz.ch.wx.entity.TransverseCategory;
import com.wwdz.ch.wx.entity.request.CategoryRequestDto; import com.wwdz.ch.wx.entity.request.CategoryRequestDto;
import com.wwdz.ch.wx.entity.vo.CategoryResponseVo; import com.wwdz.ch.wx.entity.vo.CategoryResponseVo;
import com.wwdz.ch.wx.entity.vo.CategoryVo;
import com.wwdz.ch.wx.entity.vo.TransverseCategoryVo; import com.wwdz.ch.wx.entity.vo.TransverseCategoryVo;
import com.wwdz.ch.wx.service.CategoryService; import com.wwdz.ch.wx.service.CategoryService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -45,6 +44,9 @@ public class CategoryServiceImpl implements CategoryService { ...@@ -45,6 +44,9 @@ public class CategoryServiceImpl implements CategoryService {
public Result child(CategoryRequestDto dto) { public Result child(CategoryRequestDto dto) {
try { try {
logger.info("【请求结束】查询子类目成功"); logger.info("【请求结束】查询子类目成功");
if (!CollectionUtils.isEmpty(dto.getPidList())) {
return Result.success(categoryDao.queryByPids(dto.getPidList()));
}
return Result.success(categoryDao.queryByPid(dto.getId())); return Result.success(categoryDao.queryByPid(dto.getId()));
} catch (Exception e) { } catch (Exception e) {
logger.error("查询子类目失败", e); logger.error("查询子类目失败", e);
...@@ -208,4 +210,6 @@ public class CategoryServiceImpl implements CategoryService { ...@@ -208,4 +210,6 @@ public class CategoryServiceImpl implements CategoryService {
} }
return Result.failed(); return Result.failed();
} }
} }
...@@ -50,4 +50,6 @@ public interface CategoryService { ...@@ -50,4 +50,6 @@ public interface CategoryService {
* @return * @return
*/ */
Result findCategoryByTransverse(CategoryRequestDto dto); Result findCategoryByTransverse(CategoryRequestDto dto);
} }
...@@ -57,4 +57,11 @@ public class QueryPriceController { ...@@ -57,4 +57,11 @@ public class QueryPriceController {
public Result findTransverseCategory(@RequestBody CategoryRequestDto dto) { public Result findTransverseCategory(@RequestBody CategoryRequestDto dto) {
return categoryService.findCategoryByTransverse(dto); return categoryService.findCategoryByTransverse(dto);
} }
@ApiOperation(value = "查询所有叶子类目")
@PostMapping("/findAllChildCategory")
public Result findAllChildCategory(@RequestBody CategoryRequestDto dto) {
return categoryService.findCategoryByTransverse(dto);
}
} }
...@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -43,7 +44,7 @@ public class WxCategoryController { ...@@ -43,7 +44,7 @@ public class WxCategoryController {
@PostMapping(value = "/child") @PostMapping(value = "/child")
public Result child(@RequestBody CategoryRequestDto dto) { public Result child(@RequestBody CategoryRequestDto dto) {
logger.info("【请求开始】查询子分类列表,请求参数:{}", JSON.toJSONString(dto)); logger.info("【请求开始】查询子分类列表,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getId())) { if (Objects.isNull(dto.getId()) && CollectionUtils.isEmpty(dto.getPidList())) {
return Result.failed("分类id不能为空"); return Result.failed("分类id不能为空");
} }
return categoryService.child(dto); return categoryService.child(dto);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment