UfoProductDetailsMapper.xml
3.26 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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.UfoProductDetailsMapper">
<resultMap id="productDetails" type="com.yoho.ufo.model.goodsmanage.ProductDetails">
</resultMap>
<sql id="queryColumns">
product.id, product.product_code, product.product_name, product.product_code, brand.brand_name,
CONCAT(IFNULL(CONCAT(sort2.sort_name,'/'),''),sort1.sort_name) AS sortName, product.del_status, pool_detail.order_by
</sql>
<select id="queryProductIdsByProductIds" parameterType="java.util.Set" resultType="integer">
select id from product
where del_status = 0 and id in
<foreach collection="set" index="index" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<sql id="queryParam">
WHERE pool_detail.pool_id = #{productDetails.poolId}
<if test="productDetails.productCode != null and productDetails.productCode != ''">
and product.product_code like concat('%',#{productDetails.productCode}, '%')
</if>
<if test="productDetails.id != null and productDetails.id != ''">
and product.id like #{productDetails.id}
</if>
<if test="productDetails.productName != null and productDetails.productName != ''">
and product.product_name like concat('%', #{productDetails.productName}, '%')
</if>
<if test="productDetails.brandName != null and productDetails.brandName != ''">
and brand.brand_name like concat('%', #{productDetails.brandName}, '%')
</if>
<if test="productDetails.sortName != null and productDetails.sortName != ''">
and (sort1.sort_name like concat('%', #{productDetails.sortName}, '%') or sort2.sort_name like concat('%', #{productDetails.sortName}, '%'))
</if>
</sql>
<sql id="queryTable">
FROM product_pool pool
LEFT JOIN product_pool_detail pool_detail
ON pool.id = pool_detail.pool_id
LEFT JOIN product
ON pool_detail.product_id = product.id
LEFT JOIN brand
ON product.brand_id = brand.id
LEFT JOIN product_sort sort1
ON product.mid_sort_id = sort1.id
LEFT JOIN product_sort sort2
ON product.max_sort_id = sort2.id
</sql>
<select id="selectProductDetailsCount" resultType="integer">
SELECT COUNT(*)
<include refid="queryTable"/>
<include refid="queryParam"/>
</select>
<select id="getProductDetailsPageList" resultMap="productDetails">
select <include refid="queryColumns"/>
<include refid="queryTable"/>
<include refid="queryParam"/>
order by pool_detail.order_by desc
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectAllCountByPoolId" resultType="java.lang.Integer">
select count(1) from product_pool_detail
where pool_id=#{poolId}
</select>
<select id="selectAllByPoolId" parameterType="java.lang.Integer" resultMap="productDetails">
select product_id, order_by
from product_pool_detail
where pool_id=#{poolId}
order by order_by desc
</select>
</mapper>