<?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.ehsEnterprise.mapper.EhsEnterpriseMapper">

    <resultMap type="EhsEnterprise" id="EhsEnterpriseResult">
            <result property="enterpriseId"    column="enterprise_id"    />
            <result property="enterpriseCode"    column="enterprise_code"    />
            <result property="enterpriseName"    column="enterprise_name"    />
            <result property="enterpriseType"    column="enterprise_type"    />
            <result property="enterpriseAddr"    column="enterprise_addr"    />
            <result property="enterpriseLeader"    column="Enterprise_leader"    />
            <result property="leaderTel"    column="leader_tel"    />
            <result property="registeredCapital"    column="registered_capital"    />
            <result property="businessScope"    column="business_scope"    />
            <result property="businessProjects"    column="business_projects"    />
            <result property="enterpriseStatus"    column="enterprise_status"    />
            <result property="safetyManagerName"    column="safety_manager_name"    />
            <result property="safetyManagerTel"    column="safety_manager_tel"    />
            <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="selectEhsEnterpriseVo">
        select enterprise_id, enterprise_code, enterprise_name, enterprise_type, enterprise_addr, Enterprise_leader, leader_tel, registered_capital, business_scope, business_projects, enterprise_status, safety_manager_name, safety_manager_tel, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_enterprise
    </sql>

    <select id="selectEhsEnterpriseList" parameterType="EhsEnterprise" resultMap="EhsEnterpriseResult">
        <include refid="selectEhsEnterpriseVo"/>
        <where>
                        <if test="enterpriseCode != null  and enterpriseCode != ''"> and enterprise_code like concat('%', #{enterpriseCode}, '%')</if>
                        <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
                        <if test="enterpriseType != null  and enterpriseType != ''"> and enterprise_type = #{enterpriseType}</if>
                        <if test="enterpriseAddr != null  and enterpriseAddr != ''"> and enterprise_addr like concat('%', #{enterpriseAddr}, '%')</if>
                        <if test="enterpriseLeader != null  and enterpriseLeader != ''"> and Enterprise_leader like concat('%', #{enterpriseLeader}, '%')</if>
                        <if test="leaderTel != null  and leaderTel != ''"> and leader_tel like concat('%', #{leaderTel}, '%')</if>
                        <if test="registeredCapital != null  and registeredCapital != ''"> and registered_capital like concat('%', #{registeredCapital}, '%')</if>
                        <if test="businessScope != null  and businessScope != ''"> and business_scope like concat('%', #{businessScope}, '%')</if>
                        <if test="businessProjects != null  and businessProjects != ''"> and business_projects like concat('%', #{businessProjects}, '%')</if>
                        <if test="enterpriseStatus != null  and enterpriseStatus != ''"> and enterprise_status = #{enterpriseStatus}</if>
                        <if test="safetyManagerName != null  and safetyManagerName != ''"> and safety_manager_name like concat('%', #{safetyManagerName}, '%')</if>
                        <if test="safetyManagerTel != null  and safetyManagerTel != ''"> and safety_manager_tel like concat('%', #{safetyManagerTel}, '%')</if>
                        <if test="deptId != null "> and dept_id = #{deptId}</if>
                        <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
                        <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
        </where>
    </select>

    <select id="selectEhsEnterpriseByEnterpriseId" parameterType="Long" resultMap="EhsEnterpriseResult">
            <include refid="selectEhsEnterpriseVo"/>
            where enterprise_id = #{enterpriseId}
    </select>




</mapper>