<?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.lymsh.yimiao.main.data.dao.YmUserKidMapsMapper">
<resultMap id="YmUserKidMapsResultMap" type="com.lymsh.yimiao.main.data.model.YmUserKidMaps">
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="kid_id" property="kidId" jdbcType="VARCHAR" />
<result column="created" property="created" jdbcType="TIMESTAMP" />
<result column="yn" property="yn" jdbcType="INTEGER" />
</resultMap>
<insert id="addYmUserKidMaps" parameterType="com.lymsh.yimiao.main.data.model.YmUserKidMaps">
insert into ym_user_kid_maps (user_id,kid_id,created,yn) values (#{userId},#{kidId},#{created},#{yn})
</insert>
<update id="updateYmUserKidMaps" parameterType="com.lymsh.yimiao.main.data.model.YmUserKidMaps">
update ym_user_kid_maps <set><if test="userId != null and userId >= 0">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="kidId != null and kidId != ''">
kid_id = #{kidId,jdbcType=VARCHAR},
</if>
<if test="created != null">
created = #{created,jdbcType=TIMESTAMP},
</if>
<if test="yn != null and yn >= 0">
yn = #{yn,jdbcType=INTEGER},
</if>
</set>
</update>
<delete id="deleteYmUserKidMaps" parameterType="java.lang.Integer">
</delete>
<select id="getYmUserKidMaps" resultMap="YmUserKidMapsResultMap" parameterType="java.lang.Integer">
select user_id,kid_id,created,yn
from ym_user_kid_maps
WHERE user_id = #{userId,jdbcType=INTEGER}
</select>
<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>
<sql id="YmUserKidMapsCondition">
<where>
1 = 1
<if test="userId != null and userId >= 0">
and user_id = #{userId,jdbcType=INTEGER}
</if>
<if test="kidId != null and kidId != ''">
and kid_id = #{kidId,jdbcType=VARCHAR}
</if>
<if test="created != null">
and created = #{created,jdbcType=TIMESTAMP}
</if>
<if test="yn != null and yn >= 0">
and yn = #{yn,jdbcType=INTEGER}
</if>
</where>
</sql>
<select id="queryYmUserKidMaps" resultMap="YmUserKidMapsResultMap" parameterType="com.lymsh.yimiao.main.data.model.YmUserKidMapsQuery">
select user_id,kid_id,created,yn
from ym_user_kid_maps
<include refid="YmUserKidMapsCondition" />
<include refid="orderAndLimit" />
</select>
<select id="queryYmUserKidMapsCount" resultType="int" parameterType="com.lymsh.yimiao.main.data.model.YmUserKidMapsQuery">
select count(1) from ym_user_kid_maps
<include refid="YmUserKidMapsCondition" />
</select>
</mapper>