IUserFavoriteDao.xml
1.54 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
<?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.yohoufo.dal.user.IUserFavoriteDao" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.user.model.UserFavorite" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="valid_status" property="validStatus" jdbcType="INTEGER" />
<result column="product_id" property="productId" 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, uid, valid_status,product_id, create_time, update_time
</sql>
<select id="selectValidFavoriteByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from favorite_${tableIndex}
where uid = #{uid} and valid_status = 1
</select>
<insert id="insert">
INSERT INTO favorite_${tableIndex} (uid, valid_status,product_id, create_time, update_time)
values
(#{userFavorite.uid},#{userFavorite.validStatus}, #{userFavorite.productId},
#{userFavorite.createTime},#{userFavorite.updateTime})
</insert>
<update id="updateFavoriteInvalid">
update favorite_${tableIndex} set valid_status=0, update_time=#{updateTime}
where uid = ${uid} and valid_status=1 and product_id=${productId}
</update>
</mapper>