123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <?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.GroupMapper">
- <resultMap id="GetResultMap" type="com.zhyc.xps.sys.dto.GroupDto" >
- <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
- <result column="group_id" property="groupId" jdbcType="BIGINT" /><!--群组ID-->
- <result column="group_name" property="groupName" jdbcType="VARCHAR" /><!--群组Name-->
- <result column="group_code" property="groupCode" jdbcType="VARCHAR" /><!--群组Code-->
- <result column="group_cat_id" property="groupCatId" jdbcType="BIGINT" /><!--群组类别ID-->
- <result column="parent_id" property="parentId" jdbcType="BIGINT" /><!--父群组-->
- <result column="root_id" property="rootId" jdbcType="BIGINT" /><!--根群组ID-->
- <result column="node_left" property="nodeLeft" jdbcType="BIGINT" /><!--Node Left-->
- <result column="node_right" property="nodeRight" jdbcType="BIGINT" /><!--Node Right-->
- <result column="node_level" property="nodeLevel" jdbcType="BIGINT" /><!--Node Leve-->
- <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" /><!--Leaf-->
- <result column="is_fixed" property="isFixed" jdbcType="BIGINT" /><!--是否可删除-->
- <result column="group_desc" property="groupDesc" jdbcType="VARCHAR" /><!--描述-->
- <result column="group_select" property="groupSelect" jdbcType="VARCHAR" /><!--供首字母等检索用-->
- <result column="parent_name" property="parentName" jdbcType="VARCHAR" />
- <result column="group_cat_title" property="groupCatTitle" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="GroupDto_Cols">
- A.oc_id,
- A.group_id,
- A.group_name,
- A.group_code,
- A.group_cat_id,
- C.group_cat_title,
- A.node_left,
- A.node_right,
- A.parent_id,
- A.root_id,
- B.group_name as parent_name,
- A.node_level,
- A.is_leaf,
- A.is_fixed,
- A.group_desc
- </sql>
- <!--根据ID获取群组信息-->
- <select id="getById" resultMap="GetResultMap">
- SELECT
- <include refid="GroupDto_Cols"/>
- FROM s_group AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.parent_id = B.group_id )
- LEFT JOIN s_group_cat AS C ON (A.oc_id = C.oc_id AND A.group_cat_id = C.group_cat_id)
- WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND A.deleted_flag = 0 AND A.group_id = #{groupId ,jdbcType=BIGINT}
- </select>
- <!--根据条件返回相应的群组列表-->
- <select id="getByList" parameterType="java.util.Map" resultMap="GetResultMap">
- SELECT
- <include refid="GroupDto_Cols"/>
- FROM s_group AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.parent_id = B.group_id)
- LEFT JOIN s_group_cat AS C ON (A.oc_id = C.oc_id AND A.group_cat_id = C.group_cat_id)
- WHERE A.oc_id = #{ocId,jdbcType=BIGINT} AND A.deleted_flag = 0
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND A.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND A.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="groupCatId!=null">
- AND A.group_cat_id = #{groupCatId ,jdbcType=BIGINT}
- </if>
- <if test="groupId !=null">
- AND A.group_id = #{groupId,jdbcType=BIGINT}
- </if>
- <if test="parentId != null">
- AND A.parent_id = #{parentId, jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND ( A.group_name LIKE "%"#{keywords}"%"
- </if>
- </select>
- <!--获取某个群组的所有下级群组列表-->
- <select id="getGroupChildren" parameterType="java.util.Map" resultMap="GetResultMap">
- SELECT
- <include refid="GroupDto_Cols"/>
- FROM s_group AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.parent_id = B.group_id )
- LEFT JOIN s_group_cat AS C ON (A.oc_id = C.oc_id AND A.group_cat_id = C.group_cat_id)
- WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND A.deleted_flag = 0
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND A.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND A.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="groupCatId!=null">
- AND A.group_cat_id = #{groupCatId ,jdbcType=BIGINT}
- </if>
- <if test="groupIds !=null and groupIds.length > 0">
- AND A.group_id in
- <foreach collection="groupIds" item="groupId" open="(" separator="," close=")">
- #{groupId}
- </foreach>
- </if>
- <if test="groupId !=null">
- AND A.group_id = #{groupId,jdbcType=BIGINT}
- </if>
- <if test="parentId != null">
- AND A.parent_id = #{parentId, jdbcType=BIGINT}
- </if>
- ORDER BY A.group_id
- </select>
- <!--根据名称获取群组信息-->
- <select id="getGroupByName" parameterType="java.util.Map" resultMap="GetResultMap">
- SELECT
- <include refid="GroupDto_Cols"/>
- FROM s_group AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.parent_id = B.group_id )
- LEFT JOIN s_group_cat AS C ON (A.oc_id = C.oc_id AND A.group_cat_id = C.group_cat_id)
- WHERE A.oc_id = #{ocId,jdbcType=BIGINT} AND A.deleted_flag = 0
- <if test="groupName != null and groupName != ''">
- AND A.group_name = #{groupName,jdbcType=VARCHAR}
- </if>
- </select>
- <!--insert新增-->
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.Group" useGeneratedKeys="true" keyProperty="groupId">
- INSERT INTO s_group
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="groupId != null">
- group_id,
- </if>
- <if test="groupName != null and groupName != ''">
- group_name,
- </if>
- <if test="groupCode != null and groupCode != ''">
- group_code,
- </if>
- <if test="groupCatId != null">
- group_cat_id,
- </if>
- <if test="nodeLeft != null">
- node_left,
- </if>
- <if test="nodeRight != null">
- node_right,
- </if>
- <if test="parentId != null">
- parent_id,
- </if>
- <if test="rootId != null">
- root_id,
- </if>
- <if test="nodeLevel != null">
- node_level,
- </if>
- <if test="isLeaf != null">
- is_leaf,
- </if>
- <if test="isFixed != null">
- is_fixed,
- </if>
- <if test="groupDesc != null and groupDesc != ''">
- group_desc,
- </if>
- <if test="groupSelect != null and groupSelect != ''">
- group_select,
- </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="groupId != null">
- #{groupId,jdbcType=BIGINT},
- </if>
- <if test="groupName != null and groupName != ''">
- #{groupName,jdbcType=VARCHAR},
- </if>
- <if test="groupCode != null and groupCode != ''">
- #{groupCode,jdbcType=VARCHAR},
- </if>
- <if test="groupCatId != null">
- #{groupCatId,jdbcType=BIGINT},
- </if>
- <if test="nodeLeft != null">
- #{nodeLeft,jdbcType=BIGINT},
- </if>
- <if test="nodeRight != null">
- #{nodeRight,jdbcType=BIGINT},
- </if>
- <if test="parentId != null">
- #{parentId,jdbcType=BIGINT},
- </if>
- <if test="rootId != null">
- #{rootId,jdbcType=BIGINT},
- </if>
- <if test="nodeLevel != null">
- #{nodeLevel,jdbcType=BIGINT},
- </if>
- <if test="isLeaf != null">
- #{isLeaf,jdbcType=BIGINT},
- </if>
- <if test="isFixed != null">
- #{isFixed,jdbcType=BIGINT},
- </if>
- <if test="groupDesc != null and groupDesc != ''">
- #{groupDesc,jdbcType=VARCHAR},
- </if>
- <if test="groupSelect != null and groupSelect != ''">
- #{groupSelect,jdbcType=VARCHAR},
- </if>
- <if test="createdBy != null">
- #{createdBy,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--更新群组-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.Group">
- UPDATE s_group
- <trim suffixOverrides=",">
- <set>
- <if test="groupName != null and groupName != ''">
- group_name = #{groupName,jdbcType=VARCHAR},
- </if>
- <if test="groupCode != null and groupCode != ''">
- group_code = #{groupCode,jdbcType=VARCHAR},
- </if>
- <if test="groupCatId != null">
- group_cat_id = #{groupCatId,jdbcType=BIGINT},
- </if>
- <if test="nodeLeft != null">
- node_left = #{nodeLeft,jdbcType=BIGINT},
- </if>
- <if test="nodeRight != null">
- node_right = #{nodeRight,jdbcType=BIGINT},
- </if>
- <if test="parentId != null">
- parent_id = #{parentId,jdbcType=BIGINT},
- </if>
- <if test="nodeLevel != null">
- node_level = #{nodeLevel,jdbcType=BIGINT},
- </if>
- <if test="groupDesc != null and groupDesc != ''">
- group_desc = #{groupDesc,jdbcType=VARCHAR},
- </if>
- <if test="isLeaf != null">
- is_leaf = #{isLeaf,jdbcType=BIGINT},
- </if>
- <if test="ocId != null">
- oc_id = #{ocId,jdbcType=BIGINT},
- </if>
- <if test="groupSelect != null and groupSelect != ''">
- group_select =#{groupSelect,jdbcType=VARCHAR},
- </if>
- <if test="updatedBy != null">
- updated_by = #{updatedBy,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE oc_id = #{ocId,jdbcType=BIGINT} AND group_id = #{groupId ,jdbcType=BIGINT}
- </update>
- <!--删除角色 -->
- <update id="delete" parameterType="java.util.Map">
- UPDATE s_group
- <trim suffixOverrides=",">
- <set>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy ,jdbcType=BIGINT},
- </if>
- <if test="deletedAt != null">
- deleted_at = #{deletedAt ,jdbcType=DATE},
- </if>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE deleted_flag = 0 AND oc_id = #{ocId,jdbcType=BIGINT}
- <if test="groupId != null ">
- AND group_id = #{groupId ,jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null">
- <![CDATA[
- AND node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- </update>
- </mapper>
|