<?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_OrgDao" > <sql id = "RoleOrg_sql"> FROM sys_organization left join sys_role_org on sys_organization.org_no=sys_role_org.org_no <where> <if test="roleNo!=null"> AND sys_role_org.org_no like '%${roleNo}%' </if> </where> </sql> <select id="OrgRoleCount" parameterType="com.newfiber.api.pc.model.entity.SysOrganization" resultType="int"> SELECT COUNT(DISTINCT sys_organization.serial) total <include refid="RoleOrg_sql"></include> </select> <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="OrgRoleList" parameterType="com.newfiber.api.pc.model.entity.SysOrganization" resultType="com.newfiber.api.pc.model.entity.SysOrganization"> select sys_organization.serial,sys_role_org.role_no, sys_organization.org_name, sys_organization.create_time, sys_organization.org_no <include refid="RoleOrg_sql"></include> order by <include refid="op"></include> <include refid="oc"></include> limit #{pageNo}, #{pageSize} </select> <sql id = "RoleOrg_sqlOne"> FROM sys_organization <where> 1=1 <if test="Role_No!=null"> AND sys_organization.org_no not in (SELECT sys_role_org.org_no from sys_role_org where sys_role_org.role_no like '%${roleNo}%') </if> </where> </sql> <select id="OrgRoleNotCount" parameterType="com.newfiber.api.pc.model.entity.SysOrganization" resultType="int"> SELECT COUNT(DISTINCT sys_organization.serial) total <include refid="RoleOrg_sqlOne"></include> </select> <select id="OrgRoleNotList" parameterType="com.newfiber.api.pc.model.entity.SysOrganization" resultType="com.newfiber.api.pc.model.entity.SysOrganization"> SELECT DISTINCT sys_organization.serial, sys_organization.org_name, sys_organization.create_time, sys_organization.org_no <include refid="RoleOrg_sqlOne"></include> Order BY <include refid="op"></include> <include refid="oc"></include> limit #{pageNo}, #{pageSize} </select> <insert id="insertRole" parameterType="list" > insert into sys_role_org (role_no,org_no) values <foreach collection="list" item="item" separator=","> <trim prefix="(" suffix=")" suffixOverrides="," > <if test="item.roleNo != null" > #{item.roleNo,jdbcType=VARCHAR}, </if> <if test="item.orgNo != null" > #{item.orgNo,jdbcType=VARCHAR}, </if> </trim> </foreach> </insert> <delete id="deleteRole" parameterType="list" > delete from sys_role_org where org_no in <foreach collection="list" item="item" separator="," open="(" close=")"> #{item.orgNo,jdbcType=VARCHAR} </foreach> and role_no in <foreach collection="list" item="item" separator="," open="(" close=")"> #{item.roleNo,jdbcType=VARCHAR} </foreach> </delete> <select id="selectRoleByOrgNo" parameterType="string" resultType="com.newfiber.api.pc.model.entity.Sys_Roles"> SELECT o.role_no roleNo,r.role_name roleName FROM sys_role_org O LEFT JOIN sys_roles R ON r.role_no=o.role_no <if test="orgNo != null and orgNo !=''"> WHERE O.org_no=#{orgNo} </if> </select> <resultMap id="roleMap" type="com.newfiber.api.pc.model.vo.RoleVo"> <result property="roleNo" column="role_no"/> <result property="roleName" column="role_name"/> <result property="roleState" column="role_state"/> <result property="roleStateZn" column="role_state_zn"/> <result property="roleType" column="role_type"/> <result property="roleTypeZn" column="role_type_zn"/> </resultMap> <select id="selectRoleNoByOrgNos" resultMap="roleMap"> select DISTINCT sr.role_no,sr.role_name,sr.role_state,sr.role_state_zn,sr.role_type,sr.role_type_zn FROM sys_role_org sro LEFT JOIN sys_roles sr ON sro.role_no = sr.role_no where sro.org_no in (${orgs}) </select> <select id="queryRoleByOrg" resultType="com.newfiber.api.pc.model.entity.Data_Role_Org"> select so.* from sys_organization so LEFT JOIN sys_role_org sro on so.org_no = sro.org_no where sro.role_no = #{roleNo} </select> </mapper>