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 * FROM(
  6. SELECT p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
  7. p.status,pay_status,thumb,web_site,0 as is_upgrade,view_count,
  8. p.camera_id,p.user_id ,p.data_source,p.scene_type,build_type
  9. FROM t_scene_pro p
  10. <include refid="commonWhere"></include>
  11. <if test="param.sceneName !=null and param.sceneName !=''">
  12. and (p.scene_name like concat ('%',#{param.sceneName},'%') or p.laser_title like concat ('%',#{param.sceneName},'%') )
  13. </if>
  14. and is_upgrade = 0
  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 s.id = e.plus_id
  21. <include refid="commonWhere"></include>
  22. <if test="param.sceneName !=null and param.sceneName !=''">
  23. and (p.title like concat ('%',#{param.sceneName},'%') or p.laser_title like concat ('%',#{param.sceneName},'%') )
  24. </if>
  25. ) as tb
  26. <if test="param.orderBy !=null and param.orderBy !=''">
  27. ORDER BY ${param.orderBy}
  28. </if>
  29. <if test="param.orderBy ==null or param.orderBy ==''">
  30. ORDER BY create_time desc
  31. </if>
  32. </select>
  33. <sql id="commonWhere">
  34. left join t_user u on p.user_id = u.id
  35. left join t_camera c on p.camera_id = c.id
  36. left join t_camera_detail d on c.id = d.camera_id
  37. left join t_company co on u.company_id = co.id
  38. where p.rec_status = 'A'
  39. <if test="param.sceneType !=null and param.sceneType !=''">
  40. and p.scene_type = #{param.sceneType}
  41. </if>
  42. <if test= "param.cameraType != null" >
  43. and d.goods_id = #{param.cameraType}
  44. </if>
  45. <if test= "param.payStatus != null">
  46. and p.pay_status = #{param.payStatus}
  47. </if>
  48. <if test="param.userId !=null and param.companyId !=null and param.cooperationNumList !=null and param.cooperationNumList.size >0">
  49. and ( p.user_id = #{param.userId} or co.id = #{param.companyId} or p.num in
  50. <foreach collection="param.cooperationNumList" item="coNum" open="(" separator="," close=")">
  51. #{coNum}
  52. </foreach>
  53. )
  54. </if>
  55. <if test="param.userId !=null and param.companyId !=null and param.cooperationNumList !=null and param.cooperationNumList.size ==0 ">
  56. and (co.id = #{param.companyId} or p.user_id = #{param.userId} )
  57. </if>
  58. </sql>
  59. <select id="getCountByUserId" resultType="java.lang.Long">
  60. select count(*) from t_scene_plus s left join t_camera_detail d on s.camera_id = d.camera_id
  61. where s.rec_status = 'A'
  62. and s.user_id = #{userId} and d.goods_id = #{cameraType}
  63. </select>
  64. </mapper>