商品查询、商品详情

pull/1/head
chuzhichao 2 years ago
parent 2f85186ab9
commit 60460eb046

@ -28,8 +28,8 @@ public class H5ProductController {
List<Product> pageRes = productService.selectList(query, page);
return ResponseEntity.ok(new PageImpl<>(productConvert.dos2dtos(pageRes), page, ((com.github.pagehelper.Page) pageRes).getTotal()));
}
@GetMapping("/detail")
public ResponseEntity<ProductDetail> queryDetail(@RequestParam Long id) {
@GetMapping("/detail/{id}")
public ResponseEntity<ProductDetail> queryDetail(@PathVariable Long id) {
ProductDetail detail = productService.queryDetail(id);
return ResponseEntity.ok(detail);
}

@ -63,4 +63,13 @@ public class ProductQuery {
@ApiModelProperty("商品分类名称 精确匹配")
private String productCategoryNameLike;
@ApiModelProperty("排序字段")
private String orderField = "sort";
@ApiModelProperty("排序规则")
private String orderSort = "desc";
@ApiModelProperty("搜索关键字")
private String search;
}

@ -215,7 +215,7 @@ public class ProductCategoryService {
QueryWrapper<ProductCategory> qw = new QueryWrapper<>();
qw.select("id", "parent_id", "name", "level", "sort", "icon");
qw.eq("show_status", 1);
qw.le("level", 2);
// qw.le("level", 2);
return productCategoryMapper.selectList(qw);
}

@ -72,67 +72,27 @@ public class ProductService {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
QueryWrapper<Product> qw = new QueryWrapper<>();
if (StringUtils.isNoneEmpty(query.getOrderField())){
if (StringUtils.isNotEmpty(query.getOrderSort()) && "desc".equalsIgnoreCase(query.getOrderSort())) {
qw.orderByDesc(query.getOrderField());
} else {
qw.orderByAsc(query.getOrderField());
}
}else {
qw.orderByDesc("publish_status");
qw.orderByAsc("sort");
Long brandId = query.getBrandId();
if (brandId != null) {
qw.eq("brand_id", brandId);
}
Long categoryId = query.getCategoryId();
if (categoryId != null) {
qw.eq("category_id", categoryId);
}
String outProductId = query.getOutProductId();
if (!StringUtils.isEmpty(outProductId)) {
qw.eq("out_product_id", outProductId);
}
String nameLike = query.getNameLike();
if (!StringUtils.isEmpty(nameLike)) {
qw.like("name", nameLike);
}
String pic = query.getPic();
if (!StringUtils.isEmpty(pic)) {
qw.eq("pic", pic);
}
String albumPics = query.getAlbumPics();
if (!StringUtils.isEmpty(albumPics)) {
qw.eq("album_pics", albumPics);
}
Integer publishStatus = query.getPublishStatus();
if (publishStatus != null) {
qw.eq("publish_status", publishStatus);
}
Integer sort = query.getSort();
if (sort != null) {
qw.eq("sort", sort);
}
BigDecimal price = query.getPrice();
if (price != null) {
qw.eq("price", price);
}
String unit = query.getUnit();
if (!StringUtils.isEmpty(unit)) {
qw.eq("unit", unit);
}
BigDecimal weight = query.getWeight();
if (weight != null) {
qw.eq("weight", weight);
}
String detailHtml = query.getDetailHtml();
if (!StringUtils.isEmpty(detailHtml)) {
qw.eq("detail_html", detailHtml);
}
String detailMobileHtml = query.getDetailMobileHtml();
if (!StringUtils.isEmpty(detailMobileHtml)) {
qw.eq("detail_mobile_html", detailMobileHtml);
}
String brandNameLike = query.getBrandNameLike();
if (!StringUtils.isEmpty(brandNameLike)) {
qw.like("brand_name", brandNameLike);
}
String productCategoryNameLike = query.getProductCategoryNameLike();
if (!StringUtils.isEmpty(productCategoryNameLike)) {
qw.like("product_category_name", productCategoryNameLike);
String search = query.getSearch();
if (StringUtils.isNoneEmpty(search)){
qw.like("name", "%".concat(query.getSearch().trim()).concat("%"));
}
return productMapper.selectList(qw);
}

Loading…
Cancel
Save