<?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.tofly.xrtygis.mapper.TfCameraManageMapper">

  <resultMap id="tfCameraManageMap" type="com.tofly.xrtygis.entity.TfCameraManage">
                      <id property="id" column="ID"/>
                      <result property="createUser" column="CREATE_USER"/>
                      <result property="createTime" column="CREATE_TIME"/>
                      <result property="belongStatus" column="BELONG_STATUS"/>
                      <result property="waterId" column="WATER_ID"/>
                      <result property="code" column="CODE"/>
                      <result property="name" column="NAME"/>
                      <result property="model" column="MODEL"/>
                      <result property="manufactor" column="MANUFACTOR"/>
                      <result property="installationUnit" column="INSTALLATION_UNIT"/>
                      <result property="installationTime" column="INSTALLATION_TIME"/>
                      <result property="installationPeople" column="INSTALLATION_PEOPLE"/>
                      <result property="leader" column="LEADER"/>
                      <result property="phone" column="PHONE"/>
                      <result property="longitude" column="LONGITUDE"/>
                      <result property="latitude" column="LATITUDE"/>
                      <result property="describe" column="DESCRIBE"/>
                      <result property="typeId" column="TYPE_ID"/>
                      <association property="createUserName" column="CREATE_USER"
                                   select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"></association>
                      <association property="waterName" column="WATER_ID"
                                   select="com.tofly.xrtygis.mapper.TfWaterInfoMapper.getWaterName"></association>
                      <association property="belongStatusName" column="BELONG_STATUS"
                                   select="getBelongStatusName"></association>
                      <association property="typeName" column="TYPE_ID"
                                   select="getTypeName"></association>

                                                                                                                                                                                                                                                                                                                                                                                                                                </resultMap>

    <select id="getBelongStatusName" resultType="string">
        SELECT decode(#{belongStatus}, '0', '未定义', '1', '水厂', '2', '管网', '3', '污水厂', '4',
                      '泵站') as belongStatusName
        FROM dual
    </select>

    <select id="getTypeName" resultType="string">
        SELECT NAME AS typeName
        FROM TF_CAMERA_TYPE
        WHERE ID = #{typeId}
    </select>

</mapper>
