123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?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.GroupMemberPositionMapper">
- <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.GroupMemberPosition">
- <result column="gmp_id" property="gmpId" 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="position_id" property="positionId" jdbcType="BIGINT" /> <!--岗位ID-->
- </resultMap>
- <resultMap id="GroupMemberPositionDtoResultMap" type="com.zhyc.xps.sys.dto.GroupMemberPositionDto" extends="BaseResultMap">
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="account_name" property="accountName" jdbcType="VARCHAR" />
- <result column="account_real_name" property="accountRealName" jdbcType="VARCHAR" />
- <result column="position_name" property="positionName" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="GroupMemberPositionDto_Column_List">
- A.gmp_id,
- A.oc_id,
- A.group_id,
- B.group_name,
- A.account_id,
- D.account_name,
- D.account_real_name,
- A.position_id,
- C.position_name
- </sql>
- <!--基于ID查询-->
- <select id="getById" resultMap="GroupMemberPositionDtoResultMap">
- SELECT
- <include refid="GroupMemberPositionDto_Column_List" />
- FROM
- s_group_member_position A
- LEFT JOIN s_group B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN account D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="gmpId != null">
- AND A.gmp_id = #{gmpId, jdbcType=BIGINT}
- </if>
- </select>
- <!--根据ID获取第1个岗位-->
- <select id="getFirstPositionByGroupIdAndAccountId" resultMap="GroupMemberPositionDtoResultMap">
- SELECT
- <include refid="GroupMemberPositionDto_Column_List" />
- FROM s_group_member_position A
- LEFT JOIN s_group B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN account D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="groupId != null">
- AND A.group_id = #{groupId, jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId, jdbcType=BIGINT}
- </if>
- LIMIT 1
- </select>
- <!--根据条件获取List getGroupMemberPositionList-->
- <select id="getByList" parameterType="java.util.Map" resultMap="GroupMemberPositionDtoResultMap">
- SELECT
- <include refid="GroupMemberPositionDto_Column_List" />
- FROM s_group_member_position A
- LEFT JOIN s_group B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN account D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="groupId != null">
- AND A.group_id = #{groupId,jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId ,jdbcType=BIGINT}
- </if>
- <if test="positionId != null">
- and A.position_id = #{positionId ,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>
- <if test="position != null and position !=''">
- <foreach collection="position" item="item" open="and A.position_id in (" separator="," close=")">
- #{item}
- </foreach>
- </if>
- ORDER BY A.position_id ASC
- </select>
- <!--Insert新增-->
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.GroupMemberPosition">
- insert into s_group_member_position
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="gmpId != null">
- gmp_id,
- </if>
- <if test="groupId != null">
- group_id,
- </if>
- <if test="accountId != null">
- account_id,
- </if>
- <if test="positionId != null">
- position_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="gmpId != null">
- #{gmpId,jdbcType=BIGINT},
- </if>
- <if test="groupId != null">
- #{groupId,jdbcType=BIGINT},
- </if>
- <if test="accountId != null">
- #{accountId,jdbcType=BIGINT},
- </if>
- <if test="positionId != null">
- #{positionId,jdbcType=BIGINT},
- </if>
- <if test="createdBy != null">
- #{createdBy,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--Update更新-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.GroupMemberPosition">
- UPDATE s_group_member_position
- <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="positionId != null">
- position_id = #{positionId,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 gmp_id = #{gmpId ,jdbcType=BIGINT}
- AND oc_id = #{ocId ,jdbcType=BIGINT}
- </update>
- <!--删除-->
- <delete id="delete" parameterType="java.util.Map">
- DELETE FROM s_group_member_position
- WHERE 1 = 1
- <if test="ocId != null">
- and oc_id = #{ocId}
- </if>
- <if test="groupId!= null">
- AND group_id = #{groupId ,jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND account_id = #{accountId ,jdbcType=BIGINT}
- </if>
- <if test="positionId != null">
- AND position_id = #{positionId ,jdbcType=BIGINT}
- </if>
- <if test="gmpId!= null">
- AND gmp_id = #{gmpId ,jdbcType=BIGINT}
- </if>
- </delete>
- </mapper>
|