| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?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="cn.com.goldenwater.dcproj.dao.TacInspBatchDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.TacInspBatch" id="tacInspBatchResultMap">
- <result property="id" column="ID"/>
- <result property="batch" column="BATCH"/>
- <result property="sn" column="SN"/>
- <result property="province" column="PROVINCE"/>
- </resultMap>
- <sql id="table_columns">
- ID,
- BATCH,
- SN,PROVINCE
- </sql>
- <sql id="entity_properties">
- #{id},
- #{batch},
- #{sn},#{province}
- </sql>
- <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
- <sql id="page_where">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
- <if test="sn != null and sn != ''">and SN = #{sn}</if>
- <include refid="choseSql"/>
- </trim>
- </sql>
- <sql id="choseSql">
- <choose>
- <when test="province !=null and province !=''">
- AND t.PROVINCE=#{province}
- </when>
- <otherwise>
- AND t.PROVINCE is null
- </otherwise>
- </choose>
- </sql>
- <select id="get" resultMap="tacInspBatchResultMap" parameterType="String">
- select
- <include refid="table_columns"/>
- from TAC_INSP_BATCH where ID = #{id}
- </select>
- <select id="getBy" resultMap="tacInspBatchResultMap">
- select
- <include refid="table_columns"/>
- from TAC_INSP_BATCH t
- <include refid="page_where"/>
- order by sn
- </select>
- <select id="findAll" resultMap="tacInspBatchResultMap">
- select
- <include refid="table_columns"/>
- from TAC_INSP_BATCH
- order by sn
- </select>
- <select id="findList" resultMap="tacInspBatchResultMap">
- select
- <include refid="table_columns"/>
- from TAC_INSP_BATCH t
- <include refid="page_where"/>
- </select>
- <select id="selectCount" resultType="int">
- select count(ID) from TAC_INSP_BATCH t
- <include refid="page_where"/>
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
- insert into TAC_INSP_BATCH(
- <include refid="table_columns"/>
- )
- values (
- <include refid="entity_properties"/>
- )
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from TAC_INSP_BATCH where ID = #{id}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
- delete from TAC_INSP_BATCH t
- <include refid="page_where"/>
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update TAC_INSP_BATCH set flag_valid = 0 where ID = #{id}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
- update TAC_INSP_BATCH
- <trim prefix="set" suffixOverrides=",">
- <if test="batch != null and batch != ''">BATCH = #{batch},</if>
- <if test="sn != null and sn != ''">SN = #{sn},</if>
- <if test="province != null ">PROVINCE = #{province},</if>
- </trim>
- <where>ID = #{id}</where>
- </update>
- <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
- update TAC_INSP_BATCH
- <trim prefix="set" suffixOverrides=",">
- <if test="batch != null and batch != ''">BATCH = #{batch},</if>
- <if test="sn != null and sn != ''">SN = #{sn},</if>
- <if test="province != null ">PROVINCE = #{province},</if>
- </trim>
- <include refid="page_where"/>
- </update>
- <!-- 其他自定义SQL -->
- <select id="getBatchListByYear" resultType="cn.com.goldenwater.dcproj.model.TacInspBatch"
- parameterType="cn.com.goldenwater.dcproj.param.TacInspBatchParam">
- SELECT * FROM TAC_INSP_BATCH T
- WHERE T.BATCH NOT IN (SELECT B.BATCH FROM TAC_INSP_YEAR_BATCH B WHERE B.YEAR = #{year}
- <include refid="choseSqlYear"/>
- )
- <include refid="choseSql"/>
- ORDER BY T.SN
- </select>
- <sql id="choseSqlYear">
- <trim>
- <choose>
- <when test="province !=null and province !=''">
- and b.province=#{province}
- </when>
- <otherwise>
- and b.province is null
- </otherwise>
- </choose>
- </trim>
- </sql>
- </mapper>
|