ADD file via upload

master
moec42frf 2 years ago
parent 7eb901a8df
commit ed7ef6771e

@ -0,0 +1,63 @@
<?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="org.sang.mapper.UserMapper">
<select id="loadUserByUsername" resultType="org.sang.bean.User">
SELECT * FROM user WHERE username=#{username}
</select>
<insert id="reg" useGeneratedKeys="true" keyProperty="id">
INSERT INTO user set username=#{username},password=#{password},nickname=#{nickname}
</insert>
<update id="updateUserEmail">
UPDATE user set email=#{email} WHERE id=#{id}
</update>
<select id="getUserByNickname" resultMap="BaseResultMap">
SELECT u.*,r.`id` AS rid,r.`name` AS rname FROM user u,roles r,roles_user ru WHERE u.`id`=ru.`uid` AND
r.`id`=ru.`rid` AND u.`id` NOT IN(SELECT u.`id` FROM user u,roles_user ru WHERE u.`id`=ru.`uid` AND ru.`rid`=1)
<choose>
<when test="nickname!=null and nickname!=''">
and u.nickname like concat('%',#{nickname},'%') ORDER BY u.`id`
</when>
<otherwise>
ORDER BY u.`id` limit 20
</otherwise>
</choose>
</select>
<select id="getUserById" resultMap="BaseResultMap">
SELECT u.*,r.`id` AS rid,r.`name` AS rname FROM user u,roles r,roles_user ru WHERE u.`id`=ru.`uid` AND
r.`id`=ru.`rid` AND u.`id`=#{id}
</select>
<resultMap id="BaseResultMap" type="org.sang.bean.User">
<id column="id" property="id"/>
<result column="username" property="username"/>
<result column="nickname" property="nickname"/>
<result column="password" property="password"/>
<result column="enabled" property="enabled"/>
<result column="email" property="email"/>
<result column="userface" property="userface"/>
<result column="regTime" property="regTime"/>
<collection property="roles" ofType="org.sang.bean.Role">
<id column="rid" property="id"/>
<result column="rname" property="name"/>
</collection>
</resultMap>
<select id="getAllRole" resultType="org.sang.bean.Role">
select * from roles;
</select>
<update id="updateUserEnabled">
UPDATE user set enabled=#{enabled} WHERE id=#{uid}
</update>
<delete id="deleteUserById">
DELETE FROM user WHERE id=#{id}
</delete>
<delete id="deleteUserRolesByUid">
DELETE FROM roles_user WHERE uid=#{id}
</delete>
<insert id="setUserRoles">
INSERT INTO roles_user(rid,uid) VALUES
<foreach collection="rids" separator="," item="rid">
(#{rid},#{id})
</foreach>
</insert>
</mapper>
Loading…
Cancel
Save