ImUserFriendMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.ImUserFriendDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.ImUserFriend" id="ImUserFriend">
  9. <result column="id_" property="id" />
  10. <result column="user_id_" property="userId" />
  11. <result column="friend_id_" property="friendId" />
  12. <result column="friend_nickname_" property="friendNickname" />
  13. <result column="memo_" property="memo" />
  14. <result column="tags_" property="tags" />
  15. <result column="create_time_" property="createTime" />
  16. <result column="update_time_" property="updateTime" />
  17. </resultMap>
  18. <resultMap type="com.ym.mec.biz.dal.dto.ImUserFriendDto" id="ImUserFriendDto" extends="ImUserFriend">
  19. <result column="real_name_" property="friend.realName" />
  20. <result column="avatar_" property="friend.avatar" />
  21. <result column="user_type_" property="friend.userType" />
  22. <result column="phone_" property="friend.phone" />
  23. </resultMap>
  24. <!-- 根据主键查询一条记录 -->
  25. <select id="get" resultMap="ImUserFriend" >
  26. SELECT * FROM im_user_friend WHERE id_ = #{id}
  27. </select>
  28. <!-- 全查询 -->
  29. <select id="findAll" resultMap="ImUserFriend">
  30. SELECT * FROM im_user_friend ORDER BY id_
  31. </select>
  32. <!-- 向数据库增加一条记录 -->
  33. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ImUserFriend" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  34. INSERT INTO im_user_friend (id_,user_id_,friend_id_,friend_nickname_,memo_,tags_,create_time_,update_time_)
  35. VALUES(#{id},#{userId},#{friendId},#{friendNickname},#{memo},#{tags},NOW(),NOW())
  36. </insert>
  37. <insert id="insertByBasicUser">
  38. INSERT INTO im_user_friend (user_id_,friend_id_,friend_nickname_,tags_,memo_,create_time_,update_time_)
  39. VALUES (#{teacherId},#{basicUserDto.userId},#{basicUserDto.name},#{basicUserDto.subjectName},#{basicUserDto.musicGroupName},NOW(),NOW())
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ImUserFriend">
  43. UPDATE im_user_friend <set>
  44. <if test="userId != null">
  45. user_id_ = #{userId},
  46. </if>
  47. <if test="friendId != null">
  48. friend_id_ = #{friendId},
  49. </if>
  50. <if test="friendNickname != null">
  51. friend_nickname_ = #{friendNickname},
  52. </if>
  53. <if test="memo != null">
  54. memo_ = #{memo},
  55. </if>
  56. <if test="tags != null">
  57. tags_ = #{tags},
  58. </if>
  59. update_time_ = NOW()
  60. </set> WHERE id_ = #{id}
  61. </update>
  62. <!-- 根据主键删除一条记录 -->
  63. <delete id="delete" >
  64. DELETE FROM im_user_friend WHERE id_ = #{id}
  65. </delete>
  66. <delete id="deleteByUserId">
  67. DELETE FROM im_user_friend WHERE user_id_ = #{teacherId}
  68. </delete>
  69. <!-- 分页查询 -->
  70. <select id="queryPage" resultMap="ImUserFriend" parameterType="map">
  71. SELECT * FROM im_user_friend ORDER BY id_ <include refid="global.limit"/>
  72. </select>
  73. <!-- 查询当前表的总记录数 -->
  74. <select id="queryCount" resultType="int">
  75. SELECT COUNT(*) FROM im_user_friend
  76. </select>
  77. <select id="query" resultMap="ImUserFriend" parameterType="map">
  78. SELECT * FROM im_user_friend where user_id_ = #{userId} and friend_id_ = #{friendId} LIMIT 1
  79. </select>
  80. <select id="queryFriendListByUserId" resultMap="ImUserFriendDto" parameterType="map">
  81. SELECT iuf.*,u.real_name_,u.avatar_,u.phone_,u.user_type_ FROM im_user_friend iuf left join sys_user u on iuf.friend_id_ = u.id_
  82. where iuf.user_id_ = #{userId}
  83. <if test="search != null">
  84. and (u.real_name_ like concat('%',#{search},'%') or iuf.friend_nickname_ like concat('%',#{search},'%'))
  85. </if>
  86. </select>
  87. <select id="queryFriendDetail" resultMap="ImUserFriendDto" parameterType="map">
  88. SELECT iuf.*,u.real_name_,u.avatar_,u.phone_,u.user_type_ FROM im_user_friend iuf left join sys_user u on iuf.friend_id_ = u.id_
  89. where iuf.user_id_ = #{userId} and iuf.friend_id_ = #{friendUserId}
  90. </select>
  91. </mapper>