VaildCamerasMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.user.mapper.IVaildCamerasMapper">
  4. <resultMap id="resultMap" type="com.fdkankan.user.entity.VaildCameras">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="company_name" jdbcType="VARCHAR" property="companyName" />
  7. <result column="file_path" jdbcType="VARCHAR" property="filePath" />
  8. <result column="wifi_name" jdbcType="VARCHAR" property="wifiName" />
  9. <result column="devicemac" jdbcType="VARCHAR" property="devicemac" />
  10. <result column="rec_status" jdbcType="VARCHAR" property="recStatus" />
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  12. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  13. <result column="tb_status" jdbcType="INTEGER" property="tbStatus" />
  14. </resultMap>
  15. <sql id="columnList">
  16. id,company_name,file_path,wifi_name,devicemac,rec_status,create_time,update_time,tb_status </sql>
  17. <insert id="insert" useGeneratedKeys="true" keyProperty="entity.id">
  18. INSERT INTO ${tableName} (
  19. company_name, file_path, wifi_name, devicemac, rec_status
  20. ) VALUES (
  21. #{entity.companyName}, #{entity.filePath}, #{entity.wifiName}, #{entity.devicemac}, #{entity.recStatus}
  22. ) </insert>
  23. <insert id="insertByBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
  24. INSERT INTO ${tableName} (
  25. company_name, file_path, wifi_name, devicemac, rec_status
  26. ) VALUES
  27. <foreach collection="list" item="entity" index="index" separator=",">
  28. (#{entity.companyName}, #{entity.filePath}, #{entity.wifiName}, #{entity.devicemac}, #{entity.recStatus})
  29. </foreach>
  30. </insert>
  31. <update id="update" parameterType="java.util.List" >
  32. <foreach collection="list" item="entity" index="index" separator=";">
  33. UPDATE ${tableName} SET
  34. company_name=#{entity.companyName}, file_path=#{entity.filePath}, wifi_name=#{entity.wifiName}, devicemac=#{entity.devicemac}, rec_status=#{entity.recStatus}, tb_status=#{entity.tbStatus}
  35. WHERE
  36. id = #{entity.id}
  37. </foreach>
  38. </update>
  39. <update id="updateByBatch" >
  40. UPDATE ${tableName} SET
  41. ${field}
  42. <where>
  43. <foreach collection="condition" index="key" item="value">
  44. ${value} ${key}
  45. </foreach>
  46. </where>
  47. </update>
  48. <select id="getById" parameterType="java.lang.Integer" resultMap="resultMap">
  49. select
  50. <include refid="columnList" />
  51. from ${tableName}
  52. where id = #{id}
  53. </select>
  54. <select id="getOne" parameterType="java.util.Map" resultMap="resultMap">
  55. select
  56. <if test="field == null">
  57. <include refid="columnList" />
  58. </if>
  59. <if test="field != null">
  60. ${field}
  61. </if>
  62. from ${tableName}
  63. <where>
  64. <foreach collection="condition" index="key" item="value">
  65. ${value} ${key}
  66. </foreach>
  67. </where>
  68. limit 1;
  69. </select>
  70. <select id="getCount" parameterType="java.util.Map" resultType="java.lang.Integer">
  71. select
  72. count(id)
  73. from ${tableName}
  74. <where>
  75. <foreach collection="condition" index="key" item="value">
  76. ${value} ${key}
  77. </foreach>
  78. </where>
  79. </select>
  80. <!-- 这部分为根据传递参数,自动生成SQL -->
  81. <select id="getList" parameterType="java.util.Map" resultMap="resultMap">
  82. select
  83. <if test="field == null">
  84. <include refid="columnList" />
  85. </if>
  86. <if test="field != null">
  87. ${field}
  88. </if>
  89. from ${tableName}
  90. <where>
  91. <foreach collection="condition" index="key" item="value">
  92. ${value} ${key}
  93. </foreach>
  94. </where>
  95. <if test="order != null">
  96. order by ${order}
  97. </if>
  98. <if test="limit != 0">
  99. <if test="offset != 0">
  100. limit ${offset}, ${limit}
  101. </if>
  102. <if test="offset == 0">
  103. limit ${limit}
  104. </if>
  105. </if>
  106. </select>
  107. <!-- 判断表格是否存在,如果不存在可以配合createTable使用,用于动态创建表格 -->
  108. <select id="existTable" parameterType="String" resultType="java.lang.Integer">
  109. select count(table_name) from information_schema.TABLES WHERE table_name=#{tableName} ;
  110. </select>
  111. <update id="createTable" parameterType="String">
  112. <!-- 这里是创建表格的SQL,复制过来,表名作为参数传递 -->
  113. <!-- create table ${tableName} ( // 表名要这样写 -->
  114. </update>
  115. </mapper>