<?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.ims.eval.dao.ReportDao"> <sql id="reportColumns"> a.id AS "id", a.report_title AS "reportTitle", a.des AS "des", a.publish_time AS "publishTime", a.report_path AS "reportPath", a.dept_id AS "deptId", a.create_time AS "createTime", a.create_by AS "createBy", a.update_time AS "updateTime", a.update_by AS "updateBy" </sql> <sql id="whereStr"> 1=1 <!-- 快速定位 --> <if test="sqlMap.key != null and sqlMap.key != ''"> AND ( ) </if> <!-- 高级查询dataFilter --> <if test="sqlMap.df != null and sqlMap.df != ''"> AND ( ${sqlMap.df} ) </if> <!-- 默认查询baseFilter --> <if test="sqlMap.bf != null and sqlMap.bf != ''"> AND ( ${sqlMap.bf} ) </if> <!-- 基本Query查询 --> <if test="sqlMap.baseQuery != null and sqlMap.baseQuery != ''"> AND ( ${sqlMap.baseQuery} ) </if> <!-- 特定Query查询 --> <if test="sqlMap.specQuery != null and sqlMap.specQuery != ''"> AND ( ${sqlMap.specQuery} ) </if> <if test="sqlMap.dsf != null and sqlMap.dsf != ''"> AND (${sqlMap.dsf}) </if> </sql> <select id="get" resultType="Report"> SELECT <include refid="reportColumns"/> FROM public.{table.name} a WHERE a.id = #{id} </select> <select id="findList" resultType="Report"> SELECT <include refid="reportColumns"/> FROM public.report a <where> <include refid="whereStr"/> </where> <choose> <when test="page !=null and page.orderBy != null and page.orderBy != ''"> ORDER BY ${page.orderBy} </when> <otherwise> </otherwise> </choose> </select> <select id="findAllList" resultType="Report"> SELECT <include refid="reportColumns"/> FROM public.report a <where> <include refid="whereStr"/> </where> <choose> <when test="page !=null and page.orderBy != null and page.orderBy != ''"> ORDER BY ${page.orderBy} </when> <otherwise> </otherwise> </choose> </select> <sql id="insertColumns"> id, report_title, des, publish_time, report_path, dept_id, create_time, update_time </sql> <insert id="insert"> <selectKey keyProperty="id" resultType="String" order="BEFORE"> <choose> <when test="id == null or id == ''"> select get_next_id('report','') from dual </when> <otherwise> select #{id} from dual </otherwise> </choose> </selectKey> INSERT INTO report( <include refid="insertColumns"/> ) VALUES ( #{id , jdbcType=VARCHAR }, #{reportTitle , jdbcType=VARCHAR }, #{des , jdbcType=VARCHAR }, #{publishTime }, #{reportPath , jdbcType=VARCHAR }, #{deptId , jdbcType=VARCHAR }, #{createTime }, #{updateTime } ) </insert> <insert id="insertList"> INSERT INTO report( <include refid="insertColumns"/> ) select FFF.* from ( <foreach collection="list" item="item" index="index" separator="UNION ALL" > select #{item.id, jdbcType=VARCHAR} as "id", #{item.reportTitle, jdbcType=VARCHAR} as "reportTitle", #{item.des, jdbcType=VARCHAR} as "des", #{item.publishTime} as "publishTime", #{item.reportPath, jdbcType=VARCHAR} as "reportPath", #{item.deptId, jdbcType=VARCHAR} as "deptId", #{item.createTime} as "createTime", #{item.updateTime} as "updateTime" from dual </foreach> ) FFF </insert> <update id="update"> UPDATE report SET id = #{id}, report_title = #{reportTitle}, des = #{des}, publish_time = #{publishTime}, report_path = #{reportPath}, dept_id = #{deptId}, create_time = #{createTime}, update_time = #{updateTime}, update_by = #{updateBy} WHERE id = #{id, jdbcType=VARCHAR} </update> <update id="delete"> DELETE FROM public.report WHERE <choose> <when test="id != null and id != ''"> id = #{id, jdbcType=VARCHAR} </when> <otherwise> </otherwise> </choose> </update> </mapper>