dev798
wxy 2024-03-30 13:02:02 +08:00
parent 42d21106be
commit db1479a922
19 changed files with 431 additions and 123 deletions

View File

@ -0,0 +1,112 @@
package com.muyu.product.domain.Resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* @Author: wangxinyuan
* @Date: 2024/3/30 12:27
*/
@Data
public class ProductResp {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "名称")
@NotEmpty(message = "名称不能为空")
private String productName;
@ApiModelProperty(value = "货号")
@NotNull(message = "货号不能为空")
private String productNumber;
@ApiModelProperty(value = "审核状态 (1:通过, 2:驳回)")
private Integer productExamine;
@ApiModelProperty(value = "品牌")
@NotNull(message = "品牌不能不选择")
private Integer brandId;
@ApiModelProperty(value = "商品类型")
@NotNull(message = "商品类型不能不选择")
private Integer typeId;
@ApiModelProperty(value = "副标题")
private String productSubheading;
@ApiModelProperty(value = "商品介绍")
private String productInformation;
@ApiModelProperty(value = "单位")
private String productUnit;
@ApiModelProperty(value = "重量")
private Double productWeight;
@ApiModelProperty(value = "排序")
private Integer productSort;
@ApiModelProperty(value = "促销表id")
private Integer promotionId;
@ApiModelProperty(value = "积分")
private Integer productPoints;
@ApiModelProperty(value = "成长值")
private Integer productGrowth;
@ApiModelProperty(value = "最大积分值")
private Integer productMaxPoints;
@ApiModelProperty(value = "预告商品 (1是, 2否)")
private Integer productForeknow;
@ApiModelProperty(value = "上下架状态 (1上架, 2下架)")
private Integer productStatus;
@ApiModelProperty(value = "新品 (1是, 2否)")
private Integer productNew;
@ApiModelProperty(value = "推荐 (1是, 2否)")
private Integer productRecommended;
@ApiModelProperty(value = "详情标题")
private String detailsTitle;
@ApiModelProperty(value = "详情描述")
private String detailsInformation;
@ApiModelProperty(value = "关键字")
private String detailsKeyWord;
@ApiModelProperty(value = "备注")
private String detailsRemark;
@ApiModelProperty(value = "优惠方法")
@NotNull(message = "优惠方式不能不选择")
private Integer methodType;
@ApiModelProperty(value = "优惠Id")
private Integer methodId;
@ApiModelProperty(value = "移动端信息")
private String moveInformation;
@ApiModelProperty(value = "PC端信息")
private String pcInformation;
@ApiModelProperty(value = "售价")
private Double salePrice;
@ApiModelProperty(value = "品牌名称")
private String brandName;
@ApiModelProperty(value = "类型名称")
private String typeName;
}

View File

@ -1,30 +0,0 @@
package com.muyu.product.domain.req;
import lombok.Data;
import java.util.List;
import java.util.Set;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 10:23
*/
@Data
public class ProductInfoReq {
private Integer id;
public List<ProductInfoReq> getSkuList(ProductInfoReq productInfoReq) {
return null;
}
public Set keySet() {
return null;
}
public Object get(Object key) {
return null;
}
}

View File

@ -1,9 +1,8 @@
package com.muyu.product.domain.req;
import com.muyu.product.domain.*;
import com.muyu.product.domain.DTO.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
@ -22,11 +21,12 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ProductReq", description = "商品添加接收信息")
public class ProductReq extends HashMap {
public class ProductReq {
@ApiModelProperty(value = "商品")
@Valid
private Product product;
@ApiModelProperty(value = "商品图片列表")
private List<String> productImages;
@ -37,26 +37,18 @@ public class ProductReq extends HashMap {
private List<Integer> serviceIds;
@ApiModelProperty(value = "阶梯优惠")
@Valid
private Ladder ladder;
private List<Ladder> ladder;
@ApiModelProperty(value = "会员信息")
@Valid
private Member member;
@ApiModelProperty(value = "优惠信息")
@Valid
private Preference preference;
@ApiModelProperty(value = "价格信息")
@Valid
private Price price;
private List<Price> price;
@ApiModelProperty(value = "分页参数")
private Integer pageNum = 1;
@ApiModelProperty(value = "分页参数")
private Integer pageSize = 10;
}

View File

@ -0,0 +1,34 @@
package com.muyu.product.domain.req;
import com.muyu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 20:00
*/
@Data
public class ProductSkuNew extends BaseEntity {
@ApiModelProperty(value = "SKUId")
private long id;
@ApiModelProperty(value = "销售价格")
private Double salePrice;
@ApiModelProperty(value = "促销价格")
private Double promotionPrice;
@ApiModelProperty(value = "库存")
private Integer stock;
@ApiModelProperty(value = "预警库存")
private Integer stockAlert;
@ApiModelProperty(value = "商品Id")
private Integer productId;
@ApiModelProperty(value = "SKU背景图地址")
private String bgImg;
}

View File

@ -1,18 +0,0 @@
package com.muyu.product.domain.req;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.HashMap;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 10:32
*/
@Data
@ApiModel(description = "")
public class ProductSkuReq extends HashMap {
private Integer productId;
}

View File

@ -0,0 +1,37 @@
package com.muyu.product.domain.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 19:58
*/
@Data
public class QueryProductReq {
@ApiModelProperty(value = "名称")
private String productName;
@ApiModelProperty(value = "货号")
private String productNumber;
@ApiModelProperty(value = "上下架状态 (1上架, 2下架)")
private Integer productStatus;
@ApiModelProperty(value = "审核状态 (1:通过, 2:驳回)")
private Integer productExamine;
@ApiModelProperty(value = "品牌")
private Integer brandId;
@ApiModelProperty(value = "商品类型")
private Integer typeId;
@ApiModelProperty(value = "分页参数")
private Integer pageNum = 1;
@ApiModelProperty(value = "分页参数")
private Integer pageSize = 10;
}

View File

@ -0,0 +1,28 @@
package com.muyu.product.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/30 12:57
*/
@Data
@ApiModel(description = "商品类别")
public class ProductCategoryVo {
@ApiModelProperty(value = "类别ID")
private Integer id;
@ApiModelProperty(value = "类别名称")
private String name;
@ApiModelProperty(value = "父类别ID")
private Integer parentId;
@ApiModelProperty(value = "子类别列表")
private List<ProductCategoryVo> childrenList;
}

View File

@ -1,10 +1,22 @@
package com.muyu.product.controller;
import com.muyu.common.core.domain.AjaxResult;
import com.muyu.product.domain.DTO.Brand;
import com.muyu.product.domain.DTO.Services;
import com.muyu.product.domain.util.R;
import com.muyu.product.domain.vo.ProductCategoryVo;
import com.muyu.product.service.ArgumentService;
import io.swagger.annotations.Api;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.muyu.common.core.domain.AjaxResult.success;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:09
@ -13,4 +25,28 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("argument")
@Api(value = "下拉框管理")
public class ArgumentController {
@Autowired
private ArgumentService argumentService;
@GetMapping("/queryBrand")
public AjaxResult queryBrand(){
List<Brand>list = argumentService.queryBrand();
return success(list);
}
@GetMapping("/queryService")
public AjaxResult queryService(){
List<Services>list=argumentService.queryService();
return success(list);
}
@GetMapping("/queryCategory")
public R<List<ProductCategoryVo>>queryCategory(){
return R.ok(argumentService.queryCategory());
}
}

View File

@ -4,15 +4,18 @@ import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.AjaxResult;
import com.muyu.common.system.remote.RemoteFileService;
import com.muyu.product.domain.DTO.Product;
import com.muyu.product.domain.Resp.ProductResp;
import com.muyu.product.domain.req.ProductReq;
import com.muyu.product.domain.req.QueryProductReq;
import com.muyu.product.domain.util.R;
import com.muyu.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import static com.muyu.common.core.domain.AjaxResult.success;
@ -31,11 +34,19 @@ public class ProductController {
@Autowired
private RemoteFileService remoteFileService;
@ApiModelProperty("查询商品信息")
@ApiOperation("查询商品信息")
@GetMapping("/queryProduct")
public AjaxResult queryProduct(@RequestBody ProductReq req){
PageInfo<Product> list = productService.queryProduct(req);
public AjaxResult queryProduct(QueryProductReq req){
PageInfo<ProductResp> list = productService.queryProduct(req);
return success(list);
}
@ApiOperation("添加商品")
@PostMapping("/productInsert")
public R<Product>productInsert(@Valid @RequestBody ProductReq productReq){
productService.productInsert(productReq);
return R.ok();
}
}

View File

@ -1,8 +1,13 @@
package com.muyu.product.mapper;
import com.muyu.product.domain.DTO.Brand;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:07
*/
public interface ArgumentMapper {
List<Brand> queryBrand();
}

View File

@ -1,8 +1,17 @@
package com.muyu.product.mapper;
import com.muyu.product.domain.DTO.Product;
import com.muyu.product.domain.Resp.ProductResp;
import com.muyu.product.domain.req.ProductReq;
import com.muyu.product.domain.req.QueryProductReq;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:06
*/
public interface ProductMapper {
List<ProductResp> queryProduct(QueryProductReq productReq);
}

View File

@ -0,0 +1,8 @@
package com.muyu.product.mapper;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:29
*/
public interface ProductSkuMapper {
}

View File

@ -1,8 +1,20 @@
package com.muyu.product.service;
import com.muyu.product.domain.DTO.Brand;
import com.muyu.product.domain.DTO.Services;
import com.muyu.product.domain.vo.ProductCategoryVo;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:05
*/
public interface ArgumentService {
List<Brand> queryBrand();
List<Services> queryService();
List<ProductCategoryVo> queryCategory();
}

View File

@ -2,12 +2,16 @@ package com.muyu.product.service;
import com.github.pagehelper.PageInfo;
import com.muyu.product.domain.DTO.Product;
import com.muyu.product.domain.Resp.ProductResp;
import com.muyu.product.domain.req.ProductReq;
import com.muyu.product.domain.req.QueryProductReq;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:05
*/
public interface ProductService {
PageInfo<Product> queryProduct(ProductReq req);
PageInfo<ProductResp> queryProduct(QueryProductReq req);
void productInsert(ProductReq productReq);
}

View File

@ -1,12 +1,36 @@
package com.muyu.product.service.impl;
import com.muyu.product.domain.DTO.Brand;
import com.muyu.product.domain.DTO.Services;
import com.muyu.product.domain.vo.ProductCategoryVo;
import com.muyu.product.mapper.ArgumentMapper;
import com.muyu.product.service.ArgumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:06
*/
@Service
public class ArgumentServiceImpl implements ArgumentService {
@Autowired
private ArgumentMapper argumentMapper;
@Override
public List<Brand> queryBrand() {
return argumentMapper.queryBrand();
}
@Override
public List<Services> queryService() {
return null;
}
@Override
public List<ProductCategoryVo> queryCategory() {
return null;
}
}

View File

@ -1,12 +1,24 @@
package com.muyu.product.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.product.domain.DTO.Product;
import com.muyu.product.domain.Resp.ProductResp;
import com.muyu.product.domain.req.ProductReq;
import com.muyu.product.domain.req.QueryProductReq;
import com.muyu.product.mapper.ProductMapper;
import com.muyu.product.mapper.ProductSkuMapper;
import com.muyu.product.mapper.PromotionMapper;
import com.muyu.product.service.ProductService;
import com.muyu.product.service.ServiceService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.management.Query;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 17:06
@ -18,8 +30,38 @@ public class ProductServiceImpl implements ProductService {
private final Integer min = 0;
private final Integer max = 5;
@Resource
private ProductMapper productMapper;
@Autowired
private ServiceService serviceService;
@Resource
private PromotionMapper promotionMapper;
@Autowired
private ProductSkuMapper productSkuMapper;
@Override
public PageInfo<Product> queryProduct(ProductReq req) {
return null;
public PageInfo<ProductResp> queryProduct(QueryProductReq productReq) {
PageHelper.startPage(productReq.getPageNum(),productReq.getPageSize());
List<ProductResp>products=productMapper.queryProduct(productReq);
PageInfo<ProductResp> pageInfo = new PageInfo<>(products);
return pageInfo;
}
@Override
public void productInsert(ProductReq productReq) {
long start =System.currentTimeMillis();
insertProduct(productReq.getProduct());
}
private void insertProduct(Product product) {
}
}

View File

@ -5,4 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.muyu.product.mapper.ArgumentMapper">
<select id="queryBrand" resultType="com.muyu.product.domain.DTO.Brand">
select id,brand_name from t_product_brand
</select>
</mapper>

View File

@ -5,59 +5,45 @@
<mapper namespace="com.muyu.product.mapper.ProductMapper">
<insert id="insertProcuduct" useGeneratedKeys="true" keyProperty="id">
INSERT INTO `cargo`.`t_product` (
`product_name`,
`product_number`,
`brand_id`,
`type_id`,
`product_subheading`,
`product_information`,
`product_unit`,
`product_weight`,
`product_sort`,
`product_points`,
`product_growth`,
`product_max_points`,
`product_foreknow`,
`product_staus`,
`product_new`,
`product_recommended`,
`details_title`,
`details_information`,
`details_key_word`,
`details_remark`,
`method_type`,
`create_by`,
`create_time`
)
VALUES
(
#{productName},
#{productNumber},
#{brandId},
#{typeId},
#{productSubheading},
#{productInformation},
#{productUnit},
#{productWeight},
#{productSort},
#{productPoints},
#{productGrowth},
#{productForeknow},
#{productStatus},
#{productNew},
#{productRecommended},
#{detailsTitle},
#{detailsInformation},
#{detailsKeyWord},
#{detailsRemark},
#{methodType},
#{createBy},
now()
);
</insert>
<sql id="sql">
t_product.id,product_name,product_number,brand_id,type_id,product_subheading,product_examine,
product_information,product_unit,product_weight,product_sort,product_points,
product_growth,product_max_points,product_foreknow,product_status,product_new,
product_recommended,details_title,details_information,details_key_word,details_remark,
method_type,t_product_brand.brand_name,t_product_type.type_name,sale_price
</sql>
<select id="queryProduct" resultType="com.muyu.product.domain.Resp.ProductResp">
select <include refid="sql"></include> from t_product
LEFT JOIN t_product_brand ON t_product.brand_id = t_product_brand.id
LEFT join t_product_type ON t_product.type_id = t_product_type.id
left JOIN t_product_sku on t_product_sku.product_id = t_product.id
<where>
t_product.id_delete = 1
<if test="productName != null and productName != ''">
and product_name like concat('%',#{productName},'%')
</if>
<if test="productNumber != null and productNumber != ''">
and product_number like concat('%',#{productNumber},'%')
</if>
<if test="productStatus != null">
and product_status = #{productStatus}
</if>
<if test="productExamine != null">
and product_examine = #{productExamine}
</if>
<if test="brandId != null and brandId>0">
and t_product.brand_id = #{brandId}
</if>
<if test="typeId != null and typeId >0">
and t_product.type_id = #{typeId}
</if>
</where>
order by product_sort
</select>
<!-- 添加其他操作方法如插入、更新、删除等 -->
</mapper>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.product.mapper.ProductSkuMapper">
<!-- 添加其他操作方法如插入、更新、删除等 -->
</mapper>