123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?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.PositionPermitMapper">
- <resultMap id="PermitDtoResultMap" type="com.zhyc.xps.sys.dto.PositionPermitDto" >
- <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
- <result column="position_id" property="positionId" jdbcType="BIGINT"/>
- <result column="permit_id" property="permitId" jdbcType="BIGINT"/>
- <result column="permit_code" property="permitCode" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Ext_Column_List">
- A.oc_id,
- A.position_id,
- A.permit_id,
- B.permit_code
- </sql>
- <!--基于ID查询-->
- <select id="getById" resultMap="PermitDtoResultMap" >
- SELECT
- <include refid="Ext_Column_List"/>
- FROM s_position_permit AS A
- LEFT JOIN s_role_permit AS B ON (A.permit_id = B.permit_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND A.oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="positionId != null">
- AND A.position_id = #{positionId,jdbcType=BIGINT}
- </if>
- <if test="permitId != null">
- AND A.permit_id = #{permitId ,jdbcType=BIGINT}
- </if>
- </select>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="PermitDtoResultMap">
- SELECT
- <include refid="Ext_Column_List"/>
- FROM s_position_permit AS A
- LEFT JOIN s_role_permit AS B ON (A.permit_id = B.permit_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND A.oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="positionId != null">
- AND A.position_id = #{positionId,jdbcType=BIGINT}
- </if>
- <if test="permitId != null">
- AND A.permit_id = #{permitId ,jdbcType=BIGINT}
- </if>
- <if test="clientId != null">
- AND B.client_id = #{clientId ,jdbcType=BIGINT}
- </if>
- </select>
- <!--新增-->
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.PositionPermit">
- INSERT INTO s_position_permit
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="positionId != null">
- position_id,
- </if>
- <if test="permitId != null">
- permit_id,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId ,jdbcType=BIGINT},
- </if>
- <if test="positionId != null">
- #{positionId ,jdbcType=BIGINT},
- </if>
- <if test="permitId != null">
- #{permitId ,jdbcType=BIGINT},
- </if>
- </trim>
- </insert>
- <!--删除-->
- <delete id="delete" parameterType="java.util.Map">
- DELETE
- FROM s_position_permit
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="permitId != null">
- AND permit_id = #{permitId, jdbcType=BIGINT}
- </if>
- <if test="positionId != null">
- AND position_id = #{positionId, jdbcType=BIGINT}
- </if>
- </delete>
- <resultMap id="PermitVoResultMap" type="com.zhyc.xps.sys.vo.PermitVo" >
- <result column="permit_id" property="permitId" jdbcType="BIGINT" />
- <result column="permit_title" property="permitTitle" jdbcType="VARCHAR"/>
- <result column="permit_code" property="permitCode" jdbcType="VARCHAR"/>
- <result column="permit_desc" property="permitDesc" jdbcType="VARCHAR"/>
- <result column="permit_type" property="permitType" jdbcType="BIGINT" />
- <result column="parent_id" property="parentId" jdbcType="BIGINT" />
- <result column="root_id" property="rootId" jdbcType="BIGINT" />
- <result column="position_permitted" property="positionPermitted" jdbcType="BIGINT" />
- <result column="account_permitted" property="accountPermitted" jdbcType="BIGINT" />
- </resultMap>
- <!--列表查询-->
- <select id="getViewByList" resultMap="PermitVoResultMap" >
- SELECT
- A.permit_id,
- A.permit_title,
- A.permit_code,
- A.permit_desc,
- A.permit_type,
- A.parent_id,
- A.root_id,
- IFNULL(CASE WHEN B.permit_id > 0 THEN 1 ELSE 0 END, 0) AS position_permitted
- FROM s_role_permit AS A
- LEFT JOIN s_position_permit AS B ON (A.permit_id = B.permit_id AND B.oc_id=#{ocId} AND B.position_id=#{positionId})
- WHERE 1 = 1
- <if test="clientId != null">
- AND A.client_id = #{clientId,jdbcType=BIGINT}
- </if>
- <if test="roleId != null">
- AND A.role_id = #{roleId,jdbcType=BIGINT}
- </if>
- ORDER BY A.parent_id ASC ,A.sort_no ASC
- </select>
- </mapper>
|