<?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.YmUsersMapper">
<resultMap id="YmUsersResultMap" type="com.lymsh.yimiao.main.data.model.YmUsers">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="avatar" property="avatar" jdbcType="VARCHAR" />
<result column="nickname" property="nickname" jdbcType="VARCHAR" />
<result column="yn" property="yn" jdbcType="INTEGER" />
<result column="created" property="created" jdbcType="TIMESTAMP" />
<result column="modified" property="modified" jdbcType="TIMESTAMP" />
<result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP" />
<result column="login_center_id" property="loginCenterId" jdbcType="INTEGER" />
</resultMap>
<insert id="addYmUsers" keyProperty="id" useGeneratedKeys="false" parameterType="com.lymsh.yimiao.main.data.model.YmUsers">
<selectKey resultType="int" keyProperty="id" order="BEFORE">
SELECT WXYL_SEQ.nextval AS id
FROM dual
</selectKey>
insert into ym_users (id,phone,avatar,nickname,yn,created,modified,last_login_time,login_center_id) values (#{id,jdbcType=INTEGER},#{phone,jdbcType=VARCHAR},#{avatar,jdbcType=VARCHAR}
,#{nickname,jdbcType=VARCHAR},#{yn,jdbcType=INTEGER},#{created,jdbcType=TIMESTAMP},#{modified,jdbcType=TIMESTAMP},#{lastLoginTime,jdbcType=TIMESTAMP},#{loginCenterId,jdbcType=INTEGER})
</insert>
<update id="updateYmUsers" parameterType="com.lymsh.yimiao.main.data.model.YmUsers">
update ym_users <set><if test="phone != null and phone != ''">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="loginCenterId != null and loginCenterId != ''">
login_center_id = #{loginCenterId,jdbcType=INTEGER},
</if>
<if test="avatar != null and avatar != ''">
avatar = #{avatar,jdbcType=VARCHAR},
</if>
<if test="nickname != null and nickname != ''">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="yn != null and yn >= 0">
yn = #{yn,jdbcType=INTEGER},
</if>
<if test="created != null">
created = #{created,jdbcType=TIMESTAMP},
</if>
<if test="modified != null">
modified = #{modified,jdbcType=TIMESTAMP},
</if>
<if test="lastLoginTime != null">
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteYmUsers" parameterType="java.lang.Integer">
delete from ym_users where id = #{id,jdbcType=INTEGER}
</delete>
<select id="getYmUsers" resultMap="YmUsersResultMap" parameterType="java.lang.Integer">
select id,phone,avatar,nickname,yn,created,modified,last_login_time,login_center_id
from ym_users where id = #{id,jdbcType=INTEGER}
</select>
<select id="getUsersByLoginCenterId" resultMap="YmUsersResultMap" parameterType="java.lang.Integer">
SELECT id,phone,avatar,nickname,yn,created,modified,last_login_time,login_center_id
FROM ym_users
WHERE login_center_id = #{loginCenterId,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="YmUsersCondition">
<where>
1 = 1
<if test="id != null and id >= 0">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone,jdbcType=VARCHAR}
</if>
<if test="avatar != null and avatar != ''">
and avatar = #{avatar,jdbcType=VARCHAR}
</if>
<if test="nickname != null and nickname != ''">
and nickname = #{nickname,jdbcType=VARCHAR}
</if>
<if test="yn != null and yn >= 0">
and yn = #{yn,jdbcType=INTEGER}
</if>
<if test="created != null">
and created = #{created,jdbcType=TIMESTAMP}
</if>
<if test="modified != null">
and modified = #{modified,jdbcType=TIMESTAMP}
</if>
<if test="lastLoginTime != null">
and last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP}
</if>
<if test="loginCenterId != null">
and login_center_id = #{loginCenterId,jdbcType=INTEGER}
</if>
</where>
</sql>
<select id="queryYmUsers" resultMap="YmUsersResultMap" parameterType="com.lymsh.yimiao.main.data.model.YmUsersQuery">
select id,phone,avatar,nickname,yn,created,modified,last_login_time,login_center_id
from ym_users
<include refid="YmUsersCondition" />
<include refid="orderAndLimit" />
</select>
<select id="queryYmUsersCount" resultType="int" parameterType="com.lymsh.yimiao.main.data.model.YmUsersQuery">
select count(1) from ym_users
<include refid="YmUsersCondition" />
</select>
</mapper>