<?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.api.pc.dao.CameraGroupInfoMapper"> <!-- 通用映射列 --> <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.entity.CameraGroupInfo"> <result column="id" property="id"/> <result column="name" property="name"/> <result column="parent_id" property="parentId"/> <result column="duty_user" property="dutyUser"/> <result column="phone" property="phone"/> <result column="position" property="position"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <!-- 通用数据库列 --> <sql id="Base_Column_List"> id, name, parent_id, duty_user, phone, position, create_time, update_time </sql> <delete id="deleteByParentId"> delete from camera_group_info where parent_id = #{groupId} </delete> <select id="selectCameraPage" resultType="com.newfiber.api.pc.model.entity.CameraGroupInfo"> SELECT cgi.id,cgi.`name`,cgi.parent_id,cgi.duty_user,cgi.phone,cgi.position,cgi.create_time, cgi.update_time,cgi2.`name` as parentName FROM `camera_group_info` cgi left join `camera_group_info` cgi2 on cgi.parent_id = cgi2.id where cgi.parent_id in (select id from camera_group_info where parent_id =0) <if test="searchStr!=null and searchStr !=''"> and cgi.name like concat('%',#{searchStr},'%') </if> order by cgi.create_time desc </select> <select id="selectCameraIndex" resultType="string"> SELECT ci.index_code FROM `camera_group_info` cgi left join camera_group_relation cgr on cgi.id = cgr.group_id left join camera_info ci on cgr.camera_id = ci.id where parent_id = #{parentId} and index_code is not null </select> <select id="selectCameraInfo" resultType="com.newfiber.api.pc.model.entity.CameraInfo"> SELECT ci.* FROM `camera_group_info` cgi left join camera_group_relation cgr on cgi.id = cgr.group_id left join camera_info ci on cgr.camera_id = ci.id where parent_id = #{parentId} and index_code is not null </select> <delete id="deleteByGroupId"> delete from camera_group_info where parent_id = #{id} or id = #{id} </delete> <select id="rootList" resultType="com.newfiber.api.pc.model.entity.CameraGroupInfo"> SELECT <include refid="Base_Column_List"/> from camera_group_info where parent_id = 0 </select> <select id="selectRootList" resultType="com.newfiber.api.pc.model.entity.CameraGroupInfo"> SELECT cgi.id,cgi.`name`,cgi.parent_id,cgi.duty_user,cgi.phone,cgi.position,cgi.create_time, cgi.update_time,cgi2.`name` as parentName,cr.status as status,ci.camera_user FROM `camera_group_info` cgi left join `camera_group_info` cgi2 on cgi.parent_id = cgi2.id left join camera_group_relation cgr on cgr.group_id = cgi.id left join camera_info ci on cgr.camera_id = ci.id left join camera_resource cr on ci.index_code = cr.index_code </select> </mapper>