1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.newcoder.community.dao.UserMapper"> <sql id="selectField"> id, username, password, salt, email, type, status, activation_code, header_url, create_time </sql> <sql id="insertFile"> username, password, salt, email, type, status, activation_code, header_url, create_time </sql> <select id="selectById" resultType="User"> select <include refid="selectField"></include> from user where id = #{id} </select> <select id="selectByName" resultType="User"> select <include refid="selectField"></include> from user where username = #{username} </select> <select id="selectByEmail" resultType="User"> select <include refid="selectField"></include> from user where email = #{email} </select>
<insert id="insertUser" parameterType="User" keyProperty="id"> insert into user (<include refid="insertFile"></include>) value (#{username}, #{password}, #{salt}, #{email}, #{type}, #{status}, #{activationCode}, #{headerUrl}, #{createTime}) </insert>
<update id="updateStatus"> update user set status = #{status} where id = #{id} </update>
<update id="updateHeader"> update user set header_url = #{headerUrl} where id = #{id} </update>
<update id="updatePassword"> update user set password = #{password} where id = #{id} </update>
<delete id="deleteByName"> delete from user where username = #{username} </delete> </mapper>
|