ImUserFriendMapper.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.ImUserFriendDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.ImUserFriend">
  5. <id column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="user_id_" jdbcType="INTEGER" property="userId"/>
  7. <result column="friend_id_" jdbcType="INTEGER" property="friendId"/>
  8. <result column="friend_nickname_" jdbcType="VARCHAR" property="friendNickname"/>
  9. <result column="friend_avatar_" jdbcType="VARCHAR" property="friendAvatar"/>
  10. <result column="memo_" jdbcType="VARCHAR" property="memo"/>
  11. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  12. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  13. </resultMap>
  14. <sql id="Base_Column_List">
  15. id_, user_id_, friend_id_, friend_nickname_,friend_avatar_, memo_, create_time_, update_time_
  16. </sql>
  17. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  18. parameterType="com.yonge.cooleshow.biz.dal.entity.ImUserFriend">
  19. INSERT INTO im_user_friend(user_id_, client_type_, friend_id_, friend_type_, friend_nickname_,friend_avatar_, memo_, create_time_, update_time_) VALUES
  20. <foreach collection="entities" item="entity" separator=",">
  21. (#{entity.userId}, #{entity.clientType}, #{entity.friendId}, #{entity.friendType}, #{entity.friendNickname}, #{entity.friendAvatar}, #{entity.memo}, #{entity.createTime}, #{entity.updateTime})
  22. </foreach>
  23. ON DUPLICATE KEY UPDATE user_id_ = VALUES(user_id_), client_type_ = VALUES(client_type_), friend_id_ = VALUES(friend_id_), friend_type_ = VALUES(friend_type_)
  24. </insert>
  25. <select id="findByUserIdAndFriendId" resultMap="BaseResultMap">
  26. SELECT <include refid="Base_Column_List"/> FROM im_user_friend WHERE user_id_ = #{userId} AND friend_id_ = #{friendId} LIMIT 1
  27. </select>
  28. <delete id="delFriendByTenantId">
  29. DELETE t1
  30. FROM im_user_friend t1
  31. LEFT JOIN teacher t2 ON t1.friend_id_ = t2.user_id_
  32. LEFT JOIN teacher t3 ON t1.user_id_ = t3.user_id_
  33. WHERE (t1.user_id_ = #{userId} and t1.client_type_ = #{clientType} and t2.tenant_id_ = #{tenantId})
  34. OR (t1.friend_id_ = #{userId} and t1.friend_type_ = #{clientType} and t3.tenant_id_ = #{tenantId})
  35. </delete>
  36. </mapper>