Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / resources / mapper / termite / DeviceInfoMapper.xml
@xiongkai xiongkai on 27 May 2 KB 基础代码整理
<?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.termite.mapper.DeviceInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap type="com.newfiber.termite.domain.DeviceInfo" id="DeviceInfoResult">
        <result property="id" column="id"/>
        <result property="category" column="category"/>
        <result property="projectCode" column="project_code"/>
        <result property="sn" column="sn"/>
        <result property="location" column="location"/>
        <result property="initialpictu" column="initialpictu"/>
        <result property="lonandlat" column="lonandlat"/>
        <result property="delFlag" column="del_flag"/>
        <result property="lastPicTime" column="last_pic_time"/>
        <result property="firstWarnDatetime" column="first_warn_datetime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        t.id
    	, t.category
    	, t.project_code
    	, t.sn
    	, t.location
    	, t.initialpictu
    	, t.lonandlat
    	, t.del_flag
    	, t.last_pic_time
    	, t.first_warn_datetime
	</sql>

    <sql id="Where_Condition">
        <if test="request.category != null and request.category != ''">
            and t.category = #{request.category}
        </if>
        <if test="request.projectCode != null and request.projectCode != ''">
            and t.project_code = #{request.projectCode}
        </if>
        <if test="request.sn != null and request.sn != ''">
            and t.sn = #{request.sn}
        </if>
        <if test="request.warnFlag != null and request.warnFlag != ''">
            and t.first_warn_datetime is not null
        </if>
    </sql>

    <sql id="Join_Table">

    </sql>

    <select id="selectByCondition" resultMap="DeviceInfoResult">
        select
        <include refid="Base_Column_List"/>
        from ter_device_info t
        <include refid="Join_Table"/>
        where t.del_flag = 0
        <include refid="Where_Condition"/>
        order by t.${request.orderBy}
    </select>

    <select id="selectOneById" resultMap="DeviceInfoResult">
        select
        <include refid="Base_Column_List"/>
        from ter_device_info t
        <include refid="Join_Table"/>
        where t.id = #{id} and t.del_flag = 0
    </select>

</mapper>