<?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.example.recommend.dal.UserModelMapper">
    <resultMap id="BaseResultMap" type="com.example.recommend.model.UserModel">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
        <result column="telephone" jdbcType="VARCHAR" property="telephone"/>
        <result column="password" jdbcType="VARCHAR" property="password"/>
        <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
        <result column="gender" jdbcType="INTEGER" property="gender"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        id, created_at, updated_at, telephone, password, nick_name, gender
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        select
        <include refid="Base_Column_List"/>
        from user
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        delete from user
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" parameterType="com.example.recommend.model.UserModel">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into user (created_at, updated_at, telephone,
        password, nick_name, gender
        )
        values (#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{telephone,jdbcType=VARCHAR},
        #{password,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER}
        )
    </insert>
    <insert id="insertSelective" parameterType="com.example.recommend.model.UserModel">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="createdAt != null">
                created_at,
            </if>
            <if test="updatedAt != null">
                updated_at,
            </if>
            <if test="telephone != null">
                telephone,
            </if>
            <if test="password != null">
                password,
            </if>
            <if test="nickName != null">
                nick_name,
            </if>
            <if test="gender != null">
                gender,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createdAt != null">
                #{createdAt,jdbcType=TIMESTAMP},
            </if>
            <if test="updatedAt != null">
                #{updatedAt,jdbcType=TIMESTAMP},
            </if>
            <if test="telephone != null">
                #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="password != null">
                #{password,jdbcType=VARCHAR},
            </if>
            <if test="nickName != null">
                #{nickName,jdbcType=VARCHAR},
            </if>
            <if test="gender != null">
                #{gender,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.example.recommend.model.UserModel">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        update user
        <set>
            <if test="createdAt != null">
                created_at = #{createdAt,jdbcType=TIMESTAMP},
            </if>
            <if test="updatedAt != null">
                updated_at = #{updatedAt,jdbcType=TIMESTAMP},
            </if>
            <if test="telephone != null">
                telephone = #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="password != null">
                password = #{password,jdbcType=VARCHAR},
            </if>
            <if test="nickName != null">
                nick_name = #{nickName,jdbcType=VARCHAR},
            </if>
            <if test="gender != null">
                gender = #{gender,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.example.recommend.model.UserModel">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Mon Oct 09 13:50:54 CST 2023.
        -->
        update user
        set created_at = #{createdAt,jdbcType=TIMESTAMP},
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
        telephone = #{telephone,jdbcType=VARCHAR},
        password = #{password,jdbcType=VARCHAR},
        nick_name = #{nickName,jdbcType=VARCHAR},
        gender = #{gender,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>

    <select id="selectByTelephoneAndPassword" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        from user where telephone=#{telephone} and password = #{password}
    </select>

    <select id="countAllUser" resultType="java.lang.Integer">
        SELECT count(1)
        from user
    </select>
</mapper>