Newer
Older
huludao / src / main / resources / mapper / Data_Role_JurisdictionDao.xml
<?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.newfiber.api.pc.dao.Data_Role_JurisdictionDao" >

     
	<select  id="getRoleJur"  parameterType="string" resultType="com.newfiber.api.pc.model.entity.Data_Role_Jurisdiction">
	
	
	select  jurisdiction_no,`type`  from   sys_role_jurisdiction
	
	where role_no=#{roleNo,jdbcType=VARCHAR}
	
	</select>

 
	<select  id="getRoleOrgUserInfo" parameterType="string" resultType="com.newfiber.api.pc.model.entity.Data_User_Org">
	
	
	select  sys_user_org.user_no   from   sys_user_org  LEFT JOIN   sys_role_org
	 
	 ON  sys_user_org.org_no=sys_role_org.org_no
	 
	 where  sys_role_org.role_no=#{roleNo,jdbcType=VARCHAR}
	
	</select>



 <sql id = "Role_Jurisdiction_sql">
			FROM  sys_role_jurisdiction  LEFT JOIN  sys_jurisdiction  ON  sys_role_jurisdiction.jurisdiction_no
			=sys_jurisdiction.jurisdiction_no
			<where>
			     1=1
				<if test="fuzzyQuery!=null">
					AND (sys_jurisdiction.jurisdiction_name like '%${fuzzyQuery}%' )
				</if>
			    <if test="roleNo!=null">
			        AND ( sys_role_jurisdiction.role_no like '%${roleNo}%' )
			    </if>
			</where>
		</sql>
   
   
   	<sql id="op">
	
	<choose>
        <when test="sort!=null and sort != ''">
          
           ${sort}
        </when>
        <otherwise>
           serial
        </otherwise>
    </choose>
	
	</sql>
	<sql id="oc">
	  <choose>
        <when test="order !=null and order  != ''">
           ${order}
        </when>
        <otherwise>
           DESC
        </otherwise>
    </choose>
	
	</sql>
   
    <select id="GetRoleJurisdicton" parameterType="com.newfiber.api.pc.model.entity.Data_Role_Jurisdiction" resultType="int">
		SELECT COUNT(DISTINCT  sys_role_jurisdiction.serial) total
		<include refid="Role_Jurisdiction_sql"></include>
	</select>
	            
	<select id="selectRoleJurisdList" parameterType="com.newfiber.api.pc.model.entity.Data_Role_Jurisdiction" resultType="com.newfiber.api.pc.model.entity.Data_Role_Jurisdiction">
		
		select
	     sys_role_jurisdiction.serial,sys_jurisdiction.jurisdiction_no,sys_jurisdiction.jurisdiction_name,  sys_role_jurisdiction.create_time, sys_role_jurisdiction.type
	<include refid="Role_Jurisdiction_sql"></include>
	    order by 
        <include refid="op"></include> 
	    <include refid="oc"></include>  
	    limit
	    #{pageNo},
	    #{pageSize}
	</select>
	
	
	
	
	
	
	
	<sql id = "Role_Jurisdiction_sqlOne">
			FROM sys_jurisdiction
			<where>
			     1=1
				
			    <if test="roleNo!=null">
			      AND sys_jurisdiction.jurisdiction_no not in (SELECT  sys_role_jurisdiction.jurisdiction_no from  sys_role_jurisdiction where  sys_role_jurisdiction.role_no like '%${roleNo}%')
				
			    </if>
			</where>
		</sql>
   
   
    <select id="GetRoleJurisdictonBy" parameterType="com.newfiber.api.pc.model.entity.SysJurisdiction" resultType="int">
		SELECT COUNT(DISTINCT sys_jurisdiction.serial) total
		<include refid="Role_Jurisdiction_sqlOne"></include>
	</select>
	            
	<select id="selectRoleJurisdListBy" parameterType="com.newfiber.api.pc.model.entity.SysJurisdiction" resultType="com.newfiber.api.pc.model.entity.SysJurisdiction">
		
		select
	    sys_jurisdiction.serial,sys_jurisdiction.jurisdiction_no,sys_jurisdiction.jurisdiction_name, sys_jurisdiction.create_time
	<include refid="Role_Jurisdiction_sqlOne"></include>
	    order by 
        <include refid="op"></include> 
	    <include refid="oc"></include>  
	    limit
	    #{pageNo},
	    #{pageSize}
	</select>


  <insert id="insertJurisdiction" parameterType="com.newfiber.api.pc.model.entity.Data_Role_Jurisdiction" >
    insert into  sys_role_jurisdiction
        (role_no,
        jurisdiction_no,
        type) values

        <foreach collection="list" item="item" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides="," >

                <if test="item.roleNo != null" >
                    #{item.roleNo,jdbcType=VARCHAR},
                </if>

                <if test="item.jurisdictionNo != null" >
                    #{item.jurisdictionNo,jdbcType=VARCHAR},
                </if>

                <if test="item.type!=null" >
                    #{item.type,jdbcType=VARCHAR}
                </if>
            </trim>
        </foreach>

  </insert>

<delete id="deleteJurisdiction" parameterType="list" >
    delete from  sys_role_jurisdiction  where `type` in
    <foreach collection="list" item="item" close=")" separator="," open="(">
        #{item}
    </foreach>
  </delete>

    <resultMap id="jurMap" type="com.newfiber.api.pc.model.vo.JurVo">
        <result column="jurisdiction_no" property="jurisdictionNo"/>
        <result column="jurisdiction_name" property="jurisdictionName"/>
        <result column="jurisdiction_type" property="jurisdictionType"/>
        <result column="jurisdiction_type_zn" property="jurisdictionTypeZn"/>
        <result column="jurisdiction_state" property="jurisdictionState"/>
        <result column="jurisdiction_state_zn" property="jurisdictionStateZn"/>
        <result property="roleNo" column="role_no"/>
    </resultMap>


    <select id="selectJurByRoleNos" resultMap="jurMap">
        select
          DISTINCT sj.jurisdiction_no,sj.jurisdiction_name,sj.jurisdiction_type,sj.jurisdiction_type_zn,sj.jurisdiction_state,sj.jurisdiction_state_zn
        FROM
        sys_role_jurisdiction srj
        LEFT JOIN
        sys_jurisdiction sj
        ON srj.jurisdiction_no = sj.jurisdiction_no
        where srj.role_no in (${roles})
    </select>

  
</mapper>