IntercomMessageMapper.xml 4.6 KB

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