Showing
7 changed files
with
143 additions
and
3 deletions
1 | +package com.yoho.order.model; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +@Data | ||
6 | +public class ProductSize { | ||
7 | + private Integer id; | ||
8 | + | ||
9 | + private Integer sizeId; | ||
10 | + | ||
11 | + private String sizeName; | ||
12 | + | ||
13 | + private Integer orderBy; | ||
14 | + | ||
15 | + private Integer createTime; | ||
16 | + | ||
17 | + private Integer updateTime; | ||
18 | + | ||
19 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.order.dal.ProductSizeMapper" > | ||
4 | + | ||
5 | + <resultMap id="BaseResultMap" type="com.yoho.order.model.ProductSize" > | ||
6 | + <id column="id" property="id" jdbcType="INTEGER" /> | ||
7 | + <result column="size_id" property="sizeId" jdbcType="INTEGER" /> | ||
8 | + <result column="size_name" property="sizeName" jdbcType="VARCHAR" /> | ||
9 | + <result column="order_by" property="orderBy" jdbcType="INTEGER" /> | ||
10 | + <result column="create_time" property="createTime" jdbcType="INTEGER" /> | ||
11 | + <result column="update_time" property="updateTime" jdbcType="INTEGER" /> | ||
12 | + </resultMap> | ||
13 | + | ||
14 | + <sql id="Base_Column_List" > | ||
15 | + id, size_id, size_name, order_by, create_time, update_time | ||
16 | + </sql> | ||
17 | + | ||
18 | + <insert id="insert" parameterType="com.yoho.order.model.ProductSize" > | ||
19 | + insert into product_size (id, size_id, size_name, | ||
20 | + order_by, create_time, | ||
21 | + update_time) | ||
22 | + values (#{id,jdbcType=INTEGER}, #{sizeId,jdbcType=INTEGER}, #{sizeName,jdbcType=VARCHAR}, | ||
23 | + #{orderBy,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, | ||
24 | + #{updateTime,jdbcType=INTEGER}) | ||
25 | + </insert> | ||
26 | + | ||
27 | + <update id="updateBySizeId" parameterType="com.yoho.order.model.ProductSize" > | ||
28 | + update product_size | ||
29 | + <set > | ||
30 | + <if test="sizeName != null" > | ||
31 | + size_name = #{sizeName,jdbcType=VARCHAR}, | ||
32 | + </if> | ||
33 | + <if test="orderBy != null" > | ||
34 | + order_by = #{orderBy,jdbcType=INTEGER}, | ||
35 | + </if> | ||
36 | + <if test="createTime != null" > | ||
37 | + create_time = #{createTime,jdbcType=INTEGER}, | ||
38 | + </if> | ||
39 | + <if test="updateTime != null" > | ||
40 | + update_time = #{updateTime,jdbcType=INTEGER}, | ||
41 | + </if> | ||
42 | + </set> | ||
43 | + where size_id = #{sizeId,jdbcType=INTEGER} | ||
44 | + </update> | ||
45 | + | ||
46 | +</mapper> |
1 | +package com.yoho.ufo.service.impl; | ||
2 | + | ||
3 | +import com.yoho.order.dal.ProductSizeMapper; | ||
4 | +import com.yoho.order.model.ProductSize; | ||
5 | +import com.yoho.ufo.dal.UfoSizeMapper; | ||
6 | +import com.yoho.ufo.model.commoditybasicrole.size.Size; | ||
7 | +import org.apache.ibatis.annotations.Param; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Service; | ||
10 | + | ||
11 | +@Service | ||
12 | +public class SizeManage { | ||
13 | + | ||
14 | + @Autowired | ||
15 | + private UfoSizeMapper ufoSizeMapper; | ||
16 | + | ||
17 | + @Autowired | ||
18 | + private ProductSizeMapper productSizeMapper; | ||
19 | + | ||
20 | + /** | ||
21 | + * 插入一条尺寸数据 | ||
22 | + * | ||
23 | + * @param size | ||
24 | + * @return | ||
25 | + */ | ||
26 | + public int insertSize(Size size) { | ||
27 | + int rows = ufoSizeMapper.insertSize(size); | ||
28 | + if (rows > 0) { | ||
29 | + productSizeMapper.insert(newProductSize(size)); | ||
30 | + } | ||
31 | + return rows; | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * 更新尺寸数据 | ||
36 | + * | ||
37 | + * @param size | ||
38 | + * @return | ||
39 | + */ | ||
40 | + public int updateSize(@Param("size") Size size) { | ||
41 | + int rows = ufoSizeMapper.updateSize(size); | ||
42 | + if (rows > 0) { | ||
43 | + productSizeMapper.updateBySizeId(newProductSize(size)); | ||
44 | + } | ||
45 | + return rows; | ||
46 | + } | ||
47 | + | ||
48 | + private ProductSize newProductSize(Size size) { | ||
49 | + ProductSize productSize = new ProductSize(); | ||
50 | + productSize.setSizeId(size.getId()); | ||
51 | + productSize.setSizeName(size.getSizeName()); | ||
52 | + productSize.setOrderBy(size.getOrderBy()); | ||
53 | + productSize.setCreateTime(size.getCreateTime()); | ||
54 | + productSize.setUpdateTime(size.getUpdateTime()); | ||
55 | + return productSize; | ||
56 | + } | ||
57 | + | ||
58 | + | ||
59 | +} |
@@ -58,6 +58,9 @@ public class SizeServiceImpl implements ISizeService { | @@ -58,6 +58,9 @@ public class SizeServiceImpl implements ISizeService { | ||
58 | @Autowired | 58 | @Autowired |
59 | private ISizeService sizeService; | 59 | private ISizeService sizeService; |
60 | 60 | ||
61 | + @Autowired | ||
62 | + private SizeManage sizeManage; | ||
63 | + | ||
61 | @Override | 64 | @Override |
62 | public int saveOrUpdateSize(SizeRequestBo sizeRequestBo) { | 65 | public int saveOrUpdateSize(SizeRequestBo sizeRequestBo) { |
63 | LOGGER.info("saveOrUpdateSize param = {}", sizeRequestBo); | 66 | LOGGER.info("saveOrUpdateSize param = {}", sizeRequestBo); |
@@ -76,7 +79,7 @@ public class SizeServiceImpl implements ISizeService { | @@ -76,7 +79,7 @@ public class SizeServiceImpl implements ISizeService { | ||
76 | size.setOrderBy(0); | 79 | size.setOrderBy(0); |
77 | } | 80 | } |
78 | // 新增 | 81 | // 新增 |
79 | - return ufoSizeMapper.insertSize(size); | 82 | + return sizeManage.insertSize(size); |
80 | } else { | 83 | } else { |
81 | List<Size> sizes = ufoSizeMapper.selectBySizeNameEx(size.getSizeName(), size.getId()); | 84 | List<Size> sizes = ufoSizeMapper.selectBySizeNameEx(size.getSizeName(), size.getId()); |
82 | if (CollectionUtils.isNotEmpty(sizes)) { | 85 | if (CollectionUtils.isNotEmpty(sizes)) { |
@@ -85,7 +88,7 @@ public class SizeServiceImpl implements ISizeService { | @@ -85,7 +88,7 @@ public class SizeServiceImpl implements ISizeService { | ||
85 | 88 | ||
86 | // 更新 | 89 | // 更新 |
87 | size.setUpdateTime(DateUtil.currentTimeSeconds()); | 90 | size.setUpdateTime(DateUtil.currentTimeSeconds()); |
88 | - return ufoSizeMapper.updateSize(size); | 91 | + return sizeManage.updateSize(size); |
89 | } | 92 | } |
90 | } | 93 | } |
91 | 94 | ||
@@ -346,7 +349,7 @@ public class SizeServiceImpl implements ISizeService { | @@ -346,7 +349,7 @@ public class SizeServiceImpl implements ISizeService { | ||
346 | s.setCreateTime(time); | 349 | s.setCreateTime(time); |
347 | s.setUpdateTime(0); | 350 | s.setUpdateTime(0); |
348 | LOGGER.info("切换品类尺码数据, 构建新尺码:{}", s); | 351 | LOGGER.info("切换品类尺码数据, 构建新尺码:{}", s); |
349 | - ufoSizeMapper.insertSize(s); | 352 | + sizeManage.insertSize(s); |
350 | LOGGER.info("切换品类尺码数据, 保存新尺码成功:{}", s); | 353 | LOGGER.info("切换品类尺码数据, 保存新尺码成功:{}", s); |
351 | 354 | ||
352 | LOGGER.info("切换品类尺码数据, 获取 {} 绑定的类别", sName); | 355 | LOGGER.info("切换品类尺码数据, 获取 {} 绑定的类别", sName); |
@@ -60,6 +60,7 @@ datasources: | @@ -60,6 +60,7 @@ datasources: | ||
60 | - com.yoho.order.dal.DepositOrderMapper | 60 | - com.yoho.order.dal.DepositOrderMapper |
61 | - com.yoho.order.dal.DepositCodeMapper | 61 | - com.yoho.order.dal.DepositCodeMapper |
62 | - com.yoho.order.dal.ClearanceRecordMapper | 62 | - com.yoho.order.dal.ClearanceRecordMapper |
63 | + - com.yoho.order.dal.ProductSizeMapper | ||
63 | 64 | ||
64 | ufo_resource: | 65 | ufo_resource: |
65 | servers: | 66 | servers: |
@@ -61,6 +61,7 @@ datasources: | @@ -61,6 +61,7 @@ datasources: | ||
61 | - com.yoho.order.dal.DepositOrderMapper | 61 | - com.yoho.order.dal.DepositOrderMapper |
62 | - com.yoho.order.dal.DepositCodeMapper | 62 | - com.yoho.order.dal.DepositCodeMapper |
63 | - com.yoho.order.dal.ClearanceRecordMapper | 63 | - com.yoho.order.dal.ClearanceRecordMapper |
64 | + - com.yoho.order.dal.ProductSizeMapper | ||
64 | 65 | ||
65 | ufo_resource: | 66 | ufo_resource: |
66 | servers: | 67 | servers: |
-
mentioned in commit f032d73b
-
Please register or login to post a comment