<?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.publiccms.logic.mapper.tools.SqlMapper">
    <select id="select" parameterType="String" resultType="map">
        ${sql}
    </select>
    <select id="query" parameterType="String" resultType="map">
        ${sql}
    </select>
    <insert id="insert" parameterType="String">
        ${sql}
    </insert>
    <update id="update" parameterType="String">
        ${sql}
    </update>
    <delete id="delete" parameterType="String">
        ${sql}
    </delete>
    <update id="updateContentAttribute" parameterType="map">
        update cms_content_attribute a join cms_content b on a.content_id = b.id set a.text=replace(a.text,#{oldurl},#{newurl}),a.data=replace(a.data,#{oldurl},#{newurl}) where b.site_id = #{siteId}
    </update>
    <update id="updateContentRelated" parameterType="map">
        update cms_content_related a join cms_content b on a.content_id = b.id set a.url=replace(a.url,#{oldurl},#{newurl}) where b.site_id = #{siteId}
    </update>
    <update id="updatePlaceAttribute" parameterType="map">
        update cms_place_attribute a join cms_place b on a.place_id = b.id set a.data=replace(a.data,#{oldurl},#{newurl}) where b.site_id = #{siteId}
    </update>
    <update id="updatePlace" parameterType="map">
        update cms_place set url=replace(url,#{oldurl},#{newurl}),cover=replace(cover,#{oldurl},#{newurl}) where site_id = #{siteId}
    </update>
    <update id="updateCategoryAttribute" parameterType="map">
        update cms_category_attribute a join cms_category b on a.category_id = b.id set a.data=replace(a.data,#{oldurl},#{newurl}) where b.site_id = #{siteId}
    </update>
    <update id="updateConfigData" parameterType="map">
        update sys_config_data set data=replace(data,#{oldurl},#{newurl}) where site_id = #{siteId}
    </update>
</mapper>