<?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.landaiqing.mapper.userMapper">
    <resultMap id="userMap" type="com.landaiqing.entity.UserEntity">
        <!-- 数据库中字段名称 column="" property="id"  类中成员属性名称-->
        <id column="userId" property="userId"></id>
        <result column="nickname" property="nickName"></result>
        <result column="QQ" property="QQ"></result>
        <result column="email" property="email"></result>
        <result column="content" property="content"></result>
        <result column="datetime" property="dateTime"></result>
        <result column="replyContent" property="replyContent"></result>
        <result column="replyDateTime" property="replyDateTime"></result>
    </resultMap>
    <insert id="insert" parameterType="com.landaiqing.entity.UserEntity">
        INSERT INTO `webguestbook`.`user` (`userId`, `nickname`, `qq`, `email`, `content`, `datetime`, `replyContent`, `replyDateTime`) VALUES (null, #{nickName}, #{QQ}, #{email}, #{content} ,#{dateTime},null, null);
    </insert>
    <update id="reply" parameterType="com.landaiqing.entity.UserEntity">
        UPDATE `webguestbook`.`user` SET `replyContent` = #{replyContent}, `replyDateTime` = #{replyDateTime} WHERE `userId` = #{userId};
    </update>
    <update id="update" parameterType="com.landaiqing.entity.UserEntity">
        UPDATE `webguestbook`.`user` SET `nickname` = #{nickName}, `qq` = #{QQ}, `email` = #{email}, `content` = #{content}, `datetime` = #{dateTime}, `replyContent` = #{replyContent}, `replyDateTime` = #{replyDateTime} WHERE `userId` = #{userId};
    </update>
    <delete id="deleteUser" parameterType="int">
        DELETE from `user`  WHERE `userId` = #{userId};
    </delete>
    <select id="list" resultType="com.landaiqing.entity.UserEntity" resultMap="userMap">
        select  * from  user ORDER BY datetime DESC ;
    </select>

</mapper>