<?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.willalp.canteen.mapper.HsCanteenScrkMapper">

    <resultMap type="HsCanteenScrk" id="HsCanteenScrkResult">
        <result property="recordId"    column="record_id"    />
        <result property="name"    column="name"    />
        <result property="amount"    column="amount"    />
        <result property="unit"    column="unit"    />
        <result property="total"    column="total"    />
        <result property="incomeTime"    column="income_time"    />
        <result property="remark"    column="remark"    />
        <result property="jgid"    column="jgid"    />
        <result property="isDelete"    column="is_delete"    />
    </resultMap>

    <sql id="selectHsCanteenScrkVo">
        select record_id, name, amount, unit, total, income_time, remark, jgid, is_delete from hs_canteen_scrk
    </sql>

    <select id="selectHsCanteenScrkList" parameterType="HsCanteenScrk" resultMap="HsCanteenScrkResult">
        <include refid="selectHsCanteenScrkVo"/>
        <where>
            is_delete = 0
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
<!--            <if test="params.beginIncomeTime != null and params.beginIncomeTime != '' and params.endIncomeTime != null and params.endIncomeTime != ''"> and income_time between #{params.beginIncomeTime} and #{params.endIncomeTime}</if>-->
            <if test="jgid != null  and jgid != ''"> and jgid = #{jgid}</if>
        </where>
        order by income_time desc
    </select>

    <select id="getScList" resultMap="HsCanteenScrkResult">
        select DISTINCT
         record_id, name, amount, unit, total, income_time, remark, jgid, is_delete
        from hs_canteen_scrk
        where
         is_delete = 0 and jgid = #{jgid}
    </select>
</mapper>
