UfoProductPoolMapper.xml
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?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.ufo.dal.UfoProductPoolMapper">
<resultMap id="productPool" type="com.yoho.ufo.model.goodsmanage.ProductPool">
</resultMap>
<sql id="queryColumns">
pool.id, pool.pool_name, pool.create_time, COUNT(pool_detail.product_id) AS productNum
</sql>
<insert id="insertProductPool" parameterType="com.yoho.ufo.model.goodsmanage.ProductPool" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into product_pool(id, pool_name, create_time, pool_type)
values (#{id}, #{poolName}, #{createTime}, #{poolType})
</insert>
<update id="updateProductPool" parameterType="com.yoho.ufo.model.goodsmanage.ProductPool">
update product_pool set pool_name = #{productPool.poolName}
where id = #{productPool.id}
</update>
<select id="selectOneById" resultMap="productPool">
select id, pool_name
from product_pool where id = #{id}
</select>
<sql id="queryParam">
<where>
<if test="productPool.id != null">
pool.id = #{productPool.id}
</if>
<if test="productPool.poolName != null and productPool.poolName != ''">
and pool.pool_name like concat('%', #{productPool.poolName}, '%')
</if>
</where>
</sql>
<sql id="queryTable">
FROM product_pool pool
LEFT JOIN product_pool_detail pool_detail
ON pool.id = pool_detail.pool_id
</sql>
<select id="selectProductPoolCount" resultType="integer">
SELECT COUNT(*)
FROM product_pool pool
<include refid="queryParam"/>
</select>
<select id="getProductPoolPageList" resultMap="productPool">
select <include refid="queryColumns"/>
<include refid="queryTable"/>
<include refid="queryParam"/>
GROUP BY pool_detail.pool_id
ORDER BY pool.create_time DESC
limit #{page.startIndex}, #{page.pageSize}
</select>
</mapper>