ImGroupMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.ImGroupDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.ImGroup">
  5. <id column="id_" jdbcType="VARCHAR" property="id"/>
  6. <result column="name_" jdbcType="VARCHAR" property="name"/>
  7. <result column="introduce_" jdbcType="VARCHAR" property="introduce"/>
  8. <result column="member_num_" jdbcType="INTEGER" property="memberNum"/>
  9. <result column="memo_" jdbcType="VARCHAR" property="memo"/>
  10. <result column="img_" jdbcType="VARCHAR" property="img"/>
  11. <result column="type_" jdbcType="VARCHAR" property="type"/>
  12. <result column="create_by_" property="createBy"/>
  13. <result column="auto_pass_flag_" property="autoPassFlag"/>
  14. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  15. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  16. <result column="config_json_" jdbcType="VARCHAR" property="configJson"/>
  17. </resultMap>
  18. <sql id="Base_Column_List">
  19. id_, name_, introduce_, member_num_, memo_, img_, type_,create_by_, create_time_, update_time_
  20. </sql>
  21. <update id="updateById" parameterType="com.yonge.cooleshow.biz.dal.entity.ImGroup">
  22. update im_group
  23. <set>
  24. <if test="et.name != null">
  25. name_ = #{et.name},
  26. </if>
  27. <if test="et.autoPassFlag != null">
  28. auto_pass_flag_ = #{et.autoPassFlag},
  29. </if>
  30. <if test="et.introduce != null and et.introduce != ''">
  31. introduce_ = #{et.introduce},
  32. </if>
  33. <if test="et.memo != null and et.memo != ''">
  34. memo_ = #{et.memo},
  35. </if>
  36. <if test="et.configJson != null">
  37. config_json_ = #{et.configJson},
  38. </if>
  39. update_time_ = NOW()
  40. </set>
  41. where id_ = #{et.id}
  42. </update>
  43. <update id="updateMemberNum">
  44. UPDATE im_group ig
  45. LEFT JOIN (SELECT COUNT(id_) num_,group_id_ FROM im_group_member
  46. <if test="groupId != null">
  47. WHERE group_id_ = #{groupId}
  48. </if>
  49. GROUP BY group_id_) igm ON ig.id_ = igm.group_id_
  50. SET member_num_ = igm.num_
  51. WHERE ig.id_ = igm.group_id_
  52. </update>
  53. <update id="updateStatus">
  54. update im_history_message set status_ = 1
  55. where msgUID_ in <foreach collection="info" open="(" close=")" separator="," item="info">
  56. #{info.msgUID}
  57. </foreach>
  58. </update>
  59. <select id="findAll" resultMap="BaseResultMap">
  60. SELECT ig.* FROM im_group ig
  61. LEFT JOIN im_group_member igm ON igm.group_id_ = ig.id_
  62. <where>
  63. <if test="imGroupDto.type != null and imGroupDto.type != ''">
  64. AND ig.type_ = #{imGroupDto.type}
  65. </if>
  66. <if test="imGroupDto.createUserId != null">
  67. AND ig.create_by_ = #{imGroupDto.createUserId}
  68. </if>
  69. <if test="imGroupDto.userId != null">
  70. AND igm.user_id_ = #{imGroupDto.userId}
  71. </if>
  72. <if test="imGroupDto.roleType != null">
  73. AND igm.role_type_ = #{imGroupDto.roleType}
  74. </if>
  75. <if test="imGroupDto.search != null and imGroupDto.search != ''">
  76. AND (ig.id_ = #{imGroupDto.search} OR
  77. ig.name_ LIKE CONCAT('%',#{imGroupDto.search},'%') OR ig.introduce_ LIKE CONCAT('%',#{imGroupDto.search},'%'))
  78. </if>
  79. </where>
  80. ORDER BY id_ DESC
  81. </select>
  82. <resultMap id="ImGroupResultDto" type="com.yonge.cooleshow.biz.dal.dto.ImGroupResultDto" extends="BaseResultMap">
  83. <result property="existFlag" column="existFlag"/>
  84. <result property="hasWaitAuditFlag" column="hasWaitAuditFlag"/>
  85. </resultMap>
  86. <select id="queryTeacherFun" resultMap="ImGroupResultDto">
  87. SELECT ig.*,
  88. CASE WHEN igm.id_ IS NULL THEN 0 ELSE 1 END existFlag,
  89. CASE WHEN igma.id_ IS NULL THEN 0 ELSE 1 END hasWaitAuditFlag
  90. FROM im_group ig
  91. LEFT JOIN im_group_member igm ON (ig.id_ = igm.group_id_ AND igm.user_id_ = #{imGroupDto.userId} <if test="imGroupDto.roleType != null"> AND igm.role_type_ = #{imGroupDto.roleType} </if>)
  92. LEFT JOIN im_group_member_audit igma ON igma.group_id_ = ig.id_ AND igma.audit_status_ = 'AUDITING' AND igma.user_id_ = #{imGroupDto.userId}
  93. WHERE ig.create_by_ = #{imGroupDto.createUserId}
  94. <if test="imGroupDto.type != null and imGroupDto.type != ''">
  95. AND ig.type_ = #{imGroupDto.type}
  96. </if>
  97. <if test="imGroupDto.search != null and imGroupDto.search != ''">
  98. AND (ig.id_ = #{imGroupDto.search} OR
  99. ig.name_ LIKE CONCAT('%',#{imGroupDto.search},'%') OR ig.introduce_ LIKE CONCAT('%',#{imGroupDto.search},'%'))
  100. </if>
  101. GROUP BY ig.id_
  102. </select>
  103. <select id="selectAll" resultType="com.yonge.cooleshow.biz.dal.entity.ImHistoryMessage">
  104. select msgUID_ AS msgUID,
  105. fromUserId_ AS fromUserId,
  106. targetId_ AS targetId,
  107. targetType_ AS targetType,
  108. GroupId_ AS groupId,
  109. busChannel_ AS busChannel,
  110. classname_ AS classname,
  111. content_ AS content,
  112. extraContent_ AS extraContent,
  113. dateTime_ AS dateTime,
  114. source_ AS source,
  115. isDiscard_ AS isDiscard,
  116. isSensitiveWord_ AS isSensitiveWord,
  117. isForbidden_ AS isForbidden,
  118. isNotForward_ AS isNotForward,
  119. groupUserIds_ AS groupUserIds,
  120. appId_ AS appId
  121. from im_history_message
  122. where status_ = 0
  123. limit #{result},#{size}
  124. </select>
  125. <select id="queryCount" resultType="java.lang.Integer">
  126. SELECT COUNT(*) FROM im_history_message where status_ = 0
  127. </select>
  128. <insert id="batchInsert" parameterType="com.yonge.cooleshow.biz.dal.entity.ImHistoryMessage">
  129. insert ignore into im_history_message(msgUID_,fromUserId_,targetId_,targetType_,
  130. GroupId_,busChannel_,classname_,content_,
  131. extraContent_,dateTime_,source_,isDiscard_,
  132. isSensitiveWord_,isForbidden_,isNotForward_,
  133. groupUserIds_,appId_)
  134. values
  135. <foreach collection="list" separator="," item="item" >
  136. (#{item.msgUID,jdbcType=VARCHAR},#{item.fromUserId,jdbcType=VARCHAR},#{item.targetId,jdbcType=VARCHAR},
  137. #{item.targetType},#{item.groupId,jdbcType=VARCHAR},#{item.busChannel,jdbcType=VARCHAR},
  138. #{item.classname,jdbcType=VARCHAR},#{item.content,jdbcType=VARCHAR},#{item.extraContent,jdbcType=VARCHAR},
  139. #{item.dateTime,jdbcType=VARCHAR},#{item.source,jdbcType=VARCHAR},#{item.isDiscard,jdbcType=VARCHAR},
  140. #{item.isSensitiveWord,jdbcType=VARCHAR},#{item.isForbidden,jdbcType=VARCHAR},#{item.isNotForward,jdbcType=VARCHAR},
  141. #{item.groupUserIds,jdbcType=VARCHAR},#{item.appId,jdbcType=VARCHAR})
  142. </foreach>
  143. </insert>
  144. </mapper>