Files
blog-backEnd/src/main/resources/mapper/UserMapper.xml
2020-05-26 00:13:57 +08:00

135 lines
4.0 KiB
XML

<?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="cn.celess.blog.mapper.UserMapper">
<resultMap id="userResultMap" type="cn.celess.blog.entity.User">
<id column="u_id" property="id"/>
<result column="u_email" property="email"/>
<result column="u_pwd" property="pwd"/>
<result column="u_email_status" property="emailStatus"/>
<result column="u_avatar" property="avatarImgUrl"/>
<result column="u_desc" property="desc"/>
<result column="u_recently_landed_time" property="recentlyLandedDate"/>
<result column="u_display_name" property="displayName"/>
<result column="u_role" property="role"/>
<result column="status" property="status"/>
</resultMap>
<insert id="addUser" useGeneratedKeys="true" keyProperty="id">
insert into user(u_email, u_pwd)
values (#{email}, #{pwd})
</insert>
<update id="updateInfo">
update user set
<if test="desc!=null">u_desc=#{desc},</if>
<if test="displayName!=null">u_display_name=#{displayName}</if>
where u_id=#{id}
</update>
<update id="updateLoginTime">
update user
set u_recently_landed_time=now()
where u_email = #{email}
</update>
<update id="updateAvatarImgUrl">
update user
set u_avatar=#{avatarImgUrl}
where u_id = #{id}
</update>
<update id="updateEmailStatus">
update user
set u_email_status=#{status}
where u_email = #{email}
</update>
<update id="updatePwd">
update user
set u_pwd=#{pwd}
where u_email = #{email}
</update>
<update id="setUserRole">
update user
set u_role=#{role}
where u_id = #{id}
</update>
<update id="update">
update user
set u_email = #{email},
u_pwd = #{pwd},
u_email_status = #{emailStatus},
u_desc = #{desc},
u_display_name = #{displayName},
u_avatar = #{avatarImgUrl},
u_role = #{role}
where u_id = #{id}
</update>
<update id="delete">
update user
set status= 2
where u_id = #{id}
</update>
<update id="lock">
update user
set status= 1
where u_id = #{id}
</update>
<select id="existsByEmail" resultType="java.lang.Boolean">
select exists(select * from user where u_email = #{email})
</select>
<select id="findByEmail" resultMap="userResultMap">
select *
from user
where u_email = #{email}
</select>
<select id="findById" resultMap="userResultMap">
select *
from user
where u_id = #{id}
</select>
<select id="getAvatarImgUrlById" resultType="string">
select u_avatar
from user
where u_id = #{id};
</select>
<select id="getEmail" resultType="java.lang.String">
select u_email
from user
where u_id = #{id}
</select>
<select id="getDisPlayName" resultType="java.lang.String">
select u_display_name
from user
where u_id = #{id}
</select>
<select id="getPwd" resultType="java.lang.String">
select u_pwd
from user
where u_email = #{email}
</select>
<select id="getRoleByEmail" resultType="java.lang.String">
select u_role
from user
where u_email = #{emai}
</select>
<select id="count" resultType="java.lang.Long">
select count(*)
from user
where status =0;
</select>
<select id="getRoleById" resultType="java.lang.String">
select u_role
from user
where u_id = #{id}
</select>
<select id="findAll" resultMap="userResultMap">
select *
from user
</select>
</mapper>