<?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.forum.dao.UserDao">
    <update id="update">
        update user set password=#{password} where username=#{username}
    </update>

    <select id="queryByUsernameAndPassword" resultType="com.forum.entity.User">
        select * from user
        where username = #{username} and password = #{password};
    </select>

    <insert id="addUser" parameterType="user">
        insert into user(username,password,email,create_time,update_time,type,school,avatar)
        values(#{username},#{password},#{email},#{createTime},#{updateTime},#{type},#{school},#{avatar})
    </insert>
    <select id="getAllUser" resultType="com.forum.entity.User">
        select id,username,password,email,create_time,type from user
    </select>
    <delete id="deleteUser" >
        delete from user where id = #{id}
    </delete>
    <select id="count" resultType="Integer" >
        select count(*) from user where type = 0
    </select>
</mapper>
