<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDataAuthMapper">
	<!-- 通用查询映射结果 -->
	<resultMap id="SysDataAuthMap" type="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDataAuth">
		<id property="id" column="id"/>
		<result property="linkType" column="link_type"/>
		<result property="linkId" column="link_id"/>
		<result property="linkName" column="link_name"/>
		<result property="isCreateAuth" column="is_create_auth"/>
		<result property="isDeptAuth" column="is_dept_auth"/>
		<result property="isSettleAuth" column="is_settle_auth"/>
		<result property="isDiySql" column="is_diy_sql"/>
		<result property="createBy" column="create_by"/>
		<result property="createName" column="create_name"/>
		<result property="createTime" column="create_time"/>
		<result property="updateBy" column="update_by"/>
		<result property="updateTime" column="update_time"/>
	</resultMap>

	<sql id="Base_Column_List">
		a.id,
		a.link_type,
		a.link_id,
		a.link_name,
		a.is_create_auth,
		a.is_dept_auth,
		a.is_settle_auth,
		a.is_diy_sql,
		a.create_by,
		a.create_name,
		a.create_time,
		a.update_by,
		a.update_time
	</sql>

	<sql id="sysDataAuthMap_where">
		<if test="sysDataAuth != null">
			<if test="sysDataAuth.id != null and sysDataAuth.id.trim() != ''">
				AND a.id = #{sysDataAuth.id}
			</if>
			<if test="sysDataAuth.linkName != null and sysDataAuth.linkName.trim() != ''">
				AND a.link_name like concat('%',#{sysDataAuth.linkName},'%')
			</if>
			<if test="sysDataAuth.linkId != null and sysDataAuth.linkId.trim() != ''">
				AND a.link_id = #{sysDataAuth.linkId}
			</if>
			<if test="sysDataAuth.linkType != null">
				AND a.link_type =#{sysDataAuth.linkType}
			</if>
		</if>
	</sql>

	<!--简单分页查询-->
	<select id="getSysDataAuthPage" resultMap="SysDataAuthMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM sys_data_auth a
		<where>
			1=1
			<include refid="sysDataAuthMap_where"/>
		</where>
		order by a.create_time desc
	</select>
</mapper>
