OrderItemMapper.xml 5.2 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.order.mapper.IOrderItemMapper">
  4. <resultMap id="resultMap" type="com.fdkankan.order.entity.OrderItem">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="goods_name" jdbcType="VARCHAR" property="goodsName" />
  7. <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
  8. <result column="goods_count" jdbcType="INTEGER" property="goodsCount" />
  9. <result column="goods_sn" jdbcType="VARCHAR" property="goodsSn" />
  10. <result column="sku_sn" jdbcType="VARCHAR" property="skuSn" />
  11. <result column="goods_id" jdbcType="VARCHAR" property="goodsId" />
  12. <result column="order_id" jdbcType="VARCHAR" property="orderId" />
  13. <result column="express_name" jdbcType="VARCHAR" property="expressName" />
  14. <result column="express_num" jdbcType="VARCHAR" property="expressNum" />
  15. <result column="shipping_status" jdbcType="VARCHAR" property="shippingStatus" />
  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,goods_name,goods_price,goods_count,goods_sn,sku_sn,goods_id,order_id,express_name,express_num,shipping_status,create_time,rec_status,update_time,tb_status </sql>
  23. <insert id="insert" useGeneratedKeys="true" keyProperty="entity.id">
  24. INSERT INTO ${tableName} (
  25. goods_name, goods_price, goods_count, goods_sn, sku_sn, goods_id, order_id, express_name, express_num, shipping_status, rec_status
  26. ) VALUES (
  27. #{entity.goodsName}, #{entity.goodsPrice}, #{entity.goodsCount}, #{entity.goodsSn}, #{entity.skuSn}, #{entity.goodsId}, #{entity.orderId}, #{entity.expressName}, #{entity.expressNum}, #{entity.shippingStatus}, #{entity.recStatus}
  28. ) </insert>
  29. <insert id="insertByBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
  30. INSERT INTO ${tableName} (
  31. goods_name, goods_price, goods_count, goods_sn, sku_sn, goods_id, order_id, express_name, express_num, shipping_status, rec_status
  32. ) VALUES
  33. <foreach collection="list" item="entity" index="index" separator=",">
  34. (#{entity.goodsName}, #{entity.goodsPrice}, #{entity.goodsCount}, #{entity.goodsSn}, #{entity.skuSn}, #{entity.goodsId}, #{entity.orderId}, #{entity.expressName}, #{entity.expressNum}, #{entity.shippingStatus}, #{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. goods_name=#{entity.goodsName}, goods_price=#{entity.goodsPrice}, goods_count=#{entity.goodsCount}, goods_sn=#{entity.goodsSn}, sku_sn=#{entity.skuSn}, goods_id=#{entity.goodsId}, order_id=#{entity.orderId}, express_name=#{entity.expressName}, express_num=#{entity.expressNum}, shipping_status=#{entity.shippingStatus}, 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>