<?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.ruoyi.web.modules.delivery.mapper.BizShopDeliverySettingMapper">

    <resultMap id="BizShopDeliverySettingResult" type="com.ruoyi.web.modules.delivery.domain.BizShopDeliverySetting">
        <id property="settingId" column="setting_id"/>
        <result property="shopId" column="shop_id"/>
        <result property="shipperName" column="shipper_name"/>
        <result property="shipperMobile" column="shipper_mobile"/>
        <result property="regionCode" column="region_code"/>
        <result property="regionName" column="region_name"/>
        <result property="cityName" column="city_name"/>
        <result property="detailAddress" column="detail_address"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectColumns">
        setting_id, shop_id, shipper_name, shipper_mobile,
        region_code, region_name, city_name, detail_address,
        create_by, create_time, update_by, update_time
    </sql>

    <select id="selectByShopId" resultMap="BizShopDeliverySettingResult">
        select <include refid="selectColumns"/>
        from biz_shop_delivery_setting
        where shop_id = #{shopId}
        limit 1
    </select>

    <select id="selectCityNameByShopId" resultType="java.lang.String">
        select city_name
        from biz_shop_delivery_setting
        where shop_id = #{shopId}
        limit 1
    </select>

    <insert id="insert" useGeneratedKeys="true" keyProperty="settingId">
        insert into biz_shop_delivery_setting (
            shop_id, shipper_name, shipper_mobile,
            region_code, region_name, city_name, detail_address,
            create_by, create_time, update_by, update_time
        ) values (
            #{shopId}, #{shipperName}, #{shipperMobile},
            #{regionCode}, #{regionName}, #{cityName}, #{detailAddress},
            #{createBy}, #{createTime}, #{updateBy}, #{updateTime}
        )
    </insert>

    <update id="updateByShopId" parameterType="com.ruoyi.web.modules.delivery.domain.BizShopDeliverySetting">
        update biz_shop_delivery_setting
        set shipper_name = #{shipperName},
            shipper_mobile = #{shipperMobile},
            region_code = #{regionCode},
            region_name = #{regionName},
            city_name = #{cityName},
            detail_address = #{detailAddress},
            update_by = #{updateBy},
            update_time = #{updateTime}
        where shop_id = #{shopId}
    </update>

</mapper>
