java-team / EapFramework
EAP框架,基于Maven构建,支持本地编译调试
Newer
Older
EapFramework / debugproject / src / main / resources / com / mapping / sqlserver / configTableModel-mapper.xml
20541 on 17 Feb 2023 初始化调式项目
<?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 NAME FROM SYSOBJECTS WHERE TYPE='U' order by NAME
	</select>
</mapper>