<?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="org.springblade.modules.baseinfo.project.mapper.ProjectInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="projectInfoResultMap" type="org.springblade.modules.baseinfo.project.entity.ProjectInfoEntity">
        <result column="project_name" property="projectName"/>
        <result column="org_id" property="orgId"/>
        <result column="manage_name" property="manageName"/>
        <result column="contact_phone" property="contactPhone"/>
        <result column="mail" property="mail"/>
        <result column="agreement_id" property="agreementId"/>
        <result column="power_type_id" property="powerTypeId"/>
        <result column="remark" property="remark"/>
        <result column="import_time" property="importTime"/>
        <result column="warn_active" property="warnActive"/>
        <result column="delay_time" property="delayTime"/>
    </resultMap>

    <!-- 通用查询映射结果 -->
    <resultMap id="projectInfoVOResultMap" type="org.springblade.modules.baseinfo.project.vo.ProjectInfoVO">

        <result column="project_name" property="projectName"/>
        <result column="org_id" property="orgId"/>
        <result column="dept_name" property="orgName"/>
        <result column="manage_name" property="manageName"/>
        <result column="contact_phone" property="contactPhone"/>
        <result column="mail" property="mail"/>
        <result column="agreement_id" property="agreementId"/>
        <result column="power_type_id" property="powerTypeId"/>
        <result column="remark" property="remark"/>
        <result column="import_time" property="importTime"/>
        <result column="warn_active" property="warnActive"/>
        <result column="delay_time" property="delayTime"/>
    </resultMap>


    <select id="selectPage" resultMap="projectInfoVOResultMap">
        SELECT
        n.*
        ,d.dept_name
        FROM
        project_info n
        LEFT JOIN blade_dept d ON d.id = n.org_id
        WHERE
        n.is_deleted = 0
        <if test="projectInfoEntity.projectName!=null">
            and n.project_name like concat(concat('%', #{projectInfoEntity.projectName}), '%')
        </if>
        <if test="projectInfoEntity.orgId!=null">
            and n.org_id = #{projectInfoEntity.orgId}
        </if>

    </select>
</mapper>
