清理已迁移的 product 代码
This commit is contained in:
@@ -1,106 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>product</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>product-service-impl</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>product-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>user-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DB 相关 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Registry 和 Config 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Transaction 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-seata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MQ 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>user-biz</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 提供给 mapstruct 使用 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,58 +0,0 @@
|
||||
package cn.iocoder.mall.product.convert;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.*;
|
||||
import cn.iocoder.mall.product.api.dto.ProductAttrAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductAttrUpdateDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductAttrValueAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductAttrValueUpdateDTO;
|
||||
import cn.iocoder.mall.product.dataobject.ProductAttrDO;
|
||||
import cn.iocoder.mall.product.dataobject.ProductAttrValueDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductAttrConvert {
|
||||
|
||||
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductAttrDetailBO> convert(List<ProductAttrDO> attrs);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrValueDetailBO convert(ProductAttrValueDO value);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductAttrValueDetailBO> convert2(List<ProductAttrValueDO> values);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductAttrSimpleBO> convert3(List<ProductAttrDO> attrs);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrValueSimpleBO convert3(ProductAttrValueDO value); // 保证 convert4 能够映射到这个方法
|
||||
|
||||
@Mappings({})
|
||||
List<ProductAttrValueSimpleBO> convert4(List<ProductAttrValueDO> values);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrDO convert(ProductAttrAddDTO productAttrAddDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrDO convert(ProductAttrUpdateDTO productAttrUpdateDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrValueDO convert(ProductAttrValueAddDTO productAttrValueAddDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrValueDO convert(ProductAttrValueUpdateDTO productAttrValueUpdateDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrBO convert(ProductAttrDO productAttrDO);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrValueBO convert2(ProductAttrValueDO productAttrValueDO);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductAttrDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductAttrMapper {
|
||||
|
||||
ProductAttrDO selectById(@Param("id") Integer id);
|
||||
|
||||
ProductAttrDO selectByName(@Param("name") String name);
|
||||
|
||||
List<ProductAttrDO> selectListByIds(@Param("ids") Collection<Integer> ids);
|
||||
|
||||
List<ProductAttrDO> selectListByStatus(@Param("status") Integer status);
|
||||
|
||||
List<ProductAttrDO> selectListByNameLike(@Param("name") String name,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByNameLike(@Param("name") String name);
|
||||
|
||||
void insert(ProductAttrDO productAttrDO);
|
||||
|
||||
void update(ProductAttrDO productAttrDO);
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductAttrValueDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductAttrValueMapper {
|
||||
|
||||
ProductAttrValueDO selectById(@Param("id") Integer id);
|
||||
|
||||
List<ProductAttrValueDO> selectListByIds(@Param("ids") Collection<Integer> ids);
|
||||
|
||||
List<ProductAttrValueDO> selectListByStatus(@Param("status") Integer status);
|
||||
|
||||
List<ProductAttrValueDO> selectListByAttrIds(@Param("attrIds") Collection<Integer> attrIds);
|
||||
|
||||
ProductAttrValueDO selectByAttrIdAndName(@Param("attrId") Integer attrId,
|
||||
@Param("name") String name);
|
||||
|
||||
|
||||
void insert(ProductAttrValueDO productAttrValueDO);
|
||||
|
||||
void update(ProductAttrValueDO productAttrValueDO);
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductSkuDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductSkuMapper {
|
||||
|
||||
ProductSkuDO selectById(Integer id);
|
||||
|
||||
List<ProductSkuDO> selectByIds(@Param("ids") Collection<Integer> ids);
|
||||
|
||||
List<ProductSkuDO> selectListBySpuIdAndStatus(@Param("spuId") Integer spuId,
|
||||
@Param("status") Integer status);
|
||||
|
||||
void insertList(@Param("productSkuDOs") List<ProductSkuDO> productSkuDOs);
|
||||
|
||||
int update(ProductSkuDO productSkuDO);
|
||||
|
||||
int updateToDeleted(@Param("ids") List<Integer> ids);
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.UserProductSpuCollectionsDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户_商品_收藏记录表
|
||||
*
|
||||
* @author xiaofeng
|
||||
* @date 2019-07-01 20:23:30
|
||||
*/
|
||||
@Repository
|
||||
public interface UserProductSpuCollectionsMapper extends BaseMapper<UserProductSpuCollectionsDO> {
|
||||
|
||||
/**
|
||||
* 根据用户id 和 spuId 查找用户商品收藏
|
||||
* @param userId
|
||||
* @param spuId
|
||||
* @return
|
||||
*/
|
||||
default UserProductSpuCollectionsDO getUserSpuCollectionsByUserIdAndSpuId(final Integer userId,
|
||||
final Integer spuId) {
|
||||
QueryWrapper<UserProductSpuCollectionsDO> query = new QueryWrapper<UserProductSpuCollectionsDO>()
|
||||
.eq("user_id", userId).eq("spu_id", spuId);
|
||||
return selectOne(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询用户收藏列表
|
||||
* @param userId
|
||||
* @param offset
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
List<UserProductSpuCollectionsDO> selectListByUser(@Param("userId") Integer userId, @Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 根据用户ID 查找总数
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Integer selectCountByUser(Integer userId);
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package cn.iocoder.mall.product.dataobject;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Product 库存
|
||||
*/
|
||||
@Deprecated // TODO 芋艿,咱暂时不加库存表和库存服务
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductStockDO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* SKU 编号
|
||||
*/
|
||||
private Integer skuId;
|
||||
/**
|
||||
* 库存数
|
||||
*/
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-正常
|
||||
* 2-删除
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package cn.iocoder.mall.product.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 用户_商品_收藏记录表
|
||||
*
|
||||
* @author xiaofeng
|
||||
* @date 2019-07-01 20:23:30
|
||||
*/
|
||||
@TableName("user_spu_collections")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserProductSpuCollectionsDO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id自增长
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer spuId;
|
||||
|
||||
/**
|
||||
* 商品名字
|
||||
*/
|
||||
private String spuName;
|
||||
|
||||
/**
|
||||
* 图片名字
|
||||
*/
|
||||
private String spuImage;
|
||||
|
||||
/**
|
||||
* 卖点
|
||||
*/
|
||||
private String sellPoint;
|
||||
|
||||
/**
|
||||
* 价格,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 删除状态
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package cn.iocoder.mall.product.service;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.product.api.ProductSpuCollectionService;
|
||||
import cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum;
|
||||
import cn.iocoder.mall.product.api.message.ProductSpuCollectionMessage;
|
||||
import cn.iocoder.mall.product.dao.ProductSpuMapper;
|
||||
import cn.iocoder.mall.product.dataobject.ProductSpuDO;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProductSpuCollectionServiceImpl
|
||||
* @author xiaofeng
|
||||
* @date 2019/07/01 23:14
|
||||
* @version 1.0
|
||||
*/
|
||||
@Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.ProductSpuCollectionService.version}")
|
||||
public class ProductSpuCollectionServiceImpl implements ProductSpuCollectionService {
|
||||
|
||||
@Autowired
|
||||
private ProductSpuMapper productSpuMapper;
|
||||
|
||||
@Resource
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
|
||||
@Override
|
||||
public boolean productSpuCollection(Integer spuId, Integer hasCollectionType, Integer userId) {
|
||||
ProductSpuDO productSpuDO = this.productSpuMapper.selectById(spuId);
|
||||
// 校验 Spu 是否存在
|
||||
if (productSpuDO == null) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_SPU_NOT_EXISTS.getCode());
|
||||
}
|
||||
this.sendProductSpuCollectionMessage(productSpuDO, hasCollectionType, userId);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送商品收藏或取消消息
|
||||
* @param productSpuDO
|
||||
* @param hasCollectionType
|
||||
*/
|
||||
// TODO FROM 芋艿 to ??:切换到 Spring Cloud Stream 发送消息
|
||||
private void sendProductSpuCollectionMessage(final ProductSpuDO productSpuDO, final Integer hasCollectionType,
|
||||
final Integer userId) {
|
||||
List<String> result = Lists.newArrayList(Splitter.on(",").omitEmptyStrings().trimResults().split(productSpuDO.getPicUrls()));
|
||||
ProductSpuCollectionMessage productSpuCollectionMessage = new ProductSpuCollectionMessage()
|
||||
.setSpuId(productSpuDO.getId())
|
||||
.setSpuName(productSpuDO.getName())
|
||||
.setSpuImage(result.size() > 0 ? result.get(0) : "")
|
||||
.setSellPoint(productSpuDO.getSellPoint())
|
||||
.setPrice(productSpuDO.getPrice())
|
||||
.setHasCollectionType(hasCollectionType)
|
||||
.setUserId(userId);
|
||||
rocketMQTemplate.convertAndSend(ProductSpuCollectionMessage.TOPIC, productSpuCollectionMessage);
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
spring:
|
||||
# datasource
|
||||
datasource:
|
||||
url: jdbc:mysql://s1.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: zhuyang
|
||||
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
|
||||
# Spring Cloud Stream 配置
|
||||
stream:
|
||||
# Binding 配置项
|
||||
bindings:
|
||||
product-update-output:
|
||||
destination: ProductUpdate
|
||||
# Spring Cloud Stream RocketMQ 配置项
|
||||
rocketmq:
|
||||
# RocketMQ Binder 配置项
|
||||
binder:
|
||||
name-server: s1.iocoder.cn:9876 # RocketMQ Namesrv 地址
|
||||
# RocketMQ 默认 Binding 配置项
|
||||
default:
|
||||
# RocketMQ 生产者
|
||||
producer:
|
||||
group: product-producer-group # 生产者分组
|
||||
sync: true # 是否同步发送消息,默认为 false 异步。
|
||||
|
||||
# mybatis
|
||||
mybatis-plus:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: cn.iocoder.mall.product.dataobject
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
||||
# Spring Cloud Alibaba Dubbo 专属配置
|
||||
cloud:
|
||||
subscribed-services: admin-application, user-application # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||
# Dubbo 提供者的协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
# Dubbo 提供服务的扫描基础包
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.product.service
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
filter: -exception
|
||||
ProductAttrService:
|
||||
version: 1.0.0
|
||||
ProductCategoryService:
|
||||
version: 1.0.0
|
||||
ProductSpuService:
|
||||
version: 1.0.0
|
||||
ProductBrandService:
|
||||
version: 1.0.0
|
||||
OAuth2Service:
|
||||
version: 1.0.0
|
||||
ProductSpuCollectionService:
|
||||
version: 1.0.0
|
||||
UserProductSpuCollectionsService:
|
||||
version: 1.0.0
|
||||
consumer:
|
||||
UserService:
|
||||
version: 1.0.0
|
||||
|
||||
# Seata 配置项
|
||||
seata:
|
||||
tx-service-group: default # Seata 事务组编号,用于 TC 集群名
|
||||
# 服务配置项,对应 ServiceProperties 类
|
||||
service:
|
||||
# 虚拟组和分组的映射
|
||||
vgroup-mapping:
|
||||
default: default
|
||||
# Seata 注册中心配置项
|
||||
registry:
|
||||
type: nacos # 注册中心类型
|
||||
nacos:
|
||||
serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址
|
||||
namespace: # Nacos 命名空间
|
||||
cluster: default # 使用的 Seata 分组
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<?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="cn.iocoder.mall.product.dao.ProductAttrMapper">
|
||||
|
||||
|
||||
<select id="selectByName" parameterType="String" resultType="ProductAttrDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr
|
||||
WHERE name = #{name}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ProductAttrDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_attr (
|
||||
name, status, create_time, deleted
|
||||
) VALUES (
|
||||
#{name}, #{status}, #{createTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="ProductAttrDO">
|
||||
UPDATE product_attr
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectListByIds" resultType="ProductAttrDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")" index="">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListByNameLike" resultType="ProductAttrDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr
|
||||
<where>
|
||||
<if test="name != null">
|
||||
name LIKE "%"#{name}"%"
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectCountByNameLike" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM product_attr
|
||||
<where>
|
||||
<if test="name != null">
|
||||
name LIKE "%"#{name}"%"
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListByStatus" parameterType="Integer" resultType="ProductAttrDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr
|
||||
<where>
|
||||
<if test="status != null">
|
||||
status = #{status}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,130 +0,0 @@
|
||||
<?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="cn.iocoder.mall.product.dao.ProductAttrValueMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, attr_id, name, status, create_time
|
||||
</sql>
|
||||
|
||||
<!--<select id="selectList" resultType="ProductCategoryDO">-->
|
||||
<!--SELECT-->
|
||||
<!--<include refid="FIELDS" />-->
|
||||
<!--FROM product_category-->
|
||||
<!--WHERE deleted = 0-->
|
||||
<!--</select>-->
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductAttrValueDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr_value
|
||||
WHERE id = #{id}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<!--<insert id="insert" parameterType="ProductCategoryDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">-->
|
||||
<!--INSERT INTO product_category (-->
|
||||
<!--pid, name, description, pic_url, sort,-->
|
||||
<!--status, create_time, deleted-->
|
||||
<!--) VALUES (-->
|
||||
<!--#{pid}, #{name}, #{description}, #{picUrl}, #{sort},-->
|
||||
<!--#{status}, #{createTime}, #{deleted}-->
|
||||
<!--)-->
|
||||
<!--</insert>-->
|
||||
|
||||
<!--<update id="update" parameterType="ProductCategoryDO">-->
|
||||
<!--UPDATE product_category-->
|
||||
<!--<set>-->
|
||||
<!--<if test="pid != null">-->
|
||||
<!--pid = #{pid},-->
|
||||
<!--</if>-->
|
||||
<!--<if test="name != null">-->
|
||||
<!--name = #{name},-->
|
||||
<!--</if>-->
|
||||
<!--<if test="description != null">-->
|
||||
<!--description = #{description},-->
|
||||
<!--</if>-->
|
||||
<!--<if test="picUrl != null">-->
|
||||
<!--pic_url = #{picUrl},-->
|
||||
<!--</if>-->
|
||||
<!--<if test="sort != null">-->
|
||||
<!--sort = #{sort},-->
|
||||
<!--</if>-->
|
||||
<!--<if test="status != null">-->
|
||||
<!--status = #{status},-->
|
||||
<!--</if>-->
|
||||
<!--<if test="deleted != null">-->
|
||||
<!--deleted = #{deleted}-->
|
||||
<!--</if>-->
|
||||
<!--</set>-->
|
||||
<!--WHERE id = #{id}-->
|
||||
<!--</update>-->
|
||||
|
||||
<select id="selectListByIds" resultType="ProductAttrValueDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr_value
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")" index="">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListByAttrIds" resultType="ProductAttrValueDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr_value
|
||||
WHERE attr_id IN
|
||||
<foreach item="attrId" collection="attrIds" separator="," open="(" close=")" index="">
|
||||
#{attrId}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListByStatus" resultType="ProductAttrValueDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr_value
|
||||
<where>
|
||||
<if test="status != null">
|
||||
status = #{status}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectByAttrIdAndName" resultType="ProductAttrValueDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_attr_value
|
||||
WHERE name = #{name}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ProductAttrValueDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_attr_value (
|
||||
attr_id, name, status, create_time, deleted
|
||||
) VALUES (
|
||||
#{attrId}, #{name}, #{status}, #{createTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="ProductAttrValueDO">
|
||||
UPDATE product_attr_value
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,87 +0,0 @@
|
||||
<?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="cn.iocoder.mall.product.dao.ProductSkuMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, spu_id, status, pic_url, attrs,
|
||||
price, quantity, create_time
|
||||
</sql>
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductSkuDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_sku
|
||||
WHERE id = #{id}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="ProductSkuDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_sku
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")" index="">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertList" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_sku (
|
||||
spu_id, status, pic_url, attrs, price,
|
||||
quantity, deleted, create_time
|
||||
) VALUES
|
||||
<foreach collection="productSkuDOs" item="productSkuDO" separator=",">
|
||||
(#{productSkuDO.spuId}, #{productSkuDO.status}, #{productSkuDO.picUrl}, #{productSkuDO.attrs}, #{productSkuDO.price},
|
||||
#{productSkuDO.quantity}, #{productSkuDO.deleted}, #{productSkuDO.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectListBySpuIdAndStatus" resultType="ProductSkuDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_sku
|
||||
WHERE spu_id = #{spuId}
|
||||
AND status = #{status}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="ProductSpuDO">
|
||||
UPDATE product_sku
|
||||
<set>
|
||||
<if test="spuId != null">
|
||||
spu_id = #{spuId},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="picUrl != null">
|
||||
pic_url = #{picUrl},
|
||||
</if>
|
||||
<if test="attrs != null">
|
||||
attrs = #{attrs},
|
||||
</if>
|
||||
<if test="price != null">
|
||||
price = #{price},
|
||||
</if>
|
||||
<if test="quantity != null">
|
||||
quantity = #{quantity},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateToDeleted" parameterType="Integer">
|
||||
UPDATE product_sku
|
||||
SET deleted = 1
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")" index="">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user