123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?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.fdkankan.ucenter.mapper.IScenePlusMapper">
- <select id="pageList" resultType="com.fdkankan.ucenter.vo.response.AppSceneVo">
- SELECT p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
- p.status,pay_status,thumb,web_site,0 as is_upgrade,view_count,
- p.camera_id,p.user_id ,p.data_source,p.scene_type,build_type
- FROM t_scene_pro p
- left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
- WHERE is_upgrade = 0 and p.rec_status = 'A' AND ( p.status = 1 OR p.status = -2) AND p.scene_type != 99
- <include refid="commonWhere"></include>
- <if test="param.sceneName !=null and param.sceneName !=''">
- and p.scene_name like CONCAT('%',#{param.sceneName},'%')
- </if>
- UNION
- SELECT p.id as id ,null as name ,0 as isFolder,null as type,null as parentId,p.create_time ,num,title as scene_name,description as scene_dec,
- scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,view_count,
- p.camera_id,p.user_id,e.data_source,p.scene_type,build_type
- FROM t_scene_plus p
- LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
- left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
- WHERE p.rec_status = 'A' AND ( p.scene_status = 1 OR p.scene_status = -2) AND p.scene_type != 99
- <include refid="commonWhere"></include>
- <if test="param.sceneName !=null and param.sceneName !=''">
- and p.title like CONCAT('%',#{param.sceneName},'%')
- </if>
- <if test="param.orderBy !=null and param.orderBy !=''">
- ORDER BY ${param.orderBy}
- </if>
- <if test="param.orderBy ==null or param.orderBy ==''">
- ORDER BY create_time desc
- </if>
- </select>
- <sql id="commonWhere">
- <if test= 'param.userId != null or param.cooperationNumList != null or param.cameraId != null'>
- and ( 1!=1
- </if>
- <if test="param.userId != null">
- or p.user_id =#{param.userId}
- </if>
- <if test="param.cameraId !=null ">
- or p.camera_id = #{param.cameraId}
- </if>
- <if test="param.cooperationNumList !=null and param.cooperationNumList.size >0">
- or p.num in
- <foreach collection="param.cooperationNumList" item="sceneNum" open="(" separator="," close=")">
- #{sceneNum}
- </foreach>
- </if>
- <if test= 'param.userId != null or param.cooperationNumList != null or param.cameraId != null'>
- )
- </if>
- <if test="param.sceneType !=null and param.sceneType !=''">
- and p.scene_type = #{param.sceneType}
- </if>
- <if test= 'param.cameraType != null' >
- and tcd.type = #{param.cameraType}
- </if>
- </sql>
- <select id="getCountByUserId" resultType="java.lang.Long">
- select count(*) from t_scene_plus s left join t_camera_detail d on s.camera_id = d.camera_id
- where s.rec_status = 'A'
- and s.user_id = #{userId} and d.type = #{cameraType}
- </select>
- </mapper>
|