gasWellWatch/src/main/resources/mapper/GasWellMapper.xml

101 lines
4.8 KiB
XML

<?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.isu.gaswellwatch.dao.GasWellDao">
<resultMap type="com.isu.gaswellwatch.vo.GasWellVO" id="GasWellVO">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="name" column="name" />
<result property="details" column="details" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
</resultMap>
<resultMap type="com.isu.gaswellwatch.entity.GasWell" id="GasWellResult">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="name" column="name" />
<result property="details" column="details" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
</resultMap>
<sql id="selectGasWellVo">
select t1.id, t1.company_id, t1.name, t1.details, t1.create_by, t1.create_time, t1.update_by, t1.update_time from gas_wells t1
</sql>
<select id="pageForQuery" resultMap="GasWellVO">
<include refid="selectGasWellVo"/>
<where>
<if test="query.companyId != null "> and t1.company_id = #{companyId}</if>
<if test="query.name != null and query.name != ''"> and t1.name like concat('%', #{query.name}, '%')</if>
</where>
order by t1.id desc
</select>
<select id="selectGasWellList" resultMap="GasWellResult">
<include refid="selectGasWellVo"/>
<where>
<if test="companyId != null "> and t1.company_id = #{companyId}</if>
<if test="name != null and name != ''"> and t1.name like concat('%', #{name}, '%')</if>
</where>
</select>
<select id="selectGasWellById" parameterType="Long" resultMap="GasWellResult">
<include refid="selectGasWellVo"/>
where t1.id = #{id}
</select>
<insert id="insertGasWell" useGeneratedKeys="true" keyProperty="id">
insert into gas_wells
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyId != null">company_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="details != null">details,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyId != null">#{companyId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="details != null">#{details},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateGasWell">
update gas_wells
<trim prefix="SET" suffixOverrides=",">
<if test="companyId != null">company_id = #{companyId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="details != null">details = #{details},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteGasWellById" parameterType="Long">
delete from gas_wells where id = #{id}
</delete>
<delete id="deleteGasWellByIds">
delete from gas_wells where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>