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

View File

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

View File

@ -3,13 +3,19 @@ package com.muyu.product.domain.DTO;
import com.muyu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/3/29 16:59
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ProductTypeAttrValue", description = "产品类型属性值信息")
public class ProductTypeAttrValue extends BaseEntity {
@ -25,4 +31,12 @@ public class ProductTypeAttrValue extends BaseEntity {
@ApiModelProperty(value = "录入方式0-自动1-手动")
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;
@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);
void insertProduct(Product product);
Integer insertProduct(Product product);
void updateMothodId(Integer id);

View File

@ -1,6 +1,7 @@
package com.muyu.product.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -11,5 +12,5 @@ import java.util.List;
@Mapper
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
*/
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) {
try {
// 异步执行方法类型检查
CompletableFuture<ValidationResult> methodTypeFuture =
@ -130,7 +132,7 @@ public class ProductServiceImpl implements ProductService {
insertProductPromotion(productReq);
insertProductSku(productReq);
// insertProductSku(productReq);
log.info("耗时:{}",(System.currentTimeMillis()-start));
@ -227,6 +229,7 @@ public class ProductServiceImpl implements ProductService {
serviceService.insertProductService(id,serviceIds);
}
private void insertProduct(Product product) {
product.setCreateBy(SecurityUtils.getUsername());
productMapper.insertProduct(product);

View File

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

View File

@ -36,7 +36,7 @@
<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`
) VALUES
<foreach collection="productSkuAttrs" separator="," item="productSkuAttr">
@ -53,7 +53,7 @@
</insert>
<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">
#{id}
</foreach>

View File

@ -20,7 +20,14 @@
( #{memberGold},#{memberSilver},#{memberDiamond},now(),#{createBy} )
</insert>
<insert id="insertLadder">
INSERT INTO `t_product_ladder` ( `ladder_num`, `ladder_discount`, `create_time`, `create_by` )
VALUES
(
#{ladderNum},
#{ladderDiscount},
now(),
#{createBy}
)
</insert>
<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
<foreach collection="serviceIds" item="ids" separator=",">
(#{id},#{ids})
<foreach collection="serviceIds" item="serviceId" separator=",">
(#{id}, #{serviceId})
</foreach>
</insert>
</mapper>

View File

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