SpaceSdkMapper.xml 5.0 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.ISpaceSdkMapper">
  4. <resultMap id="resultMap" type="com.fdkankan.user.entity.SpaceSdk">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="version" jdbcType="VARCHAR" property="version" />
  7. <result column="imprint_ch" jdbcType="VARCHAR" property="imprintCh" />
  8. <result column="imprint_en" jdbcType="VARCHAR" property="imprintEn" />
  9. <result column="publish_time" jdbcType="TIMESTAMP" property="publishTime" />
  10. <result column="is_top" jdbcType="INTEGER" property="isTop" />
  11. <result column="status" jdbcType="INTEGER" property="status" />
  12. <result column="platform_type" jdbcType="VARCHAR" property="platformType" />
  13. <result column="file_name" jdbcType="VARCHAR" property="fileName" />
  14. <result column="file_url" jdbcType="VARCHAR" property="fileUrl" />
  15. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  16. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  17. <result column="rec_status" jdbcType="VARCHAR" property="recStatus" />
  18. <result column="tb_status" jdbcType="INTEGER" property="tbStatus" />
  19. </resultMap>
  20. <sql id="columnList">
  21. id,version,imprint_ch,imprint_en,publish_time,is_top,status,platform_type,file_name,file_url,create_time,update_time,rec_status,tb_status </sql>
  22. <insert id="insert" useGeneratedKeys="true" keyProperty="entity.id">
  23. INSERT INTO ${tableName} (
  24. version, imprint_ch, imprint_en, publish_time, is_top, status, platform_type, file_name, file_url, rec_status
  25. ) VALUES (
  26. #{entity.version}, #{entity.imprintCh}, #{entity.imprintEn}, #{entity.publishTime}, #{entity.isTop}, #{entity.status}, #{entity.platformType}, #{entity.fileName}, #{entity.fileUrl}, #{entity.recStatus}
  27. ) </insert>
  28. <insert id="insertByBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
  29. INSERT INTO ${tableName} (
  30. version, imprint_ch, imprint_en, publish_time, is_top, status, platform_type, file_name, file_url, rec_status
  31. ) VALUES
  32. <foreach collection="list" item="entity" index="index" separator=",">
  33. (#{entity.version}, #{entity.imprintCh}, #{entity.imprintEn}, #{entity.publishTime}, #{entity.isTop}, #{entity.status}, #{entity.platformType}, #{entity.fileName}, #{entity.fileUrl}, #{entity.recStatus})
  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. version=#{entity.version}, imprint_ch=#{entity.imprintCh}, imprint_en=#{entity.imprintEn}, publish_time=#{entity.publishTime}, is_top=#{entity.isTop}, status=#{entity.status}, platform_type=#{entity.platformType}, file_name=#{entity.fileName}, file_url=#{entity.fileUrl}, rec_status=#{entity.recStatus}, 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>