<?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.pj.tb_agreement.TbAgreementMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, type, content from tb_agreement  -->

	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.tb_agreement.TbAgreement"></resultMap>

	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select *
		from tb_agreement
	</sql>


	<!-- 查集合 - 根据条件（参数为空时代表忽略指定条件） [G] -->
	<select id="getList" resultMap="model">
		<include refid="select_sql"></include>
		<where>
			<if test=' this.has("id") '> and id = #{id} </if>
			<if test=' this.has("type") '> and type like concat('%', #{type}, '%') </if>
			<if test=' this.has("content") '> and content like concat('%', #{content}, '%') </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> type desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>










</mapper>
