ScenePlusMapper.xml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. left join t_company com on tcd.company_id = com.id
  11. WHERE is_upgrade = 0 and p.rec_status = 'A' AND ( p.status = 1 OR p.status = -2) AND p.scene_type != 99
  12. <include refid="commonWhere"></include>
  13. <if test="param.sceneName !=null and param.sceneName !=''">
  14. and p.scene_name like CONCAT('%',#{param.sceneName},'%')
  15. </if>
  16. UNION
  17. 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,
  18. scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,view_count,
  19. p.camera_id,p.user_id,e.data_source,p.scene_type,build_type
  20. FROM t_scene_plus p
  21. LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
  22. left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
  23. left join t_company com on tcd.company_id = com.id
  24. WHERE p.rec_status = 'A' AND ( p.scene_status = 1 OR p.scene_status = -2) AND p.scene_type != 99
  25. <include refid="commonWhere"></include>
  26. <if test="param.sceneName !=null and param.sceneName !=''">
  27. and p.title like CONCAT('%',#{param.sceneName},'%')
  28. </if>
  29. <if test="param.orderBy !=null and param.orderBy !=''">
  30. ORDER BY ${param.orderBy}
  31. </if>
  32. <if test="param.orderBy ==null or param.orderBy ==''">
  33. ORDER BY create_time desc
  34. </if>
  35. </select>
  36. <sql id="commonWhere">
  37. <if test= 'param.userId != null or param.cooperationNumList != null or param.cameraId != null or param.companyId != null'>
  38. and ( 1!=1
  39. </if>
  40. <if test="param.userId != null">
  41. or p.user_id =#{param.userId}
  42. </if>
  43. <if test= 'param.companyId != null' >
  44. or com.id = #{param.companyId}
  45. </if>
  46. <if test="param.cameraId !=null ">
  47. or p.camera_id = #{param.cameraId}
  48. </if>
  49. <if test="param.companyId != null and param.cooperationNumList !=null and param.cooperationNumList.size >0">
  50. or p.num in
  51. <foreach collection="param.cooperationNumList" item="sceneNum" open="(" separator="," close=")">
  52. #{sceneNum}
  53. </foreach>
  54. </if>
  55. <if test= 'param.userId != null or param.cooperationNumList != null or param.cameraId != null or param.companyId != null'>
  56. )
  57. </if>
  58. <if test="param.sceneType !=null and param.sceneType !=''">
  59. and p.scene_type = #{param.sceneType}
  60. </if>
  61. <if test= 'param.cameraType != null' >
  62. and tcd.goods_id = #{param.cameraType}
  63. </if>
  64. <if test= 'param.payStatus != null' >
  65. and p.pay_status = #{param.payStatus}
  66. </if>
  67. </sql>
  68. <select id="getCountByUserId" resultType="java.lang.Long">
  69. select count(*) from t_scene_plus s left join t_camera_detail d on s.camera_id = d.camera_id
  70. where s.rec_status = 'A'
  71. and s.user_id = #{userId} and d.goods_id = #{cameraType}
  72. </select>
  73. </mapper>