<?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.kmall.api.dao.ApiSysPrinterMapper">

    <resultMap type="com.kmall.api.entity.SysPrinterVo" id="sysPrinterMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="sn" column="sn"/>
        <result property="storeId" column="store_id"/>
    </resultMap>

    <select id="queryObject" resultType="com.kmall.api.entity.SysPrinterVo">
		select
			`id`,
			`name`,
			`sn`,
			`store_id`
		from sys_printer
		where id = #{id}
	</select>

    <select id="queryList" resultType="com.kmall.api.entity.SysPrinterVo">
        select
        `id`,
        `name`,
        `sn`,
        `store_id`
        from sys_printer
        WHERE 1=1
        <if test="storeId != null">
            AND store_id = #{storeId}
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(*) from sys_printer
        WHERE 1=1
        <if test="storeId != null">
            AND store_id = #{storeId}
        </if>
    </select>
</mapper>