<?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.ehsLawEnforce.mapper.EhsLawEnforcementMapper">

    <resultMap type="EhsLawEnforcement" id="EhsLawEnforcementResult">
            <result property="id"    column="id"    />
            <result property="enterpriseName"    column="enterprise_name"    />
            <result property="location"    column="location"    />
            <result property="responsiblePerson"    column="responsible_person"    />
            <result property="phone"    column="phone"    />
            <result property="risk"    column="risk"    />
            <result property="isLargeRisk"    column="is_large_risk"    />
            <result property="rectificationMeasure"    column="rectification_measure"    />
            <result property="rectificationPeople"    column="rectification_people"    />
            <result property="enterpriseCategory"    column="enterprise_category"    />
            <result property="employeeNum"    column="employee_num"    />
            <result property="isEstablishPrevention"    column="is_establish_prevention"    />
            <result property="time"    column="time"    />
            <result property="other"    column="other"    />
            <result property="classFirst"    column="class_first"    />
            <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"    />
            <result property="deptId"    column="dept_id"    />
            <result property="createUserId"    column="create_user_id"    />
            <result property="updateUserId"    column="update_user_id"    />
    </resultMap>

    <sql id="selectEhsLawEnforcementVo">
        select e.*, d.dept_name from ehs_law_enforcement e
           left join sys_dept d on e.dept_id = d.dept_id
    </sql>

    <select id="selectEhsLawEnforcementList" parameterType="EhsLawEnforcement" resultMap="EhsLawEnforcementResult">
        <include refid="selectEhsLawEnforcementVo"/>
        <where>
                        <if test="enterpriseName != null  and enterpriseName != ''"> and e.enterprise_name like concat('%', #{enterpriseName}, '%')</if>
                        <if test="location != null  and location != ''"> and e.location like concat('%', #{location}, '%')</if>
                        <if test="responsiblePerson != null  and responsiblePerson != ''"> and e.responsible_person like concat('%', #{responsiblePerson}, '%')</if>
                        <if test="phone != null  and phone != ''"> and e.phone = #{phone}</if>
                        <if test="risk != null  and risk != ''"> and e.risk = #{risk}</if>
                        <if test="isLargeRisk != null  and isLargeRisk != ''"> and e.is_large_risk = #{isLargeRisk}</if>
                        <if test="rectificationMeasure != null  and rectificationMeasure != ''"> and e.rectification_measure = #{rectificationMeasure}</if>
                        <if test="rectificationPeople != null  and rectificationPeople != ''"> and e.rectification_people like concat('%',#{rectificationPeople}, '%')</if>
                        <if test="enterpriseCategory != null "> and e.enterprise_category = #{enterpriseCategory}</if>
                        <if test="employeeNum != null "> and e.employee_num = #{employeeNum}</if>
                        <if test="isEstablishPrevention != null  and isEstablishPrevention != ''"> and e.is_establish_prevention = #{isEstablishPrevention}</if>
                        <if test="time != null "> and e.time = #{time}</if>
                        <if test="other != null  and other != ''"> and e.other = #{other}</if>
                        <if test="classFirst != null "> and e.class_first = #{classFirst}</if>
        </where>
    </select>

    <select id="selectEhsLawEnforcementById" parameterType="Long" resultMap="EhsLawEnforcementResult">
            <include refid="selectEhsLawEnforcementVo"/>
            where e.id = #{id}
    </select>




</mapper>