<?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.system.mapper.StoreInfoMapper">
    
    <resultMap type="StoreInfo" id="StoreInfoResult">
        <result property="id"    column="id"    />
        <result property="storeCode"    column="store_code"    />
        <result property="storeType"    column="store_type"    />
        <result property="storeStatus"    column="store_status"    />
        <result property="stationCode"    column="station_code"    />
        <result property="shelfCode"    column="shelf_code"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdDt"    column="created_dt"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="updatedDt"    column="updated_dt"    />
    </resultMap>

    <sql id="selectStoreInfoVo">
        select id, store_code, store_type, store_status, station_code, shelf_code, created_by, created_dt, updated_by, updated_dt from store_info
    </sql>

    <select id="selectStoreInfoList" parameterType="StoreInfo" resultMap="StoreInfoResult">
        <include refid="selectStoreInfoVo"/>
        <where>  
            <if test="storeCode != null  and storeCode != ''"> and store_code = #{storeCode}</if>
            <if test="storeType != null "> and store_type = #{storeType}</if>
            <if test="storeStatus != null "> and store_status = #{storeStatus}</if>
            <if test="stationCode != null  and stationCode != ''"> and station_code = #{stationCode}</if>
            <if test="shelfCode != null  and shelfCode != ''"> and shelf_code = #{shelfCode}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="createdDt != null "> and created_dt = #{createdDt}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="updatedDt != null "> and updated_dt = #{updatedDt}</if>
        </where>
    </select>
    
    <select id="selectStoreInfoById" parameterType="Long" resultMap="StoreInfoResult">
        <include refid="selectStoreInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertStoreInfo" parameterType="StoreInfo" useGeneratedKeys="true" keyProperty="id">
        insert into store_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="storeCode != null">store_code,</if>
            <if test="storeType != null">store_type,</if>
            <if test="storeStatus != null">store_status,</if>
            <if test="stationCode != null">station_code,</if>
            <if test="shelfCode != null">shelf_code,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdDt != null">created_dt,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="updatedDt != null">updated_dt,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="storeCode != null">#{storeCode},</if>
            <if test="storeType != null">#{storeType},</if>
            <if test="storeStatus != null">#{storeStatus},</if>
            <if test="stationCode != null">#{stationCode},</if>
            <if test="shelfCode != null">#{shelfCode},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdDt != null">#{createdDt},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedDt != null">#{updatedDt},</if>
         </trim>
    </insert>

    <update id="updateStoreInfo" parameterType="StoreInfo">
        update store_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="storeCode != null">store_code = #{storeCode},</if>
            <if test="storeType != null">store_type = #{storeType},</if>
            <if test="storeStatus != null">store_status = #{storeStatus},</if>
            <if test="stationCode != null">station_code = #{stationCode},</if>
            <if test="shelfCode != null">shelf_code = #{shelfCode},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdDt != null">created_dt = #{createdDt},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="updatedDt != null">updated_dt = #{updatedDt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteStoreInfoById" parameterType="Long">
        delete from store_info where id = #{id}
    </delete>

    <delete id="deleteStoreInfoByIds" parameterType="String">
        delete from store_info where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>