DspPlatformMapper.xml 4.2 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.parking.module.park.dsp.dal.mysql.DspPlatformMapper">

    <!--
      下级平台准入(dsp_platform)

      注意:
        1. secret_key / secret_key_prev 只在验签时读取,任何管理端查询都要在 Service 层清空后再返回;
        2. 平台编码全局唯一(uk_platform_code),删除是软删(deleted = 1)。
    -->

    <select id="selectByCode" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspPlatformDO">
        SELECT * FROM dsp_platform
         WHERE platform_code = #{platformCode}
           AND deleted = 0
         LIMIT 1
    </select>

    <select id="selectById" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspPlatformDO">
        SELECT * FROM dsp_platform
         WHERE id = #{id}
           AND deleted = 0
    </select>

    <sql id="listCondition">
        deleted = 0
        <if test="platformCode != null and platformCode != ''">
            AND platform_code LIKE CONCAT('%', #{platformCode}, '%')
        </if>
        <if test="platformName != null and platformName != ''">
            AND platform_name LIKE CONCAT('%', #{platformName}, '%')
        </if>
        <if test="status != null">
            AND status = #{status}
        </if>
    </sql>

    <select id="selectList" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspPlatformDO">
        SELECT * FROM dsp_platform
        <where>
            <include refid="listCondition"/>
        </where>
         ORDER BY id DESC
    </select>

    <select id="selectCount" resultType="java.lang.Long">
        SELECT COUNT(*) FROM dsp_platform
        <where>
            <include refid="listCondition"/>
        </where>
    </select>

    <insert id="insert" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO dsp_platform (
            platform_code, platform_name, platform_type, contact_name, contact_phone, contact_email,
            secret_key, secret_key_prev, prev_key_expire_time, ip_whitelist, data_scope, status,
            remark, deleted, create_time, create_op, modify_time, modify_op
        ) VALUES (
            #{platformCode}, #{platformName}, #{platformType}, #{contactName}, #{contactPhone}, #{contactEmail},
            #{secretKey}, #{secretKeyPrev}, #{prevKeyExpireTime}, #{ipWhitelist}, #{dataScope}, #{status},
            #{remark}, 0, #{createTime}, #{createOp}, #{modifyTime}, #{modifyOp}
        )
    </insert>

    <update id="update">
        UPDATE dsp_platform
           SET platform_name = #{platformName},
               platform_type = #{platformType},
               contact_name = #{contactName},
               contact_phone = #{contactPhone},
               contact_email = #{contactEmail},
               ip_whitelist = #{ipWhitelist},
               data_scope = #{dataScope},
               remark = #{remark},
               modify_time = #{modifyTime},
               modify_op = #{modifyOp}
         WHERE id = #{id}
           AND deleted = 0
    </update>

    <update id="updateStatus">
        UPDATE dsp_platform
           SET status = #{status}, modify_time = #{modifyTime}, modify_op = #{modifyOp}
         WHERE id = #{id}
           AND deleted = 0
    </update>

    <update id="updateSecret">
        UPDATE dsp_platform
           SET secret_key = #{secretKey},
               secret_key_prev = #{secretKeyPrev},
               prev_key_expire_time = #{prevKeyExpireTime},
               modify_time = #{modifyTime},
               modify_op = #{modifyOp}
         WHERE id = #{id}
           AND deleted = 0
    </update>

    <update id="updateLastReport">
        UPDATE dsp_platform
           SET last_report_time = #{lastReportTime}
               <if test="lastSuccessTime != null">
                   , last_success_time = #{lastSuccessTime}
               </if>
         WHERE platform_code = #{platformCode}
           AND deleted = 0
    </update>

    <update id="deleteById">
        UPDATE dsp_platform
           SET deleted = 1, modify_time = #{modifyTime}, modify_op = #{modifyOp}
         WHERE id = #{id}
           AND deleted = 0
    </update>

</mapper>