ElectricModuleMapper.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.welampiot.dao.ElectricModuleDao">
  4. <insert id="add" parameterType="com.welampiot.dto.ElectricModuleDTO" useGeneratedKeys="true" keyProperty="id"
  5. >
  6. insert into electric_module(type,address,box_id
  7. )
  8. values
  9. (#{type},#{address},#{boxId}
  10. )
  11. </insert>
  12. <update id="update" parameterType="com.welampiot.dto.ElectricModuleDTO"
  13. >
  14. update electric_module
  15. set
  16. type=#{type},
  17. address=#{address},
  18. box_id=#{boxId}
  19. where id = #{id}
  20. </update>
  21. <select id="getListByBoxId" resultType="com.welampiot.dto.ElectricModuleDTO" parameterType="int">
  22. select address,id,box_id as boxId,type from electric_module where box_id = #{boxId}
  23. </select>
  24. <select id="getDetailsById" resultType="com.welampiot.dto.ElectricModuleDTO" parameterType="int">
  25. select address,id,box_id as boxId,type from electric_module where id = #{id}
  26. </select>
  27. <delete id="deleteByBoxId" parameterType="int">
  28. delete from electric_module where box_id=#{boxId}
  29. </delete>
  30. <select id="getModuleAddressById" resultType="ElectricModuleDTO">
  31. select e.id,e.address
  32. from electric_module e
  33. where e.box_id = #{boxId} and e.type = 0
  34. </select>
  35. <select id="getAirSwitchAddressById" resultType="AirSwitchInfoDTO">
  36. select a.address
  37. from air_switch_info a
  38. where a.module_id = #{moduleId}
  39. </select>
  40. <update id="updateElectricBoxStatusById" parameterType="AirSwitchInfoDTO">
  41. update air_switch_info a
  42. set
  43. a.`status` = #{status}
  44. where a.module_id = #{moduleId}
  45. </update>
  46. <select id="getModuleAddressByAirIds" resultType="ElectricModuleDTO">
  47. SELECT (em.id) AS id,em.address
  48. FROM electric_module em
  49. LEFT JOIN air_switch_info a
  50. ON em.id = a.module_id
  51. <if test="airIds != null and !airIds.isEmpty()">
  52. WHERE a.id IN
  53. <foreach collection="airIds" item="dto" open="(" separator="," close=")">
  54. #{dto}
  55. </foreach>
  56. </if>
  57. GROUP BY id
  58. </select>
  59. </mapper>