dev798
wxy 2024-04-10 21:31:49 +08:00
parent 48e58bea7c
commit 2d2b0541ff
15 changed files with 132 additions and 41 deletions

View File

@ -3,7 +3,9 @@ package com.muyu.product.domain.DTO;
import com.muyu.common.core.domain.BaseEntity; import com.muyu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -13,29 +15,34 @@ import javax.validation.constraints.NotNull;
* @Date: 2024/3/29 16:57 * @Date: 2024/3/29 16:57
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "产品实体类") @ApiModel(description = "产品实体类")
public class Product extends BaseEntity { public class Product extends BaseEntity {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private Integer id; private Integer id;
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称",required = true)
@NotEmpty(message = "名称不能为空") @NotEmpty(message = "名称不能为空")
private String productName; private String productName;
@ApiModelProperty(value = "货号") @ApiModelProperty(value = "货号",required = true)
@NotNull(message = "货号不能为空") @NotNull(message = "货号不能为空")
private Integer productNumber; private String productNumber;
@ApiModelProperty(value = "审核状态 (1:通过, 2:驳回)") @ApiModelProperty(value = "审核状态 (1:通过, 2:驳回)")
private Integer productExamine; private Integer productExamine;
@ApiModelProperty(value = "品牌") @ApiModelProperty(value = "分类",required = true)
@NotNull(message = "分类不能不选择")
private Integer categoryId;
@ApiModelProperty(value = "品牌",required = true)
@NotNull(message = "品牌不能不选择") @NotNull(message = "品牌不能不选择")
private Integer brandId; private Integer brandId;
@ApiModelProperty(value = "商品类型") @ApiModelProperty(value = "商品类型",required = true)
@NotNull(message = "商品类型不能不选择")
private Integer typeId; private Integer typeId;
@ApiModelProperty(value = "副标题") @ApiModelProperty(value = "副标题")
@ -51,10 +58,10 @@ public class Product extends BaseEntity {
private Double productWeight; private Double productWeight;
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
private String productSort; private Integer productSort;
@ApiModelProperty(value = "促销表id") @ApiModelProperty(value = "市场价")
private Integer promotionId; private Integer marketPrice;
@ApiModelProperty(value = "积分") @ApiModelProperty(value = "积分")
private Integer productPoints; private Integer productPoints;
@ -102,5 +109,6 @@ public class Product extends BaseEntity {
@ApiModelProperty(value = "PC端信息") @ApiModelProperty(value = "PC端信息")
private String pcInformation; private String pcInformation;
private Integer sales;
} }

View File

@ -57,13 +57,11 @@ public class ProductTypeAttr extends BaseEntity {
@ApiModelProperty(value = "手动新增0-是1-否") @ApiModelProperty(value = "手动新增0-是1-否")
private Integer manualOperation; private Integer manualOperation;
@ApiModelProperty(value = "类型名称") @ApiModelProperty(value = "类型名称")
private String typeName; private String typeName;
@ApiModelProperty(value = "类型集合") @ApiModelProperty(value = "类型集合")
private List<TypeAttrs> typeAttrs; private List<TypeAttrs> typeAttrs;
@ApiModelProperty(value = "tavId")
private Integer tavId;
} }

View File

@ -3,13 +3,19 @@ package com.muyu.product.domain.DTO;
import com.muyu.common.core.domain.BaseEntity; import com.muyu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* @Author: wangxinyuan * @Author: wangxinyuan
* @Date: 2024/3/29 16:59 * @Date: 2024/3/29 16:59
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ProductTypeAttrValue", description = "产品类型属性值信息") @ApiModel(value = "ProductTypeAttrValue", description = "产品类型属性值信息")
public class ProductTypeAttrValue extends BaseEntity { public class ProductTypeAttrValue extends BaseEntity {
@ -25,4 +31,12 @@ public class ProductTypeAttrValue extends BaseEntity {
@ApiModelProperty(value = "录入方式0-自动1-手动") @ApiModelProperty(value = "录入方式0-自动1-手动")
private Integer inputMethod; private Integer inputMethod;
// 添加集合属性及其getter方法
private List<ProductTypeAttrValue> productTypeAttrValueList;
public List<ProductTypeAttrValue> getProductTypeAttrValueList() {
return productTypeAttrValueList;
}
} }

View File

@ -34,6 +34,6 @@ public class QueryProductReq {
private Integer pageNum = 1; private Integer pageNum = 1;
@ApiModelProperty(value = "分页参数") @ApiModelProperty(value = "分页参数")
private Integer pageSize = 5; private Integer pageSize = 10;
} }

View File

@ -0,0 +1,52 @@
package com.muyu.product.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: wangxinyuan
* @Date: 2024/4/10 8:47
*/
@Data
@ApiModel(value = "ProductVo")
@AllArgsConstructor
@NoArgsConstructor
public class ProductVo {
@ApiModelProperty(value = "产品id")
private Integer id;
@ApiModelProperty(value = "产品名称")
private String productName;
@ApiModelProperty(value = "产品信息")
private String productInformation;
@ApiModelProperty(value = "详情标题")
private String detailsTitle;
@ApiModelProperty(value = "详情信息")
private String detailsInformation;
@ApiModelProperty(value = "品牌名称")
private String brandName;
@ApiModelProperty(value = "销售价格")
private Double salePrice;
@ApiModelProperty(value = "促销价格")
private Double promotionPrice;
@ApiModelProperty(value = "图片链接")
private String imagesUrl;
@ApiModelProperty(value = "服务名称")
private String serviceName;
@ApiModelProperty(value = "类型名称")
private String typeName;
}

View File

@ -14,7 +14,7 @@ public interface ProductMapper {
List<ProductResp> queryProduct(QueryProductReq productReq); List<ProductResp> queryProduct(QueryProductReq productReq);
void insertProduct(Product product); Integer insertProduct(Product product);
void updateMothodId(Integer id); void updateMothodId(Integer id);

View File

@ -1,6 +1,7 @@
package com.muyu.product.mapper; package com.muyu.product.mapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -11,5 +12,5 @@ import java.util.List;
@Mapper @Mapper
public interface ServicesMapper { public interface ServicesMapper {
int insertProductServicep(Integer productId, List<Integer> serviceIds); int insertProductService(@Param("id") Integer id, @Param("serviceIds") List<Integer> serviceIds);
} }

View File

@ -7,5 +7,6 @@ import java.util.List;
* @Date: 2024/3/29 17:05 * @Date: 2024/3/29 17:05
*/ */
public interface ServiceService { public interface ServiceService {
int insertProductService(Integer id, List<Integer> serviceIds);
int insertProductService(Integer productId,List<Integer> serviceIds);
} }

View File

@ -52,6 +52,8 @@ public class ProductServiceImpl implements ProductService {
// 检查产品参数 // 检查产品参数
public void checkProductParams(ProductReq productReq) { public void checkProductParams(ProductReq productReq) {
try { try {
// 异步执行方法类型检查 // 异步执行方法类型检查
CompletableFuture<ValidationResult> methodTypeFuture = CompletableFuture<ValidationResult> methodTypeFuture =
@ -130,7 +132,7 @@ public class ProductServiceImpl implements ProductService {
insertProductPromotion(productReq); insertProductPromotion(productReq);
insertProductSku(productReq); // insertProductSku(productReq);
log.info("耗时:{}",(System.currentTimeMillis()-start)); log.info("耗时:{}",(System.currentTimeMillis()-start));
@ -227,6 +229,7 @@ public class ProductServiceImpl implements ProductService {
serviceService.insertProductService(id,serviceIds); serviceService.insertProductService(id,serviceIds);
} }
private void insertProduct(Product product) { private void insertProduct(Product product) {
product.setCreateBy(SecurityUtils.getUsername()); product.setCreateBy(SecurityUtils.getUsername());
productMapper.insertProduct(product); productMapper.insertProduct(product);

View File

@ -18,6 +18,6 @@ public class ServiceServiceImpl implements ServiceService {
private ServicesMapper servicesMapper; private ServicesMapper servicesMapper;
@Override @Override
public int insertProductService(Integer productId, List<Integer> serviceIds) { public int insertProductService(Integer productId, List<Integer> serviceIds) {
return servicesMapper.insertProductServicep(productId,serviceIds); return servicesMapper.insertProductService(productId,serviceIds);
} }
} }

View File

@ -12,15 +12,14 @@
product_recommended,details_title,details_information,details_key_word,details_remark, 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,images_url,sales method_type,t_product_brand.brand_name,t_product_type.type_name,sale_price,images_url,sales
</sql> </sql>
<insert id="insertProduct">
<insert id="insertProduct" useGeneratedKeys="true" keyProperty="id"> INSERT INTO `t_product` (
INSERT INTO `t_Product` (
`product_name`, `product_name`,
`product_number`, `product_number`,
`category_id`,
`brand_id`, `brand_id`,
`type_id`, `type_id`,
`product_subheading`, `product_subheading`,
`product_examine`,
`product_information`, `product_information`,
`product_unit`, `product_unit`,
`product_weight`, `product_weight`,
@ -38,14 +37,15 @@
`details_remark`, `details_remark`,
`method_type`, `method_type`,
`create_by`, `create_by`,
`create_time` `create_time`,
`sales`
) VALUES ( ) VALUES (
#{productName}, #{productName},
#{productNumber}, #{productNumber},
#{categoryId},
#{brandId}, #{brandId},
#{typeId}, #{typeId},
#{productSubheading}, #{productSubheading},
#{productExamine},
#{productInformation}, #{productInformation},
#{productUnit}, #{productUnit},
#{productWeight}, #{productWeight},
@ -63,7 +63,8 @@
#{detailsRemark}, #{detailsRemark},
#{methodType}, #{methodType},
#{createBy}, #{createBy},
NOW() NOW(),
#{sales}
) )
</insert> </insert>

View File

@ -36,7 +36,7 @@
<insert id="insertProductSkuAttr"> <insert id="insertProductSkuAttr">
INSERT INTO `product`.`t_product_sku_attr` ( INSERT INTO `t_product_sku_attr` (
`sku_id`, `attr_id`, `attr_value_id`, `attr_value`, `flag`, `create_time`, `create_by` `sku_id`, `attr_id`, `attr_value_id`, `attr_value`, `flag`, `create_time`, `create_by`
) VALUES ) VALUES
<foreach collection="productSkuAttrs" separator="," item="productSkuAttr"> <foreach collection="productSkuAttrs" separator="," item="productSkuAttr">
@ -53,7 +53,7 @@
</insert> </insert>
<select id="findSkuId" resultType="java.lang.Integer"> <select id="findSkuId" resultType="java.lang.Integer">
select count(id) from t_product_sku where id in select count(id) from t_product_sku where id_delete = 1 and id in
<foreach collection="productSkus" separator="," open="(" close=")" item="id"> <foreach collection="productSkus" separator="," open="(" close=")" item="id">
#{id} #{id}
</foreach> </foreach>

View File

@ -20,7 +20,14 @@
( #{memberGold},#{memberSilver},#{memberDiamond},now(),#{createBy} ) ( #{memberGold},#{memberSilver},#{memberDiamond},now(),#{createBy} )
</insert> </insert>
<insert id="insertLadder"> <insert id="insertLadder">
INSERT INTO `t_product_ladder` ( `ladder_num`, `ladder_discount`, `create_time`, `create_by` )
VALUES
(
#{ladderNum},
#{ladderDiscount},
now(),
#{createBy}
)
</insert> </insert>
<insert id="insertPrice"> <insert id="insertPrice">

View File

@ -8,11 +8,13 @@
<!-- 添加其他操作方法如插入、更新、删除等 --> <!-- 添加其他操作方法如插入、更新、删除等 -->
<insert id="insertProductServicep">
insert t_product_service_middle(product_id,service_id) <insert id="insertProductService">
insert into t_product_service_middle(product_id, service_id)
values values
<foreach collection="serviceIds" item="ids" separator=","> <foreach collection="serviceIds" item="serviceId" separator=",">
(#{id},#{ids}) (#{id}, #{serviceId})
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>

View File

@ -3,9 +3,11 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.product.mapper.TypeMapper"> <mapper namespace="com.muyu.product.mapper.TypeMapper">
<insert id="insertType"> <insert id="insertType">
insert t_product_type(type_name,create_by,create_time) value (#{typeName},#{createBy},now()) insert t_product_type(type_name,create_by,create_time) value (#{typeName},#{createBy},now())
</insert> </insert>
<insert id="insertTypeAttr" useGeneratedKeys="true" keyProperty="id"> <insert id="insertTypeAttr" useGeneratedKeys="true" keyProperty="id">
INSERT INTO `product`.`t_product_type_attr` ( INSERT INTO `product`.`t_product_type_attr` (
`product_type_id`, `product_type_id`,
@ -29,7 +31,7 @@
#{productTypeId}, #{productTypeId},
#{attrName}, #{attrName},
#{multipleChoice}, #{multipleChoice},
#{inputMethod}, #{input},
#{sort}, #{sort},
#{flag}, #{flag},
#{screen}, #{screen},
@ -46,22 +48,23 @@
<insert id="insertTypeValue"> <insert id="insertTypeValue">
INSERT INTO `product`.`t_product_type_attr_value` ( `type_attr_id`, `type_attr_value`, `input_method`, `create_time`, `create_by` ) INSERT INTO `product`.`t_product_type_attr_value` ( `type_attr_id`, `type_attr_value`, `input_method`, `create_time`, `create_by` )
VALUES VALUES
<foreach collection="productTypeAttrValueList" separator="," item="productTypeAttrValue">
( (
#{productTypeAttrValue.typeAttrId}, #{typeAttrId},
#{productTypeAttrValue.typeAttrValue}, #{typeAttrValue},
#{productTypeAttrValue.inputMethod}, #{inputMethod},
now(), now(),
#{productTypeAttrValue.createBy} #{createBy}
) )
</foreach>
</insert> </insert>
<update id="deleteType"> <update id="deleteType">
update t_product_type set id_delete = 0,update_time = now(),create_by=#{name} where id = #{typeId} update t_product_type set id_delete = 0,update_time = now(),create_by=#{name} where id = #{typeId}
</update> </update>
<update id="updateType"> <update id="updateType">
update t_product_type set type_name = #{typeName},update_time = now(),create_by=#{createBy} where id = #{id} update t_product_type set type_name = #{typeName},update_time = now(),create_by=#{createBy} where id = #{id}
</update> </update>
<update id="updateAttr"> <update id="updateAttr">
UPDATE `product`.`t_product_type_attr` UPDATE `product`.`t_product_type_attr`
SET `product_type_id` = #{productTypeId}, SET `product_type_id` = #{productTypeId},
@ -136,6 +139,7 @@
INNER JOIN t_product_type_attr_value tav ON tav.type_attr_id = ta.id INNER JOIN t_product_type_attr_value tav ON tav.type_attr_id = ta.id
where ta.id_delete=1 and ta.flag = #{flag} and t.id = #{id} where ta.id_delete=1 and ta.flag = #{flag} and t.id = #{id}
</select> </select>
<select id="queryTypeAll" resultType="com.muyu.product.domain.Resp.ProductTypeResp"> <select id="queryTypeAll" resultType="com.muyu.product.domain.Resp.ProductTypeResp">
SELECT SELECT
t.id, t.id,