AgentAuditMapper.xml 5.9 KB

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