<?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.xunmei.system.mapper.SysWorkTimeMonthMapper">

    <resultMap type="com.xunmei.system.domain.SysWorkTimeMonth" id="SysWorkTimeMonthResult">
                <result property="id" column="id"/>
                <result property="createTime" column="create_time"/>
                <result property="modifiedId" column="modified_id"/>
                <result property="modifiedName" column="modified_name"/>
                <result property="updateTime" column="update_time"/>
                <result property="closeCount" column="close_count"/>
                <result property="month" column="month"/>
                <result property="openCount" column="open_count"/>
                <result property="orgId" column="org_id"/>
    </resultMap>

    <sql id="selectSysWorkTimeMonthVo">
        select id, create_time, modified_id, modified_name, update_time, close_count, month, open_count, org_id
        from sys_work_time_month
    </sql>

    <select id="selectSysWorkTimeMonthList" parameterType="com.xunmei.system.domain.SysWorkTimeMonth"
            resultMap="SysWorkTimeMonthResult">
        <include refid="selectSysWorkTimeMonthVo"/>
        <where>
                        <if test="modifiedId != null ">
                            and modified_id = #{modifiedId}
                        </if>
                        <if test="modifiedName != null  and modifiedName != ''">
                            and modified_name like concat('%', #{modifiedName}, '%')
                        </if>
                        <if test="closeCount != null ">
                            and close_count = #{closeCount}
                        </if>
                        <if test="month != null ">
                            and month = #{month}
                        </if>
                        <if test="openCount != null ">
                            and open_count = #{openCount}
                        </if>
                        <if test="orgId != null ">
                            and org_id = #{orgId}
                        </if>
        </where>
    </select>

    <select id="selectSysWorkTimeMonthById" parameterType="String"
            resultMap="SysWorkTimeMonthResult">
            <include refid="selectSysWorkTimeMonthVo"/>
            where id = #{id}
    </select>

    <insert id="insertSysWorkTimeMonth" parameterType="com.xunmei.system.domain.SysWorkTimeMonth">
        insert into sys_work_time_month
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="id != null">id,
                    </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="modifiedId != null">modified_id,
                    </if>
                    <if test="modifiedName != null">modified_name,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
                    <if test="closeCount != null">close_count,
                    </if>
                    <if test="month != null">month,
                    </if>
                    <if test="openCount != null">open_count,
                    </if>
                    <if test="orgId != null">org_id,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="id != null">#{id},
                    </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="modifiedId != null">#{modifiedId},
                    </if>
                    <if test="modifiedName != null">#{modifiedName},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
                    <if test="closeCount != null">#{closeCount},
                    </if>
                    <if test="month != null">#{month},
                    </if>
                    <if test="openCount != null">#{openCount},
                    </if>
                    <if test="orgId != null">#{orgId},
                    </if>
        </trim>
    </insert>

    <update id="updateSysWorkTimeMonth" parameterType="com.xunmei.system.domain.SysWorkTimeMonth">
        update sys_work_time_month
        <trim prefix="SET" suffixOverrides=",">
                    <if test="createTime != null">create_time =
                        #{createTime},
                    </if>
                    <if test="modifiedId != null">modified_id =
                        #{modifiedId},
                    </if>
                    <if test="modifiedName != null">modified_name =
                        #{modifiedName},
                    </if>
                    <if test="updateTime != null">update_time =
                        #{updateTime},
                    </if>
                    <if test="closeCount != null">close_count =
                        #{closeCount},
                    </if>
                    <if test="month != null">month =
                        #{month},
                    </if>
                    <if test="openCount != null">open_count =
                        #{openCount},
                    </if>
                    <if test="orgId != null">org_id =
                        #{orgId},
                    </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysWorkTimeMonthById" parameterType="String">
        delete
        from sys_work_time_month where id = #{id}
    </delete>

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