| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <?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.ym.mec.biz.dal.dao.ImGroupDao">
-
- <resultMap type="com.ym.mec.biz.dal.entity.ImGroup" id="ImGroup">
- <result column="id_" property="id" />
- <result column="name_" property="name" />
- <result column="introduce_" property="introduce" />
- <result column="member_num_" property="memberNum" />
- <result column="memo_" property="memo" />
- <result column="tags_" property="tags" />
- <result column="img_" property="img" />
- <result column="type_" property="type" />
- <result column="group_type_" property="groupType" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="tenant_id_" property="tenantId"/>
- <result column="import_flag_" property="importFlag"/>
- </resultMap>
-
- <resultMap type="com.ym.mec.biz.dal.dto.ImGroupMemberDto" id="ImGroupMemberDto">
- <result column="id_" property="id" />
- <result column="im_group_id_" property="imGroupId" />
- <result column="user_id_" property="userId" />
- <result column="nickname_" property="nickname" />
- <result column="is_admin_" property="isAdmin" />
- <result column="role_type_" property="roleType" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="member_rank_setting_id_" property="memberRankSettingId" />
- <result column="subject_name_" property="subjectName" />
- <result column="subject_id_" property="subjectId" />
- <result column="username_" property="user.username" />
- <result column="avatar_" property="user.avatar" />
- <result column="phone_" property="user.phone" />
- <result column="real_name_" property="user.realName" />
- <result column="user_type_" property="user.userType" />
- <result column="group_nickname_" property="groupNickname" />
- </resultMap>
-
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="ImGroup" >
- SELECT * FROM im_group WHERE id_ = #{id}
- </select>
-
- <select id="getLocked" resultMap="ImGroup" >
- SELECT * FROM im_group WHERE id_ = #{id} for update
- </select>
-
- <!-- 全查询 -->
- <select id="findAll" resultMap="ImGroup">
- SELECT * FROM im_group where tenant_id_ = #{tenantId} ORDER BY id_
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ImGroup" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO im_group (id_,name_,introduce_,member_num_,memo_,tags_,img_,type_,create_time_,update_time_,tenant_id_,group_type_,school_id_)
- VALUES(#{id},#{name},#{introduce},#{memberNum},#{memo},#{tags},#{img},#{type},#{createTime},#{updateTime},#{tenantId},#{groupType},#{schoolId})
- </insert>
-
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.ImGroup">
- UPDATE im_group <set>
- <if test="groupType != null">
- group_type_ = #{groupType},
- </if>
- <if test="memberNum != null">
- member_num_ = member_num_ + #{memberNum},
- </if>
- <if test="tags != null">
- tags_ = #{tags},
- </if>
- <if test="introduce != null">
- introduce_ = #{introduce},
- </if>
- <if test="updateTime != null">
- update_time_ = #{updateTime},
- </if>
- <if test="memo != null">
- memo_ = #{memo},
- </if>
- <if test="name != null">
- name_ = #{name},
- </if>
- <if test="img != null">
- img_ = #{img},
- </if>
- <if test="type != null">
- type_ = #{type},
- </if>
- </set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
- </update>
- <update id="updateNickname">
- UPDATE im_group_member SET nickname_ = #{nickName} WHERE user_id_ = #{userId}
- </update>
- <update id="updateUserFriendNickname">
- UPDATE im_user_friend SET friend_nickname_ = #{nickName} WHERE friend_id_ = #{userId};
- </update>
- <update id="updateMemberNum">
- UPDATE im_group ig
- LEFT JOIN (SELECT COUNT(id_) num_,im_group_id_ FROM im_group_member GROUP BY im_group_id_) igm ON ig.id_ = igm.im_group_id_
- SET member_num_ = igm.num_
- WHERE ig.id_ = igm.im_group_id_
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM im_group WHERE id_ = #{id}
- </delete>
- <sql id="queryPageSql">
- <where>
- <if test="userId != null">
- AND igm.user_id_ = #{userId}
- </if>
- <if test="search != null and search != ''">
- AND (ig.name_ like concat('%',#{search},'%') or ig.memo_ like concat('%',#{search},'%'))
- </if>
- <if test="ignoreIds != null and ignoreIds != ''">
- AND NOT FIND_IN_SET(ig.id_,#{ignoreIds})
- </if>
- <if test="targetIds != null and targetIds != ''">
- AND FIND_IN_SET(ig.id_,#{targetIds})
- </if>
- <if test="groupType != null">
- AND ig.group_type_ = #{groupType}
- </if>
- <if test="importFlag != null">
- AND ig.import_flag_ = #{importFlag}
- </if>
- </where>
- </sql>
-
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="ImGroup" parameterType="map">
- SELECT ig.* FROM im_group ig
- LEFT JOIN im_group_member igm ON igm.im_group_id_ = ig.id_
- <include refid="queryPageSql" />
- GROUP BY ig.id_
- ORDER BY id_
- <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(DISTINCT ig.id_) FROM im_group ig
- LEFT JOIN im_group_member igm ON igm.im_group_id_ = ig.id_
- <include refid="queryPageSql" />
- </select>
-
- <select id="queryByUserId" resultMap="ImGroup" parameterType="map">
- SELECT ig.* FROM im_group_member igm
- LEFT JOIN im_group ig ON igm.im_group_id_ = ig.id_
- where 1 =1
- <if test="userId != null">
- AND igm.user_id_ = #{userId}
- </if>
- <if test="search != null and search != ''">
- AND (ig.name_ like concat('%',#{search},'%') or ig.tags_ like concat('%',#{search},'%'))
- </if>
- <if test="groupType != null and groupType != ''">
- AND ig.group_type_ = #{groupType}
- </if>
- </select>
-
- <select id="queryMemberById" resultMap="ImGroupMemberDto">
- SELECT igm.*
- , u.avatar_
- , CASE WHEN find_in_set('STUDENT',u.user_type_) THEN u.username_ ELSE u.real_name_ END username_
- , IFNULL(NULLIF(u.username_, ''), u.real_name_) AS group_nickname_
- , u.real_name_
- , u.user_type_
- , st.member_rank_setting_id_,s.name_ subject_name_,st.subject_id_list_ subject_id_
- FROM im_group_member igm
- LEFT JOIN sys_user u ON igm.user_id_ = u.id_
- LEFT JOIN student st ON st.user_id_ = u.id_
- LEFT JOIN `subject` s ON s.id_ = st.subject_id_list_
- WHERE igm.im_group_id_ = #{imGroupId}
- <if test="search != null and search != ''">
- AND (u.username_ like concat('%',#{search},'%') or u.real_name_ like concat('%',#{search},'%'))
- </if>
- </select>
-
- <select id="queryMember" resultMap="ImGroupMemberDto" parameterType="map">
- SELECT igm.*,u.avatar_,CASE WHEN find_in_set('STUDENT',u.user_type_) THEN u.username_ ELSE u.real_name_ END username_
- FROM im_group_member igm left join sys_user u on igm.user_id_ = u.id_
- WHERE igm.user_id_ = #{userId}
- <if test="imGroupId != null and imGroupId != ''">
- AND igm.im_group_id_ = #{imGroupId}
- </if>
- <if test="imGroupId == null or imGroupId == ''">
- LIMIT 1
- </if>
- </select>
- <resultMap id="NameDto" type="com.ym.mec.biz.dal.dto.NameDto">
- <result property="id" column="id_" />
- <result property="name" column="name_" />
- <result property="type" column="type_"/>
- </resultMap>
- <select id="queryNameByIds" resultMap="NameDto">
- select id_,name_,3 type_ from im_group where FIND_IN_SET(id_,#{ids})
- </select>
- <select id="queryByUserIdV2" resultMap="ImGroup">
- SELECT ig.* FROM im_group_member igm
- LEFT JOIN im_group ig ON igm.im_group_id_ = ig.id_
- left join class_group cg on cg.id_ = ig.id_
- left join music_group mg on mg.id_ = cg.music_group_id_
- where 1 =1 and ig.group_type_ in ('NORMAL','MIX')
- <if test="userId != null">
- AND igm.user_id_ = #{userId}
- </if>
- <if test="search != null and search != ''">
- AND (ig.name_ like concat('%',#{search},'%') or ig.tags_ like concat('%',#{search},'%'))
- </if>
- <if test="groupType != null and groupType != ''">
- AND ig.group_type_ = #{groupType}
- </if>
- <if test="musicGroupId != null and musicGroupId != ''">
- and mg.id_ = #{musicGroupId}
- </if>
- <if test="classType != null and classType != ''">
- AND cg.type_ = #{classType}
- </if>
- </select>
- <select id="queryMemberByIdV2" resultMap="ImGroupMemberDto">
- SELECT igm.*,u.avatar_,CASE WHEN find_in_set('STUDENT',u.user_type_) THEN u.username_ ELSE u.real_name_ END username_,
- st.member_rank_setting_id_,s.name_ subject_name_,st.subject_id_list_ subject_id_
- FROM im_group_member igm
- LEFT JOIN sys_user u ON igm.user_id_ = u.id_
- LEFT JOIN student st ON st.user_id_ = u.id_
- LEFT JOIN `subject` s ON s.id_ = st.subject_id_list_
- WHERE igm.im_group_id_ = #{imGroupId} and st.user_id_ is not null
- <if test="search != null">
- and (u.real_name_ like concat('%',#{search},'%'))
- </if>
- <if test="subjectId != null">
- and st.subject_id_list_ = #{subjectId}
- </if>
- <if test="vipFlag != null">
- <if test="vipFlag">
- and st.member_rank_setting_id_ is not null
- </if>
- <if test="vipFlag == false">
- and st.member_rank_setting_id_ is null
- </if>
- </if>
- </select>
- <select id="queryBySchoolId" resultMap="ImGroup">
- SELECT ig.* FROM im_group ig where school_id_ = #{schoolId} limit 1
- </select>
- <select id="getByIds" resultMap="ImGroup">
- select ig.* FROM im_group ig where ig.id_ in
- <foreach collection="musicGroupIds" separator="," item="item" open="(" close=")">
- #{item}
- </foreach>
- </select>
- <update id="addMemberNum">
- update im_group set member_num_ = member_num_ + #{num} where id_ in
- <foreach collection="imGroupIds" close=")" item="item" open="(" separator=",">
- #{item}
- </foreach>
- </update>
- <update id="updateMember">
- update im_group set member_num_ = #{num} where id_ = #{imGroupId}
- </update>
- <select id="getByUserId" resultMap="ImGroup">
- SELECT distinct ig.* FROM im_group_member igm
- LEFT JOIN im_group ig ON igm.im_group_id_ = ig.id_
- left join class_group cg on ig.id_ = cg.id_
- where 1 =1
- <if test="param.userId != null">
- AND igm.user_id_ = #{param.userId}
- </if>
- <if test="param.keyword != null and param.keyword != ''">
- AND (ig.name_ like concat('%',#{param.keyword},'%') or ig.tags_ like concat('%',#{param.keyword},'%'))
- </if>
- <if test="param.musicGroupId != null and param.musicGroupId != ''">
- and cg.music_group_id_ = #{param.musicGroupId}
- </if>
- <if test="param.groupType != null">
- and ig.group_type_ = #{param.groupType}
- </if>
- </select>
- <select id="queryInfoCount" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM im_history_message
- </select>
- <select id="selectAll" resultType="com.ym.mec.biz.dal.entity.ImHistoryMessage">
- select msgUID_ AS msgUID,
- fromUserId_ AS fromUserId,
- targetId_ AS targetId,
- targetType_ AS targetType,
- GroupId_ AS groupId,
- busChannel_ AS busChannel,
- classname_ AS classname,
- content_ AS content,
- extraContent_ AS extraContent,
- dateTime_ AS dateTime,
- source_ AS source,
- isDiscard_ AS isDiscard,
- isSensitiveWord_ AS isSensitiveWord,
- isForbidden_ AS isForbidden,
- isNotForward_ AS isNotForward,
- groupUserIds_ AS groupUserIds,
- appId_ AS appId
- from im_history_message
- limit #{result},#{size}
- </select>
- <update id="updateSchoolRoleType">
- update im_group_member set role_type_ = #{userType.msg} ,type_ = #{userType.name} where user_id_ = #{userId}
- </update>
- <update id="updateImportStatusSuccess">
- update im_group set import_flag_ = 1
- where id_ = #{id}
- </update>
- <update id="updateStatus">
- update im_history_message set status_ = 1
- where msgUID in <foreach collection="info" open="(" close=")" separator="," item="info">
- #{info.msgUID}
- </foreach>
- </update>
- </mapper>
|