ScenePlusMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.fdkankan.ucenter.mapper.IScenePlusMapper">
  4. <select id="pageList" resultType="com.fdkankan.ucenter.vo.response.AppSceneVo">
  5. SELECT p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
  6. p.status,pay_status,thumb,web_site,0 as is_upgrade,view_count,
  7. p.camera_id,p.user_id ,p.data_source,p.scene_type,build_type
  8. FROM t_scene_pro p
  9. left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
  10. WHERE is_upgrade = 0 and p.rec_status = 'A' AND ( p.status = 1 OR p.status = -2) AND p.scene_type != 99
  11. <include refid="commonWhere"></include>
  12. <if test="param.sceneName !=null and param.sceneName !=''">
  13. and p.scene_name like CONCAT('%',#{param.sceneName},'%')
  14. </if>
  15. UNION
  16. 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,
  17. scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,view_count,
  18. p.camera_id,p.user_id,e.data_source,p.scene_type,build_type
  19. FROM t_scene_plus p
  20. LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
  21. left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
  22. WHERE p.rec_status = 'A' AND ( p.scene_status = 1 OR p.scene_status = -2) AND p.scene_type != 99
  23. <include refid="commonWhere"></include>
  24. <if test="param.sceneName !=null and param.sceneName !=''">
  25. and p.title like CONCAT('%',#{param.sceneName},'%')
  26. </if>
  27. <if test="param.orderBy !=null and param.orderBy !=''">
  28. ORDER BY ${param.orderBy}
  29. </if>
  30. <if test="param.orderBy ==null or param.orderBy ==''">
  31. ORDER BY create_time desc
  32. </if>
  33. </select>
  34. <sql id="commonWhere">
  35. <if test= 'param.userId != null or param.cooperationNumList != null or param.cameraId != null'>
  36. and ( 1!=1
  37. </if>
  38. <if test="param.userId != null">
  39. or p.user_id =#{param.userId}
  40. </if>
  41. <if test="param.cameraId !=null ">
  42. or p.camera_id = #{param.cameraId}
  43. </if>
  44. <if test="param.cooperationNumList !=null and param.cooperationNumList.size >0">
  45. or p.num in
  46. <foreach collection="param.cooperationNumList" item="sceneNum" open="(" separator="," close=")">
  47. #{sceneNum}
  48. </foreach>
  49. </if>
  50. <if test= 'param.userId != null or param.cooperationNumList != null or param.cameraId != null'>
  51. )
  52. </if>
  53. <if test="param.sceneType !=null and param.sceneType !=''">
  54. and p.scene_type = #{param.sceneType}
  55. </if>
  56. <if test= 'param.cameraType != null' >
  57. and tcd.type = #{param.cameraType}
  58. </if>
  59. </sql>
  60. <select id="getCountByUserId" resultType="java.lang.Long">
  61. select count(*) from t_scene_plus s left join t_camera_detail d on s.camera_id = d.camera_id
  62. where s.rec_status = 'A'
  63. and s.user_id = #{userId} and d.type = #{cameraType}
  64. </select>
  65. </mapper>