ProductMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.how2java.tmall.mapper.ProductMapper">
  4. <resultMap id="BaseResultMap" type="com.how2java.tmall.pojo.Product">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="name" jdbcType="VARCHAR" property="name" />
  7. <result column="subTitle" jdbcType="VARCHAR" property="subTitle" />
  8. <result column="originalPrice" jdbcType="REAL" property="originalPrice" />
  9. <result column="promotePrice" jdbcType="REAL" property="promotePrice" />
  10. <result column="stock" jdbcType="INTEGER" property="stock" />
  11. <result column="cid" jdbcType="INTEGER" property="cid" />
  12. <result column="createDate" jdbcType="TIMESTAMP" property="createDate" />
  13. </resultMap>
  14. <sql id="Example_Where_Clause">
  15. <where>
  16. <foreach collection="oredCriteria" item="criteria" separator="or">
  17. <if test="criteria.valid">
  18. <trim prefix="(" prefixOverrides="and" suffix=")">
  19. <foreach collection="criteria.criteria" item="criterion">
  20. <choose>
  21. <when test="criterion.noValue">
  22. and ${criterion.condition}
  23. </when>
  24. <when test="criterion.singleValue">
  25. and ${criterion.condition} #{criterion.value}
  26. </when>
  27. <when test="criterion.betweenValue">
  28. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  29. </when>
  30. <when test="criterion.listValue">
  31. and ${criterion.condition}
  32. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  33. #{listItem}
  34. </foreach>
  35. </when>
  36. </choose>
  37. </foreach>
  38. </trim>
  39. </if>
  40. </foreach>
  41. </where>
  42. </sql>
  43. <sql id="Base_Column_List">
  44. id, name, subTitle, originalPrice, promotePrice, stock, cid, createDate
  45. </sql>
  46. <select id="selectByExample" parameterType="com.how2java.tmall.pojo.ProductExample" resultMap="BaseResultMap">
  47. select
  48. <if test="distinct">
  49. distinct
  50. </if>
  51. 'false' as QUERYID,
  52. <include refid="Base_Column_List" />
  53. from product
  54. <if test="_parameter != null">
  55. <include refid="Example_Where_Clause" />
  56. </if>
  57. <if test="orderByClause != null">
  58. order by ${orderByClause}
  59. </if>
  60. </select>
  61. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  62. select
  63. <include refid="Base_Column_List" />
  64. from product
  65. where id = #{id,jdbcType=INTEGER}
  66. </select>
  67. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  68. delete from product
  69. where id = #{id,jdbcType=INTEGER}
  70. </delete>
  71. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.how2java.tmall.pojo.Product" useGeneratedKeys="true">
  72. insert into product (name, subTitle, originalPrice,
  73. promotePrice, stock, cid,
  74. createDate)
  75. values (#{name,jdbcType=VARCHAR}, #{subTitle,jdbcType=VARCHAR}, #{originalPrice,jdbcType=REAL},
  76. #{promotePrice,jdbcType=REAL}, #{stock,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER},
  77. #{createDate,jdbcType=TIMESTAMP})
  78. </insert>
  79. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.how2java.tmall.pojo.Product" useGeneratedKeys="true">
  80. insert into product
  81. <trim prefix="(" suffix=")" suffixOverrides=",">
  82. <if test="name != null">
  83. name,
  84. </if>
  85. <if test="subTitle != null">
  86. subTitle,
  87. </if>
  88. <if test="originalPrice != null">
  89. originalPrice,
  90. </if>
  91. <if test="promotePrice != null">
  92. promotePrice,
  93. </if>
  94. <if test="stock != null">
  95. stock,
  96. </if>
  97. <if test="cid != null">
  98. cid,
  99. </if>
  100. <if test="createDate != null">
  101. createDate,
  102. </if>
  103. </trim>
  104. <trim prefix="values (" suffix=")" suffixOverrides=",">
  105. <if test="name != null">
  106. #{name,jdbcType=VARCHAR},
  107. </if>
  108. <if test="subTitle != null">
  109. #{subTitle,jdbcType=VARCHAR},
  110. </if>
  111. <if test="originalPrice != null">
  112. #{originalPrice,jdbcType=REAL},
  113. </if>
  114. <if test="promotePrice != null">
  115. #{promotePrice,jdbcType=REAL},
  116. </if>
  117. <if test="stock != null">
  118. #{stock,jdbcType=INTEGER},
  119. </if>
  120. <if test="cid != null">
  121. #{cid,jdbcType=INTEGER},
  122. </if>
  123. <if test="createDate != null">
  124. #{createDate,jdbcType=TIMESTAMP},
  125. </if>
  126. </trim>
  127. </insert>
  128. <update id="updateByPrimaryKeySelective" parameterType="com.how2java.tmall.pojo.Product">
  129. update product
  130. <set>
  131. <if test="name != null">
  132. name = #{name,jdbcType=VARCHAR},
  133. </if>
  134. <if test="subTitle != null">
  135. subTitle = #{subTitle,jdbcType=VARCHAR},
  136. </if>
  137. <if test="originalPrice != null">
  138. originalPrice = #{originalPrice,jdbcType=REAL},
  139. </if>
  140. <if test="promotePrice != null">
  141. promotePrice = #{promotePrice,jdbcType=REAL},
  142. </if>
  143. <if test="stock != null">
  144. stock = #{stock,jdbcType=INTEGER},
  145. </if>
  146. <if test="cid != null">
  147. cid = #{cid,jdbcType=INTEGER},
  148. </if>
  149. <if test="createDate != null">
  150. createDate = #{createDate,jdbcType=TIMESTAMP},
  151. </if>
  152. </set>
  153. where id = #{id,jdbcType=INTEGER}
  154. </update>
  155. <update id="updateByPrimaryKey" parameterType="com.how2java.tmall.pojo.Product">
  156. update product
  157. set name = #{name,jdbcType=VARCHAR},
  158. subTitle = #{subTitle,jdbcType=VARCHAR},
  159. originalPrice = #{originalPrice,jdbcType=REAL},
  160. promotePrice = #{promotePrice,jdbcType=REAL},
  161. stock = #{stock,jdbcType=INTEGER},
  162. cid = #{cid,jdbcType=INTEGER},
  163. createDate = #{createDate,jdbcType=TIMESTAMP}
  164. where id = #{id,jdbcType=INTEGER}
  165. </update>
  166. </mapper>