IotEntityMapper.xml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.IotEntityDao">
  5. <resultMap type="com.bosshand.virgo.ringzle.model.IotEntity" id="iotEntityResult">
  6. <id column="id" property="id"/>
  7. <result column="name" property="name"/>
  8. <result column="iotEntityId" property="iotEntityId"/>
  9. <result column="entityType" property="entityType"/>
  10. <result column="modelType" property="modelType"/>
  11. </resultMap>
  12. <insert id="save" parameterType="com.bosshand.virgo.ringzle.model.IotEntity" useGeneratedKeys="true" keyProperty="id">
  13. INSERT INTO iot_entity (name,iotEntityId,entityType,modelType) VALUES
  14. (#{name},#{iotEntityId},#{entityType},#{modelType});
  15. </insert>
  16. <select id="get" resultMap="iotEntityResult">
  17. select * from iot_entity where iotEntityId = #{iotEntityId}
  18. </select>
  19. <select id="getList" resultMap="iotEntityResult">
  20. select * from iot_entity
  21. <where>
  22. <if test="id != 0">
  23. and id =#{id}
  24. </if>
  25. <if test="name != null">
  26. and name =#{name}
  27. </if>
  28. <if test="iotEntityId != null">
  29. and iotEntityId =#{iotEntityId}
  30. </if>
  31. <if test="entityType != null">
  32. and entityType =#{entityType}
  33. </if>
  34. <if test="modelType != null">
  35. and modelType =#{modelType}
  36. </if>
  37. </where>
  38. </select>
  39. <update id="update">
  40. update iot_entity
  41. <trim prefix="set" suffixOverrides=",">
  42. <if test="name!=null">name=#{name},</if>
  43. <if test="iotEntityId!=null">iotEntityId=#{iotEntityId},</if>
  44. <if test="entityType!=null">entityType=#{entityType},</if>
  45. <if test="modelType!=null">modelType=#{modelType},</if>
  46. </trim>
  47. where id=#{id}
  48. </update>
  49. <delete id="delete">
  50. delete FROM iot_entity where id=#{id}
  51. </delete>
  52. </mapper>