123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?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.zhyc.xps.sys.mapper.GroupMemberMapper">
- <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.GroupMember">
- <result column="gm_id" property="gmId" jdbcType="BIGINT" /><!--群组成员ID-->
- <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--公司机构ID-->
- <result column="group_id" property="groupId" jdbcType="BIGINT" /><!--群组ID-->
- <result column="account_id" property="accountId" jdbcType="BIGINT" /><!--帐号ID-->
- <result column="is_fixed" property="isFixed" jdbcType="BIGINT" /><!--帐号ID-->
- </resultMap>
- <resultMap id="GroupMemberDtoResultMap" type="com.zhyc.xps.sys.dto.GroupMemberDto" extends="BaseResultMap">
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
- <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
- <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
- </resultMap>
- <resultMap id="GroupMemberDetailsDtoResultMap" type="com.zhyc.xps.sys.dto.GroupMemberDetailsDto" extends="GroupMemberDtoResultMap">
- <result column="account_id" property="accountId" jdbcType="BIGINT" />
- <result column="account_name" property="accountName" jdbcType="VARCHAR" />
- <result column="password" property="password" jdbcType="VARCHAR" />
- <result column="account_type" property="accountType" jdbcType="BIGINT" />
- <result column="account_staff_no" property="accountStaffNo" jdbcType="VARCHAR" />
- <result column="account_phone" property="accountPhone" jdbcType="VARCHAR" />
- <result column="account_last_ip" property="accountLastIp" jdbcType="VARCHAR" />
- <result column="account_loc" property="accountLoc" jdbcType="VARCHAR" />
- <result column="status" property="status" jdbcType="BIGINT" />
- <result column="account_avatar" property="accountAvatar" jdbcType="VARCHAR" />
- <result column="account_real_name" property="accountRealName" jdbcType="VARCHAR" />
- <result column="account_intro" property="accountIntro" jdbcType="VARCHAR" />
- <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
- <result column="gmp_id" property="gmpId" jdbcType="BIGINT" />
- <result column="position_id" property="positionId" jdbcType="BIGINT" />
- <result column="position_name" property="positionName" jdbcType="VARCHAR" />
- <result column="gmpg_id" property="gmpgId" jdbcType="BIGINT" />
- <result column="grant_group_id" property="grantGroupId" jdbcType="BIGINT" />
- <result column="grant_group_name" property="grantGroupName" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="GroupMemberDto_Cols">
- A.gm_id,
- A.oc_id,
- A.group_id,
- B.group_name,
- B.node_left ,
- B.node_right,
- A.account_id
- </sql>
- <!--根据账户id获取第一群组-->
- <select id="getById" resultMap="GroupMemberDetailsDtoResultMap">
- SELECT A.gm_id,
- A.oc_id,
- A.group_id,
- A.account_id,
- B.account_name,
- B.account_real_name,
- B.account_staff_no,
- B.account_phone,
- B.account_type,
- B.account_avatar,
- B.account_photo,
- B.account_loc,
- B.status,
- B.is_fixed,
- C.group_name,
- C.node_left,
- C.node_right,
- E.gmp_id,
- E.position_id,
- H.position_name,
- F.gmpg_id,
- F.grant_group_id,
- G.group_name AS grant_group_name
- FROM s_group_member AS A
- LEFT JOIN account AS B ON ( A.oc_id = B.oc_id AND A.account_id = B.account_id )
- LEFT JOIN s_group AS C ON ( A.oc_id = C.oc_id AND A.group_id = C.group_id )
- LEFT JOIN s_group_member_position AS E ON ( A.oc_id = E.oc_id AND A.account_id = E.account_id AND E.group_id= #{groupId ,jdbcType=BIGINT} )
- LEFT JOIN s_group_member_position_grant AS F ON ( E.oc_id = F.oc_id AND E.account_id = F.account_id AND E.position_id = F.position_id AND F.group_id = #{groupId ,jdbcType=BIGINT} )
- LEFT JOIN s_group AS G ON ( G.oc_id = F.oc_id AND G.group_id = F.grant_group_id )
- LEFT JOIN s_position AS H ON ( A.oc_id = E.oc_id AND H.position_id = E.position_id )
- WHERE B.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId ,jdbcType=BIGINT}
- </if>
- LIMIT 1
- </select>
- <!--根据账户id获取第一群组-->
- <select id="getFirstGroupByAccountId" resultMap="GroupMemberDtoResultMap">
- SELECT
- <include refid="GroupMemberDto_Cols"/>
- FROM s_group_member AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- WHERE B.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId ,jdbcType=BIGINT}
- </if>
- LIMIT 1
- </select>
- <!--根据左右树结点,获取群组所有下级成员,包括所有子群组成员-->
- <select id="getByList" parameterType="java.util.Map" resultMap="GroupMemberDetailsDtoResultMap">
- SELECT
- DISTINCT(A.account_id),
- A.gm_id,
- A.oc_id,
- A.group_id,
- B.account_name,
- B.account_real_name,
- B.account_staff_no,
- B.account_phone,
- B.account_avatar,
- B.status,
- B.is_fixed,
- C.group_name,
- C.node_left,
- C.node_right,
- D.gmp_id,
- D.position_id,
- D.position_name,
- E.gmpg_id,
- E.grant_group_id,
- F.group_name as grant_group_name
- FROM s_group_member AS A
- LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.account_id = B.account_id)
- LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.group_id = C.group_id)
- LEFT JOIN s_group_member_position_grant AS E ON (B.oc_id = E.oc_id AND B.account_id = E.account_id)
- LEFT JOIN s_group AS F ON (E.oc_id = F.oc_id AND E.grant_group_id = F.group_id)
- LEFT JOIN (
- SELECT
- M.oc_id,
- M.account_id,
- M.gmp_id,
- M.group_id,
- M.position_id,
- P.position_name,
- N.gmpg_id,
- N.grant_group_id,
- GP.group_name as grant_group_name
- FROM s_group_member_position AS M
- LEFT JOIN s_group_member_position_grant AS N ON (
- M.oc_id = N.oc_id
- AND M.account_id = N.account_id
- AND M.group_id = N.group_id
- AND M.position_id = N.position_id )
- LEFT JOIN s_position AS P ON(M.oc_id = P.oc_id AND M.position_id = P.position_id)
- LEFT JOIN s_group AS GP ON(M.oc_id = GP.oc_id AND N.grant_group_id = GP.group_id)
- ) AS D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id AND A.group_id = D.group_id)
- WHERE B.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND C.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND C.node_right <= #{nodeRight,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="keywords != null and keywords != ''">
- AND (
- B.account_real_name LIKE "%"#{keywords}"%"
- OR B.account_name LIKE "%"#{keywords}"%"
- OR B.account_phone LIKE "%"#{keywords}"%"
- OR B.account_staff_no LIKE "%"#{keywords}"%"
- OR D.position_name LIKE "%"#{keywords}"%"
- )
- </if>
- ORDER BY A.account_id ,A.group_id
- </select>
- <!--根据左右树结点,获取群组所有下级成员,包括所有子群组成员-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="GroupMemberDetailsDtoResultMap">
- SELECT
- DISTINCT(A.account_id),
- A.gm_id,
- A.oc_id,
- A.group_id,
- B.account_name,
- B.account_real_name,
- B.account_phone,
- B.account_staff_no,
- B.account_avatar,
- B.status,
- B.is_fixed,
- C.group_name,
- C.node_left,
- C.node_right,
- D.gmp_id,
- D.position_id,
- D.position_name,
- E.gmpg_id,
- E.grant_group_id,
- F.group_name as grant_group_name
- FROM
- s_group_member AS A
- LEFT JOIN account AS B ON (A.oc_id = B.oc_id AND A.account_id = B.account_id)
- LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.group_id = C.group_id )
- LEFT JOIN s_group_member_position_grant AS E ON (B.oc_id = E.oc_id AND B.account_id = E.account_id)
- LEFT JOIN s_group AS F ON (E.oc_id = F.oc_id AND E.grant_group_id = F.group_id )
- LEFT JOIN (
- SELECT
- M.oc_id,
- M.account_id,
- M.gmp_id,
- M.group_id,
- M.position_id,
- P.position_name,
- N.gmpg_id,
- N.grant_group_id,
- GP.group_name as grant_group_name
- FROM
- s_group_member_position AS M
- LEFT JOIN s_group_member_position_grant AS N ON (
- M.oc_id = N.oc_id
- AND M.account_id = N.account_id
- AND M.group_id = N.group_id
- AND M.position_id = N.position_id )
- LEFT JOIN s_position AS P ON(M.oc_id = P.oc_id AND M.position_id = P.position_id)
- LEFT JOIN s_group AS GP ON(M.oc_id = GP.oc_id AND N.grant_group_id = GP.group_id )
- ) AS D ON (A.oc_id= D.oc_id AND A.account_id = D.account_id AND A.group_id = D.group_id)
- WHERE B.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND C.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND C.node_right <= #{nodeRight,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="keywords != null and keywords != ''">
- AND (
- B.account_real_name LIKE "%"#{keywords}"%"
- OR B.account_name LIKE "%"#{keywords}"%"
- OR B.account_phone LIKE "%"#{keywords}"%"
- OR B.account_staff_no LIKE "%"#{keywords}"%"
- OR D.position_name LIKE "%"#{keywords}"%"
- )
- </if>
- ORDER BY A.account_id, A.group_id
- </select>
- <!--新增INSERT-->
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.GroupMember">
- INSERT INTO s_group_member
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="gmId != null">
- gm_id,
- </if>
- <if test="groupId != null">
- group_id,
- </if>
- <if test="accountId != null">
- account_id,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId ,jdbcType=BIGINT},
- </if>
- <if test="gmId != null">
- #{gmId ,jdbcType=BIGINT},
- </if>
- <if test="groupId != null">
- #{groupId,jdbcType=BIGINT},
- </if>
- <if test="accountId != null">
- #{accountId,jdbcType=BIGINT},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--update更新GroupMember-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.GroupMember">
- UPDATE s_group_member
- <trim suffixOverrides=",">
- <set>
- <if test="groupId != null">
- group_id = #{groupId,jdbcType=BIGINT},
- </if>
- <if test="accountId != null">
- account_id = #{accountId,jdbcType=BIGINT},
- </if>
- <if test="updatedBy != null">
- updated_by = #{updatedBy,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE gm_id = #{gmId,jdbcType=BIGINT}
- AND oc_id = #{ocId,jdbcType=BIGINT}
- </update>
- <!--删除-->
- <update id="delete" parameterType="java.util.Map">
- UPDATE s_group_member
- <trim suffixOverrides=",">
- <set>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag,jdbcType=BIGINT},
- </if>
- <if test="deletedAt != null">
- deleted_at = #{deletedAt ,jdbcType=DATE},
- </if>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE 1 = 1
- <if test="gmId != null">
- AND gm_id = #{gmId ,jdbcType=BIGINT}
- </if>
- <if test="ocId != null">
- AND oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="groupId != null">
- AND group_id = #{groupId ,jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND account_id = #{accountId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--获取群组成员数目-->
- <select id="getMembersCountOfGroup" parameterType="java.util.Map" resultType="java.lang.Long">
- SELECT
- count(*)
- FROM
- s_group_member AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight,jdbcType=BIGINT}
- ]]>
- </if>
- </select>
- </mapper>
|