IotEntityBimRuleMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE mapper
  2. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.bosshand.virgo.ringzle.dao.IotEntityBimRuleDao">
  5. <resultMap type="com.bosshand.virgo.ringzle.model.IotEntityBimRule" id="iotEntityBimRuleResult">
  6. <id column="id" property="id"/>
  7. <result column="name" property="name"/>
  8. <result column="state" property="state"/>
  9. <result column="comment" property="comment"/>
  10. <result column="attributeValue" property="attributeValue"/>
  11. <result column="type" property="type"/>
  12. <result column="chartType" property="chartType"/>
  13. <result column="data" property="data"/>
  14. <result column="iotEntityId" property="iotEntityId"/>
  15. <association property="ruleConditions" resultMap="com.bosshand.virgo.ringzle.dao.RuleConditionDao.ruleConditionResult" columnPrefix="ruleCondition_"/>
  16. </resultMap>
  17. <insert id="save" parameterType="com.bosshand.virgo.ringzle.model.IotEntityBimRule" useGeneratedKeys="true" keyProperty="id">
  18. INSERT INTO iot_entity_bim_rule (iotEntityId,name,state,comment,attributeValue,type,chartType,data) VALUES
  19. (#{iotEntityId},#{name},#{state},#{comment},#{attributeValue},#{type},#{chartType},#{data})
  20. </insert>
  21. <sql id="query">
  22. select a.*,
  23. b.ruleId as ruleCondition_ruleId,
  24. b.elementIds as ruleCondition_elementIds,
  25. b.color as ruleCondition_color,
  26. b.lineColor as ruleCondition_lineColor,
  27. b.image as ruleCondition_image,
  28. b.propertyName as ruleCondition_propertyName,
  29. b.propertyValue as ruleCondition_propertyValue,
  30. b.factor as ruleCondition_factor
  31. from iot_entity_bim_rule a
  32. left join iot_entity_bim_rule_condition b on a.id = b.ruleId
  33. </sql>
  34. <select id="getList" resultMap="iotEntityBimRuleResult">
  35. <include refid="query" />
  36. <where>
  37. <if test="id != 0">
  38. and a.id =#{id}
  39. </if>
  40. <if test="name != null">
  41. and a.name =#{name}
  42. </if>
  43. <if test="state != null">
  44. and a.state =#{state}
  45. </if>
  46. <if test="iotEntityId != null">
  47. and a.iotEntityId =#{iotEntityId}
  48. </if>
  49. </where>
  50. </select>
  51. <select id="getIotEntityId" resultMap="iotEntityBimRuleResult">
  52. <include refid="query" />
  53. where a.iotEntityId =#{iotEntityId} and a.state = 1
  54. </select>
  55. <update id="update">
  56. update iot_entity_bim_rule
  57. <trim prefix="set" suffixOverrides=",">
  58. <if test="name!=null">name=#{name},</if>
  59. <if test="state!=null">state=#{state},</if>
  60. <if test="comment!=null">comment=#{comment},</if>
  61. <if test="iotEntityId!=null">iotEntityId=#{iotEntityId},</if>
  62. <if test="attributeValue!=null">attributeValue=#{attributeValue},</if>
  63. <if test="type!=0">type=#{type},</if>
  64. <if test="chartType!=0">chartType=#{chartType},</if>
  65. <if test="data!=null">data=#{data},</if>
  66. </trim>
  67. where id=#{id}
  68. </update>
  69. <delete id="delete">
  70. delete FROM iot_entity_bim_rule where id=#{id}
  71. </delete>
  72. </mapper>