<?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="configTableModel"> <!--查询数据权限实体 --> <select id="query" parameterType="HashMap" resultType="java.util.LinkedHashMap"> <choose> <when test="m.isProc"> ${querySql} </when> <otherwise> <choose> <when test="querySql != '' and ((queryCdion != null and queryCdion != '') or (serverFilter != null and serverFilter != ''))"> select * from (${querySql})${tableAlias} <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> </when> <otherwise> ${querySql} </otherwise> </choose> <!-- <if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if> --> </otherwise> </choose> </select> <select id="queryTreeByPath" parameterType="HashMap" resultType="java.util.LinkedHashMap"> SELECT DISTINCT A.* FROM (select * from (${firstTreeQuerySql}) C) A INNER JOIN (SELECT ${fieldName} FROM ( select * from (${querySql})${tableAlias} <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> #[limit])TT) B ON <choose> <when test="matchType == 'matchDown'"> LEFT(A.${fieldName},LENGTH(B.${fieldName}))=B.${fieldName} </when> <when test="matchType == 'matchAll'"> LEFT(A.${fieldName},LENGTH(B.${fieldName}))=B.${fieldName} or LEFT(B.${fieldName},LENGTH(A.${fieldName}))=A.${fieldName} </when> <otherwise> LEFT(B.${fieldName},LENGTH(A.${fieldName}))=A.${fieldName} </otherwise> </choose> </select> <!--分组查询实体 --> <select id="queryGroup" parameterType="HashMap" resultType="java.util.LinkedHashMap"> select ${groupFields} <if test="statFields != null and statFields != ''"> ,${statFields} </if> from ( <choose> <when test="querySql != '' and ((queryCdion != null and queryCdion != '') or (serverFilter != null and serverFilter != ''))"> select * from (${querySql})${tableAlias} <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> </when> <otherwise> ${querySql} </otherwise> </choose> )T group by ${groupFields} <if test="havingCdion != null and havingCdion != ''"> having ${havingCdion} </if> </select> <!--查询分组策略数据权限实体 多分组 --> <select id="queryGroupPolicy" parameterType="HashMap" resultType="java.util.LinkedHashMap"> select ${groupFields},${analyseFields} from( select B.* FROM ( select * from( SELECT DISTINCT ${firstGroupField} FROM ( select * from(${querySql})TT )${tableAlias} <where> <if test="queryCdion != null and queryCdion != ''"> ${queryCdion} </if> <if test="serverFilter != null and serverFilter != ''"> and ${serverFilter} </if> </where> )T_QC #[limit] )T_DA LEFT JOIN (select * from(${querySql})TT <where> <if test="queryCdion != null and queryCdion != ''"> ${queryCdion} </if> </where> )B ON T_DA.${firstGroupField} = B.${firstGroupField} )DA_T group by ${groupFields} <if test="havingCdion != null and havingCdion != ''"> having ${havingCdion} </if> </select> <delete id="deleteByModel" parameterType="AbstractEntity"> delete from ${table} ${deleteCdion} </delete> <update id="addExistOverrideUpdate" parameterType="AbstractEntity"> UPDATE ${table} SET ${overrideUpdateSet} ${overrideCdion} </update> <select id="addExistOverrideSelect" parameterType="AbstractEntity" resultType="int"> select count(0) from ${table} ${overrideCdion} </select> <insert id="addExistOverrideInsert" parameterType="AbstractEntity"> INSERT INTO ${table} (${overrideFields}) SELECT * FROM (SELECT ${overrideValuesAs}) as T WHERE NOT EXISTS( SELECT 1 FROM ${table} ${overrideCdion} LIMIT 1) </insert> <insert id="add" parameterType="AbstractEntity"> INSERT INTO ${table} (${insertFields}) VALUES (${insertValues}) </insert> <update id="update" parameterType="AbstractEntity"> UPDATE ${table} SET ${updateSet} ${updateCdion}; </update> <insert id="addList" parameterType="java.util.List"> <foreach collection="list" item="item" index="index" separator=","> <if test="index == 0"> INSERT INTO ${item.table} (${item.insertFields}) VALUES </if> (${item.insertValues}) </foreach> </insert> <select id="customQuery" parameterType="HashMap" resultType="java.util.LinkedHashMap">${custom}</select> <insert id="customInsert" parameterType="HashMap" >${custom}</insert> <update id="customUpdate" parameterType="HashMap" >${custom}</update> <delete id="customDelete" parameterType="HashMap" >${custom}</delete> <select id="exeSql" parameterType="HashMap" resultType="java.util.LinkedHashMap"> <choose> <when test="querySql != '' and ((queryCdion != null and queryCdion != '') or (serverFilter != null and serverFilter != ''))"> select * from (${querySql})T <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> </when> <otherwise> ${querySql} </otherwise> </choose> </select> <select id="tableNames" parameterType="HashMap" resultType="java.util.LinkedHashMap"> SELECT A.TABLE_NAME NAME FROM INFORMATION_SCHEMA.TABLES A WHERE A.TABLE_SCHEMA = '${databaseName}' </select> <select id="count" parameterType="HashMap" resultType="java.util.LinkedHashMap"> select count(1) from ( select * from( <choose> <when test="querySql != '' and ((queryCdion != null and queryCdion != '') or (serverFilter != null and serverFilter != ''))"> select * from (${querySql})${tableAlias} <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> </when> <otherwise> ${querySql} </otherwise> </choose> )DA <if test="dataAccess != null and dataAccess != ''"> where ${dataAccess} </if> ) tmp_count </select> <select id="existTempTable" parameterType="AbstractEntity" resultType="int"> select count(*) from information_schema.TABLES where table_name = #{tempTableName} </select> <update id="emptyTempTable" parameterType="AbstractEntity"> truncate table ${tempTableName} </update> <update id="dropTempTable" parameterType="AbstractEntity"> drop table ${tempTableName} </update> <update id="createTempTable" parameterType="AbstractEntity"> create temporary table ${tempTableName} as select * from( select * from( <choose> <when test="querySql != '' and ((queryCdion != null and queryCdion != '') or (serverFilter != null and serverFilter != ''))"> select * from (${querySql})${tableAlias} <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> </when> <otherwise> ${querySql} </otherwise> </choose> <if test="limit != null and limit != ''"> limit ${limit} offset ${offset} </if> )T ) origintable </update> <insert id="insertTempTable" parameterType="AbstractEntity" > insert into ${tempTableName} select * from ( select * from( <choose> <when test="querySql != '' and ((queryCdion != null and queryCdion != '') or (serverFilter != null and serverFilter != ''))"> select * from (${querySql})${tableAlias} <trim prefix="where" suffixOverrides="and"/> <where> <if test="queryCdion != null and queryCdion != ''"> (${queryCdion}) </if> <if test="serverFilter != null and serverFilter != ''"> and (${serverFilter}) </if> </where> </when> <otherwise> ${querySql} </otherwise> </choose> <if test="limit != null and limit != ''"> limit ${limit} offset ${offset} </if> )T ) dataTable </insert> </mapper>