ReceiverInfoMapper.xml 5.3 KB

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