113 lines
5.3 KiB
XML
113 lines
5.3 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="com.ruoyi.app.mapper.AppUserFriendMapper">
|
|
|
|
<resultMap type="AppUserFriend" id="AppUserFriendResult">
|
|
<result property="id" column="id" />
|
|
<result property="userId" column="user_id" />
|
|
<result property="friendId" column="friend_id" />
|
|
<result property="status" column="status" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="updateBy" column="updateBy" />
|
|
<result property="remark" column="remark" />
|
|
</resultMap>
|
|
|
|
<sql id="selectAppUserFriendVo">
|
|
select id, user_id, friend_id, status, create_time, update_time, create_by, updateBy, remark from app_user_friend
|
|
</sql>
|
|
|
|
<select id="selectAppUserFriendList" parameterType="AppUserFriend" resultMap="AppUserFriendResult">
|
|
<include refid="selectAppUserFriendVo"/>
|
|
<where>
|
|
<if test="userId != null "> and user_id = #{userId}</if>
|
|
<if test="friendId != null "> and friend_id = #{friendId}</if>
|
|
<if test="status != null "> and status = #{status}</if>
|
|
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectByFriendId" parameterType="java.lang.Long" resultType="java.lang.Long">
|
|
select DISTINCT(user_id) from app_user_friend
|
|
<where>
|
|
<if test="ids != null and ids.size() > 0">
|
|
friend_id in
|
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectFriendList" parameterType="AppUserFriend" resultType="com.ruoyi.app.domain.vo.AppUserFriendVo">
|
|
select a.id as "id",a.user_id as "userId",a.friend_id as "friendId",a.status as "status",a.create_time as "createTime",
|
|
u.username as "username",
|
|
u.avatar_url as "avatarUrl"
|
|
from app_user_friend a
|
|
left join app_user u on u.id = a.friend_id
|
|
<where>
|
|
<if test="userId != null "> and a.user_id = #{userId}</if>
|
|
<if test="friendId != null "> and a.friend_id = #{friendId}</if>
|
|
<if test="status != null "> and a.status = #{status}</if>
|
|
<if test="updateBy != null and updateBy != ''"> and a.updateBy = #{updateBy}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectAppUserFriendById" parameterType="Long" resultMap="AppUserFriendResult">
|
|
<include refid="selectAppUserFriendVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertAppUserFriend" parameterType="AppUserFriend" useGeneratedKeys="true" keyProperty="id">
|
|
insert into app_user_friend
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">user_id,</if>
|
|
<if test="friendId != null">friend_id,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="updateBy != null">updateBy,</if>
|
|
<if test="remark != null">remark,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">#{userId},</if>
|
|
<if test="friendId != null">#{friendId},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateAppUserFriend" parameterType="AppUserFriend">
|
|
update app_user_friend
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="userId != null">user_id = #{userId},</if>
|
|
<if test="friendId != null">friend_id = #{friendId},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="updateBy != null">updateBy = #{updateBy},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteAppUserFriendById" parameterType="Long">
|
|
delete from app_user_friend where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteAppUserFriendByIds" parameterType="String">
|
|
delete from app_user_friend where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
</mapper> |