master:APP 首页分类及分类页代码;
parent
2b29c9cdb6
commit
188c12ab69
|
|
@ -4,17 +4,17 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.vo.productCategory.AppHomeProdCateListResVO;
|
||||
import com.ruoyi.common.core.domain.vo.productCategory.ProdCateListResVO;
|
||||
import com.ruoyi.common.core.domain.vo.productCategory.ProdCateListVO;
|
||||
import com.ruoyi.common.core.domain.vo.productCategory.ProdCateVO;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateListDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateListResDTO;
|
||||
import com.ruoyi.system.service.ISysProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -83,8 +83,29 @@ public class SysProductCategoryController extends XktBaseController {
|
|||
// @PreAuthorize("@ss.hasPermi('system:category:list')")
|
||||
@ApiOperation(value = "获取商品分类列表", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/list")
|
||||
public R<List<ProdCateListResDTO>> list(@RequestBody ProdCateListVO listVO) {
|
||||
return R.ok(BeanUtil.copyToList(prodCateService.selectList(BeanUtil.toBean(listVO, ProdCateListDTO.class)), ProdCateListResDTO.class));
|
||||
public R<List<ProdCateListResVO>> list(@RequestBody ProdCateListVO listVO) {
|
||||
return R.ok(BeanUtil.copyToList(prodCateService.selectList(BeanUtil.toBean(listVO, ProdCateListDTO.class)), ProdCateListResVO.class));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP首页获取商品分类
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('system:category:list')")
|
||||
@ApiOperation(value = "APP首页获取商品分类", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/app/home/list")
|
||||
public R<List<AppHomeProdCateListResVO>> appHomeCate() {
|
||||
return R.ok(BeanUtil.copyToList(prodCateService.selectAppHomeCate(), AppHomeProdCateListResVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* APP分类页
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('system:category:list')")
|
||||
@ApiOperation(value = "APP分类页", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/app/list")
|
||||
public R<List<AppHomeProdCateListResVO>> appCate() {
|
||||
return R.ok(BeanUtil.copyToList(prodCateService.appCate(), AppHomeProdCateListResVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -210,10 +210,13 @@ public class Constants
|
|||
public static final String EXPRESS_REGION_MAP_CACHE_KEY = "EXPRESS_REGION_MAP";
|
||||
public static final String EXPRESS_REGION_LIST_CACHE_KEY = "EXPRESS_REGION_LIST";
|
||||
public static final String EXPRESS_REGION_TREE_CACHE_KEY = "EXPRESS_REGION_TREE";
|
||||
|
||||
// ES 索引 product_info
|
||||
/**
|
||||
* ES 索引 product_info
|
||||
*/
|
||||
public static final String ES_IDX_PRODUCT_INFO = "product_info";
|
||||
|
||||
|
||||
/**
|
||||
* 最顶层商品分类ID
|
||||
*/
|
||||
public static final Long TOPMOST_PRODUCT_CATEGORY_ID = 1L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.common.core.domain.vo.productCategory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("APP首页商品分类")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AppHomeProdCateListResVO {
|
||||
|
||||
@ApiModelProperty(value = "商品分类主键")
|
||||
@JsonProperty(value = "prodCateId")
|
||||
private Long id;
|
||||
@ApiModelProperty(name = "分类名称")
|
||||
private String name;
|
||||
@ApiModelProperty(name = "显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.system.domain.dto.productCategory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("APP首页商品分类")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AppHomeProdCateListResDTO {
|
||||
|
||||
@ApiModelProperty(value = "商品分类主键")
|
||||
private Long id;
|
||||
@ApiModelProperty(name = "分类名称")
|
||||
private String name;
|
||||
@ApiModelProperty(name = "显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.vo.productCategory.ProdCateVO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.AppHomeProdCateListResDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateListDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateListResDTO;
|
||||
|
|
@ -40,6 +40,7 @@ public interface ISysProductCategoryService {
|
|||
|
||||
/**
|
||||
* 获取商品分类详情
|
||||
*
|
||||
* @param prodCateId 商品分类ID
|
||||
* @return ProdCateDTO
|
||||
*/
|
||||
|
|
@ -47,9 +48,24 @@ public interface ISysProductCategoryService {
|
|||
|
||||
/**
|
||||
* 获取商品分类列表
|
||||
*
|
||||
* @param listDTO 查询入参
|
||||
* @return List<ProdCateListResDTO>
|
||||
*/
|
||||
List<ProdCateListResDTO> selectList(ProdCateListDTO listDTO);
|
||||
|
||||
/**
|
||||
* 获取APP首页商品分类
|
||||
*
|
||||
* @return List<AppHomeProdCateListResDTO>
|
||||
*/
|
||||
List<AppHomeProdCateListResDTO> selectAppHomeCate();
|
||||
|
||||
/**
|
||||
* 获取APP分类页
|
||||
*
|
||||
* @return List<AppHomeProdCateListResDTO>
|
||||
*/
|
||||
List<AppHomeProdCateListResDTO> appCate();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.ruoyi.common.constant.Constants;
|
|||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.entity.SysProductCategory;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.system.domain.dto.productCategory.AppHomeProdCateListResDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateListDTO;
|
||||
import com.ruoyi.system.domain.dto.productCategory.ProdCateListResDTO;
|
||||
|
|
@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ruoyi.common.constant.Constants.TOPMOST_PRODUCT_CATEGORY_ID;
|
||||
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
/**
|
||||
|
|
@ -125,6 +127,40 @@ public class SysProductCategoryServiceImpl implements ISysProductCategoryService
|
|||
return this.buildCateTree(resList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取APP首页商品分类
|
||||
*
|
||||
* @return List<AppHomeProdCateListResDTO>
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<AppHomeProdCateListResDTO> selectAppHomeCate() {
|
||||
List<SysProductCategory> prodCateList = this.prodCateMapper.selectList(new LambdaQueryWrapper<SysProductCategory>()
|
||||
.eq(SysProductCategory::getDelFlag, Constants.UNDELETED)
|
||||
.eq(SysProductCategory::getParentId, TOPMOST_PRODUCT_CATEGORY_ID));
|
||||
// 返回前4个排序的分类
|
||||
return CollectionUtils.isEmpty(prodCateList) ? new ArrayList<>()
|
||||
: prodCateList.stream().sorted(Comparator.comparing(SysProductCategory::getOrderNum)).limit(4)
|
||||
.map(x -> BeanUtil.toBean(x, AppHomeProdCateListResDTO.class)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取APP分类页
|
||||
*
|
||||
* @return List<AppHomeProdCateListResDTO>
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<AppHomeProdCateListResDTO> appCate() {
|
||||
List<SysProductCategory> prodCateList = this.prodCateMapper.selectList(new LambdaQueryWrapper<SysProductCategory>()
|
||||
.eq(SysProductCategory::getDelFlag, Constants.UNDELETED)
|
||||
.eq(SysProductCategory::getParentId, TOPMOST_PRODUCT_CATEGORY_ID));
|
||||
return CollectionUtils.isEmpty(prodCateList) ? new ArrayList<>()
|
||||
: prodCateList.stream().sorted(Comparator.comparing(SysProductCategory::getOrderNum)
|
||||
.thenComparing(SysProductCategory::getId))
|
||||
.map(x -> BeanUtil.toBean(x, AppHomeProdCateListResDTO.class)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组装商品分类树
|
||||
|
|
|
|||
Loading…
Reference in New Issue