Authored by LUOXC

同步订单中尺码表

package com.yoho.order.dal;
import com.yoho.order.model.ProductSize;
public interface ProductSizeMapper {
int insert(ProductSize record);
int updateBySizeId(ProductSize record);
}
\ No newline at end of file
... ...
package com.yoho.order.model;
import lombok.Data;
@Data
public class ProductSize {
private Integer id;
private Integer sizeId;
private String sizeName;
private Integer orderBy;
private Integer createTime;
private Integer updateTime;
}
\ No newline at end of file
... ...
<?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.yoho.order.dal.ProductSizeMapper" >
<resultMap id="BaseResultMap" type="com.yoho.order.model.ProductSize" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="size_id" property="sizeId" jdbcType="INTEGER" />
<result column="size_name" property="sizeName" jdbcType="VARCHAR" />
<result column="order_by" property="orderBy" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, size_id, size_name, order_by, create_time, update_time
</sql>
<insert id="insert" parameterType="com.yoho.order.model.ProductSize" >
insert into product_size (id, size_id, size_name,
order_by, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{sizeId,jdbcType=INTEGER}, #{sizeName,jdbcType=VARCHAR},
#{orderBy,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER})
</insert>
<update id="updateBySizeId" parameterType="com.yoho.order.model.ProductSize" >
update product_size
<set >
<if test="sizeName != null" >
size_name = #{sizeName,jdbcType=VARCHAR},
</if>
<if test="orderBy != null" >
order_by = #{orderBy,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where size_id = #{sizeId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.service.impl;
import com.yoho.order.dal.ProductSizeMapper;
import com.yoho.order.model.ProductSize;
import com.yoho.ufo.dal.UfoSizeMapper;
import com.yoho.ufo.model.commoditybasicrole.size.Size;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SizeManage {
@Autowired
private UfoSizeMapper ufoSizeMapper;
@Autowired
private ProductSizeMapper productSizeMapper;
/**
* 插入一条尺寸数据
*
* @param size
* @return
*/
public int insertSize(Size size) {
int rows = ufoSizeMapper.insertSize(size);
if (rows > 0) {
productSizeMapper.insert(newProductSize(size));
}
return rows;
}
/**
* 更新尺寸数据
*
* @param size
* @return
*/
public int updateSize(@Param("size") Size size) {
int rows = ufoSizeMapper.updateSize(size);
if (rows > 0) {
productSizeMapper.updateBySizeId(newProductSize(size));
}
return rows;
}
private ProductSize newProductSize(Size size) {
ProductSize productSize = new ProductSize();
productSize.setSizeId(size.getId());
productSize.setSizeName(size.getSizeName());
productSize.setOrderBy(size.getOrderBy());
productSize.setCreateTime(size.getCreateTime());
productSize.setUpdateTime(size.getUpdateTime());
return productSize;
}
}
... ...
... ... @@ -58,6 +58,9 @@ public class SizeServiceImpl implements ISizeService {
@Autowired
private ISizeService sizeService;
@Autowired
private SizeManage sizeManage;
@Override
public int saveOrUpdateSize(SizeRequestBo sizeRequestBo) {
LOGGER.info("saveOrUpdateSize param = {}", sizeRequestBo);
... ... @@ -76,7 +79,7 @@ public class SizeServiceImpl implements ISizeService {
size.setOrderBy(0);
}
// 新增
return ufoSizeMapper.insertSize(size);
return sizeManage.insertSize(size);
} else {
List<Size> sizes = ufoSizeMapper.selectBySizeNameEx(size.getSizeName(), size.getId());
if (CollectionUtils.isNotEmpty(sizes)) {
... ... @@ -85,7 +88,7 @@ public class SizeServiceImpl implements ISizeService {
// 更新
size.setUpdateTime(DateUtil.currentTimeSeconds());
return ufoSizeMapper.updateSize(size);
return sizeManage.updateSize(size);
}
}
... ... @@ -346,7 +349,7 @@ public class SizeServiceImpl implements ISizeService {
s.setCreateTime(time);
s.setUpdateTime(0);
LOGGER.info("切换品类尺码数据, 构建新尺码:{}", s);
ufoSizeMapper.insertSize(s);
sizeManage.insertSize(s);
LOGGER.info("切换品类尺码数据, 保存新尺码成功:{}", s);
LOGGER.info("切换品类尺码数据, 获取 {} 绑定的类别", sName);
... ...
... ... @@ -60,6 +60,7 @@ datasources:
- com.yoho.order.dal.DepositOrderMapper
- com.yoho.order.dal.DepositCodeMapper
- com.yoho.order.dal.ClearanceRecordMapper
- com.yoho.order.dal.ProductSizeMapper
ufo_resource:
servers:
... ...
... ... @@ -61,6 +61,7 @@ datasources:
- com.yoho.order.dal.DepositOrderMapper
- com.yoho.order.dal.DepositCodeMapper
- com.yoho.order.dal.ClearanceRecordMapper
- com.yoho.order.dal.ProductSizeMapper
ufo_resource:
servers:
... ...