ParkingLotEnclosedSMapper.xml 1.83 KB
<?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.zteits.park.mapper.smapper.ParkingLotEnclosedSMapper">
  <resultMap id="BaseResultMap" type="com.zteits.park.domain.ParkingLotEnclosed">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
    <result column="mch_id" jdbcType="VARCHAR" property="mchId" />
    <result column="free_berth" jdbcType="INTEGER" property="freeBerth" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_op" jdbcType="VARCHAR" property="createOp" />
    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
    <result column="modify_op" jdbcType="VARCHAR" property="modifyOp" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
  </resultMap>


    <update id="decreaseFreeBerthEnclosed" parameterType="com.zteits.clouds.api.dto.park.param.DecreaseFreeBerthEnclosedRequest">
        UPDATE parking_lot_enclosed
        SET free_berth = (
        CASE
        WHEN free_berth > 0  THEN  (free_berth - 1)
        ELSE 0
        END
        )
        WHERE
        1=1
        <if test="plNo != null and plNo != ''">
            and pl_no = #{plNo}
        </if>

    </update>


    <update id="increaseFreeBerthEnclosed" parameterType="com.zteits.clouds.api.dto.park.param.DecreaseFreeBerthEnclosedRequest">
        UPDATE parking_lot_enclosed
        SET free_berth = (
        CASE
        WHEN free_berth &lt; #{berthNum,jdbcType=INTEGER}  THEN  (free_berth + 1)
        ELSE #{berthNum}
        END
        )
        WHERE
        1=1
        <if test="plNo != null and plNo != ''">
            and pl_no = #{plNo}
        </if>

    </update>
</mapper>