Newer
Older
huludao / src / main / resources / mapper / business / InspectionInfoDao.xml
<?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.newfiber.modules.inspection.dao.InspectionInfoDao">

    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.newfiber.modules.inspection.entity.InspectionInfoEntity" id="inspectionInfoMap">
        <result property="id" column="id"/>
        <result property="inspectionNo" column="inspection_no"/>
        <result property="username" column="username"/>
        <result property="fullname" column="fullname"/>
        <result property="pointx" column="pointx"/>
        <result property="pointy" column="pointy"/>
        <result property="deviation" column="deviation"/>
        <result property="state" column="state"/>
        <result property="remarks" column="remarks"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <!-- 查询巡检信息 -->
    <select id="queryPage" resultMap="inspectionInfoMap">
        SELECT
        id,
        inspection_no,
        username,
        fullname,
        pointx,
        pointy,
        deviation,
        state,
        remarks,
        status,
        create_time
        FROM
        inspection_info
        WHERE
        inspection_no IN
        ( SELECT n.inspection_no FROM ( SELECT DISTINCT inspection_no FROM inspection_info
        WHERE 1 = 1
        <if test="username != null and username.trim() != ''">
            AND username = #{username}
        </if>
        <if test="status != null">
            AND status = #{status}
        </if>
        LIMIT #{page}, #{limit} ) AS n )
    </select>

    <!-- 查询巡检信息总条数 -->
    <select id="queryTotal" resultType="int">
        SELECT
        COUNT( DISTINCT inspection_no )
        FROM inspection_info
        WHERE 1 = 1
        <if test="username != null and username.trim() != ''">
            AND username = #{username}
        </if>
        <if test="status != null">
            AND status = #{status}
        </if>
    </select>

    <update id="updateStatusByNo" parameterType="com.newfiber.modules.inspection.entity.InspectionInfoEntity">
        update inspection_info set status = #{status} where inspection_no = #{inspectionNo}
    </update>

</mapper>