<?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.vacation.mapper.HsVacationRuleMapper">

    <resultMap type="com.willalp.vacation.domain.HsVacationRule" id="HsVacationRuleResult">
                    <result property="id" column="id"/>
                    <result property="name" column="name"/>
                    <result property="unit" column="unit"/>
                    <result property="formulaMode" column="formula_mode"/>
                    <result property="giveOutRule" column="give_out_rule"/>
                    <result property="giveOutDate" column="give_out_date"/>
                    <result property="balanceRule" column="balance_rule"/>
                    <result property="application" column="application"/>
                    <result property="isDelete" column="is_delete"/>
                    <result property="createBy" column="create_by"/>
                    <result property="createTime" column="create_time"/>
                    <result property="updateBy" column="update_by"/>
                    <result property="updateTime" column="update_time"/>
                    <result property="remark" column="remark"/>
            </resultMap>
    
    <sql id="selectHsVacationRuleVo">
        select id, name, unit, formula_mode, give_out_rule, give_out_date, balance_rule, application, is_delete, create_by, create_time, update_by, update_time, remark        from hs_vacation_rule
    </sql>

    <select id="selectHsVacationRuleList" parameterType="HsVacationRule" resultMap="HsVacationRuleResult">
        <include refid="selectHsVacationRuleVo"/>
        <where>
            is_delete = 0
                                                                                                    <if test="name != null  and name != ''">
                            and name like concat('%', #{name}, '%')
                        </if>
                                                                                                            <if test="unit != null  and unit != ''">
                            and unit = #{unit}
                        </if>
                                                                                                            <if test="formulaMode != null  and formulaMode != ''">
                            and formula_mode = #{formulaMode}
                        </if>
                                                                                                            <if test="giveOutRule != null  and giveOutRule != ''">
                            and give_out_rule = #{giveOutRule}
                        </if>
                                                                                                            <if test="giveOutDate != null ">
                            and give_out_date = #{giveOutDate}
                        </if>
                                                                                                            <if test="balanceRule != null  and balanceRule != ''">
                            and balance_rule = #{balanceRule}
                        </if>
                                                                                                            <if test="application != null  and application != ''">
                            and application = #{application}
                        </if>
                                                                                                            <if test="isDelete != null ">
                            and is_delete = #{isDelete}
                        </if>
                                                                                                                                                                                                    </where>
    </select>
</mapper>
