Commit f43a292e authored by liuzeheng's avatar liuzeheng

商品列表支持多选

parent 7958bb32
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.product.dal.mysql.product;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductDO;
import cn.iocoder.yudao.module.product.dto.ProductReqDTO;
import cn.iocoder.yudao.module.product.vo.product.ProductExportReqVO;
import cn.iocoder.yudao.module.product.vo.product.ProductPageReqVO;
import cn.iocoder.yudao.module.product.vo.product.ProductTypeNumVO;
......@@ -97,6 +98,80 @@ public interface ProductMapper extends BaseMapperX<ProductDO> {
})
IPage<ProductDO> selectPage2(IPage<ProductDO> mpPage, @Param("query") ProductPageReqVO query);
@ResultType(ProductDO.class)
@Select({
"<script>",
"select t.*, c.nickname as creator_name, u.nickname as updater_name ",
"from ecw_product t ",
"left join system_user c on t.creator = c.id ",
"left join system_user u on t.updater = u.id ",
"where t.deleted = 0 ",
"<when test = 'query.productCode != null and query.productCode != \"\"'>",
"AND t.`product_code` like concat('%',concat(#{query.productCode},'%'))",
"</when>",
"<when test = 'query.customsCode != null and query.customsCode != \"\"'>",
"AND t.`customs_code` like concat('%',concat(#{query.customsCode},'%'))",
"</when>",
/* "<when test = 'query.typeId != null'>",
"AND t.`type_id` = #{query.typeId}",
"</when>",*/
"<when test=\"query.typeId != null and query.typeId.size()>0\">" +
" <when test=\"query.typeId != null and query.typeId != '' and query.typeId.size()==1 \">" +
" AND t.`type_id` =\n" +
" <foreach item='typeId' index='index' collection='query.typeId' >\n" +
" #{typeId}" +
" </foreach>" +
" </when>" +
" <when test=\"query.typeId != null and query.typeId != '' and query.typeId.size()>1 \">" +
" AND t.`type_id` in " +
" <foreach item='typeId' index='index' collection='query.typeId' open='(' separator=',' close=')'>" +
" #{typeId}" +
" </foreach>" +
" </when>" +
"</when>",
"<when test = 'query.status != null'>",
"AND t.`status` = #{query.status}",
"</when>",
"<when test = 'query.auditStatus != null'>",
"AND t.`audit_status` = #{query.auditStatus}",
"</when>",
"<when test = 'query.titleZh != null and query.titleZh != \"\"'>",
"AND (t.`title_zh` like concat('%',concat(#{query.titleZh},'%')) or t.`title_en` like concat('%',concat(#{query.titleZh},'%')))",
"</when>",
// "<when test = 'query.attrId != null and query.attrId != \"\" '>",
"<when test=\"query.attrId != null and query.attrId.size()>0\">" ,
"<when test=\"query.attrId != null and query.attrId != '' and query.attrId.size()==1 \">" +
"<foreach item='attrId' index=\"index\" collection='query.attrId' >" +
"AND t.`attr_id` = #{attrId}" +
"</foreach>" +
"</when>",
"<when test=\"query.attrId != null and query.attrId != '' and query.attrId.size()>1 \">" +
"AND (1!=1 " +
" <foreach item='attrId' index='index' collection='query.attrId'>" +
" OR FIND_IN_SET(t.`attr_id`, #{attrId})"+
"</foreach>" +
" )" +
"</when>",
// "AND FIND_IN_SET(t.`attr_id`, #{query.attrId})",
"</when>",
"order by t.id desc",
"</script>"
})
IPage<ProductDO> selectPageResp(IPage<ProductDO> mpPage, @Param("query") ProductReqDTO query);
default List<ProductDO> selectList(ProductPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<ProductDO>()
.likeIfPresent(ProductDO::getProductCode, reqVO.getProductCode())
......
package cn.iocoder.yudao.module.product.dto;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 商品分页 Request DTO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductReqDTO extends PageParam {
@ApiModelProperty(value = "商品类型id")
private List<Long> typeId;
@ApiModelProperty(value = "商品属性id")
//private String attrId;
private List<String> attrId;
@ApiModelProperty(value = "中文标题")
private String titleZh;
@ApiModelProperty(value = "英文标题")
private String titleEn;
@ApiModelProperty(value = "商品材质,字段material_type")
private String materialType;
@ApiModelProperty(value = "出运要求,1表示下单该类货物需要提供特定证书")
private Integer requirements;
@ApiModelProperty(value = "包装(字典packaging_type)")
private String packaging;
@ApiModelProperty(value = "图片")
private String imgs;
@ApiModelProperty(value = "商品编码")
private String productCode;
@ApiModelProperty(value = "海关编码")
private String customsCode;
@ApiModelProperty(value = "默认货柜位置,字典container_location")
private String containerLocation;
@ApiModelProperty(value = "默认方数")
private BigDecimal square;
@ApiModelProperty(value = "空运重量上限")
private BigDecimal airWeightLimit;
@ApiModelProperty(value = "是否需要预约入仓,0-否,1-是")
private Integer needBook;
@ApiModelProperty(value = "每日入仓上限")
private BigDecimal dayLimit;
@ApiModelProperty(value = "审核状态")
private Integer auditStatus;
@ApiModelProperty(value = "是否展示 默认为展示")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
private boolean filter = true;
/**
* 有效的transportType集合
*/
private List<String> enableTransportTypeList;
}
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.product;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductDO;
import cn.iocoder.yudao.module.product.dto.ProductReqDTO;
import cn.iocoder.yudao.module.product.vo.product.*;
import javax.validation.Valid;
......@@ -77,6 +78,8 @@ public interface ProductService {
*/
PageResult<ProductRespVO> getProductPage(ProductPageReqVO pageReqVO);
PageResult<ProductRespVO> getProductPageResp(ProductReqDTO pageReqVO);
List<ProductDO> getProductList(ProductPageReqVO pageReqVO);
/**
......
......@@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.product.dal.mysql.product.ProductAttrMapper;
import cn.iocoder.yudao.module.product.dal.mysql.product.ProductMapper;
import cn.iocoder.yudao.module.product.dal.mysql.product.ProductPriceStepClearanceMapper;
import cn.iocoder.yudao.module.product.dal.mysql.productPriceSnapshot.ProductPriceSnapshotMapper;
import cn.iocoder.yudao.module.product.dto.ProductReqDTO;
import cn.iocoder.yudao.module.product.service.coupon.CouponService;
import cn.iocoder.yudao.module.product.service.product.ProductPriceService;
import cn.iocoder.yudao.module.product.service.product.ProductPriceStepClearanceService;
......@@ -384,6 +385,30 @@ public class ProductServiceImpl implements ProductService {
return productRespVOPageResult;
}
@Override
public PageResult<ProductRespVO> getProductPageResp(ProductReqDTO pageReqVO) {
if (pageReqVO.isFilter()) {
pageReqVO.setAuditStatus(2);
}
IPage<ProductDO> mpPage = MyBatisUtils.buildPage(pageReqVO);
productMapper.selectPageResp(mpPage, pageReqVO);
PageResult<ProductDO> pageResult = PageResult.of(mpPage);
PageResult<ProductRespVO> productRespVOPageResult = ProductConvert.INSTANCE.convertPage(pageResult);
List<ProductRespVO> list = productRespVOPageResult.getList();
if (CollectionUtil.isNotEmpty(list)) {
for (ProductRespVO productRespVO : list) {
List<ProductPriceStepClearanceBackVO> productPriceStepClearanceList = productPriceStepClearanceService.getProductPriceStepClearanceList(productRespVO.getId());
productRespVO.setPriceStepClearanceList(productPriceStepClearanceList);
productRespVO.setPriceStepClearanceCount(new Long(productPriceStepClearanceList.size()));
}
}
return productRespVOPageResult;
}
@Override
public List<Long> getProductIdList(ProductPageReqVO pageReqVO) {
if (pageReqVO.isFilter()) {
......
......@@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.product.convert.product.ProductConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductAttrDO;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductDO;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductTypeDO;
import cn.iocoder.yudao.module.product.dto.ProductReqDTO;
import cn.iocoder.yudao.module.product.enums.AuditEnum;
import cn.iocoder.yudao.module.product.service.product.ProductAttrService;
import cn.iocoder.yudao.module.product.service.product.ProductPriceStepClearanceService;
......@@ -129,11 +130,12 @@ public class ProductController {
@GetMapping("/page")
@ApiOperation("获得商品分页")
// @PreAuthorize("@ss.hasPermission('ecw:product:query')")
public CommonResult<PageResult<ProductRespVO>> getProductPage(@Valid ProductPageReqVO pageVO) {
public CommonResult<PageResult<ProductRespVO>> getProductPage(@Valid ProductReqDTO pageVO) {
//设置有效的transportTypeList
initDictParams(pageVO);
initDictParamsCopy(pageVO);
PageResult<ProductRespVO> pageResult = productService.getProductPageResp(pageVO);
//PageResult<ProductRespVO> pageResult = productService.getProductPage(pageVO);
PageResult<ProductRespVO> pageResult = productService.getProductPage(pageVO);
// List<ProductRespVO> productList = page.getList();
// if(CollectionUtil.isNotEmpty(productList)) {
// for (ProductRespVO productRespVO : productList) {
......@@ -157,6 +159,13 @@ public class ProductController {
pageParam.setEnableTransportTypeList(CollectionUtil.newArrayList("3"));
}
private void initDictParamsCopy(ProductReqDTO pageParam) {
//目前只复制空运模板
pageParam.setEnableTransportTypeList(CollectionUtil.newArrayList("3"));
}
@PostMapping("/add")
@ApiOperation("添加商品")
public CommonResult<Long> getProductPage(@Valid @RequestBody AppProductCreateVo appProductCreateVo) {
......
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