UserIncrementMapper.xml 5.2 KB

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