SelfSizeMapper.xml
2.82 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
<?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.product.dal.SelfSizeMapper" >
<resultMap id="BaseResultMap" type="com.yoho.product.model.SelfSize" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="product_id" property="productId" jdbcType="INTEGER" />
<result column="goods_id" property="goodsId" jdbcType="INTEGER" />
<result column="size_id" property="sizeId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="INTEGER" />
<result column="audit_uid" property="auditUid" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, product_id, goods_id, size_id, audit_time, audit_uid, status
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from self_size
where id = #{id,jdbcType=INTEGER}
</select>
<sql id="Query_Sql" >
<if test="selfSizeReq.productName != null and selfSizeReq.productName != '' ">
<bind name="pattern" value="'%' + selfSizeReq.productName + '%'" />
and b.product_name like #{pattern}
</if>
<if test="selfSizeReq.productCode != null and selfSizeReq.productCode != '' ">
and b.product_code=#{selfSizeReq.productCode}
</if>
<if test="selfSizeReq.status != null">
and a.status=#{selfSizeReq.status}
</if>
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SelfSizeReq">
select count(1)
from self_size a
<if test="selfSizeReq.productName != null or selfSizeReq.productCode != null">
LEFT JOIN product b
ON( b.id=a.product_id)
</if>
where 1=1
<include refid="Query_Sql"></include>
</select>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SelfSizeReq">
select a.id, a.product_id, a.goods_id, a.size_id, a.audit_time, a.audit_uid, a.status
from self_size a
<if test="selfSizeReq.productName != null or selfSizeReq.productCode != null">
LEFT JOIN product b
ON( b.id=a.product_id)
</if>
where 1=1
<include refid="Query_Sql"></include>
order by a.id desc
<if test="selfSizeReq.start!=null and selfSizeReq.size != null">
limit #{selfSizeReq.start},#{selfSizeReq.size}
</if>
</select>
<update id="upadteAuditResult">
update self_size set status=#{status}, audit_time=unix_timestamp(), audit_uid=#{auditUid}
where id=#{id} and status=0
</update>
</mapper>