<?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.nantian.cloud.jly.mapper.TOperatingLogMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jly.entity.TOperatingLog">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="creat_time" property="creatTime" />
        <result column="userid" property="userid" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="dept_id" property="deptId" />
        <result column="plan_id" property="planId" />
        <result column="epc" property="epc" />
        <result column="state" property="state" />

        <result column="cmpName" property="cmpName" />
        <result column="planName" property="planName" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, name, creat_time, userid, update_time, del_flag, dept_id, plan_id, epc, state
    </sql>

    <select id="getPageScope" resultType="com.nantian.cloud.jly.entity.TOperatingLog">
        select log.id, log.name, log.creat_time, log.userid, log.update_time, log.del_flag, log.dept_id, log.plan_id, log.epc,
        log.state, p.`name` planName, e.cmp_name cmpName
        from t_operating_log log
        left join check_plan p on log.plan_id = p.id
        left join enterprise_info e on log.epc = e.enterprise_code
        where log.del_flag = '1'
        <if test="query.epc!=null and query.epc != ''">
            and log.epc like concat("%",#{query.epc},"%")
        </if>
        <if test="query.state!=null and query.state != ''">
            and log.state like concat("%",#{query.state},"%")
        </if>
        <if test="query.cmpName!=null and query.cmpName != ''">
            and e.cmp_name like concat("%",#{query.cmpName},"%")
        </if>
        <if test="query.planName!=null and query.planName != ''">
            and p.`name` like concat("%",#{query.planName},"%")
        </if>
        order by log.creat_time desc
    </select>

</mapper>
