GoodsMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.web.dal.dao.GoodsDao">
  8. <resultMap type="com.ym.mec.web.dal.entity.Goods" id="Goods">
  9. <result column="id_" property="id"/>
  10. <result column="goods_category_id_" property="goodsCategoryId"/>
  11. <result column="sn_" property="sn"/>
  12. <result column="name_" property="name"/>
  13. <result column="brand_" property="brand"/>
  14. <result column="specification_" property="specification"/>
  15. <result column="image_" property="image"/>
  16. <result column="stock_count_" property="stockCount"/>
  17. <result column="sell_count_" property="sellCount"/>
  18. <result column="market_price_" property="marketPrice"/>
  19. <result column="discount_price_" property="discountPrice"/>
  20. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  21. <result column="brief_" property="brief"/>
  22. <result column="desc_" property="desc"/>
  23. <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  24. <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  25. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  26. <result column="memo_" property="memo"/>
  27. <result column="publish_time_" property="publishTime"/>
  28. <result column="create_time_" property="createTime"/>
  29. <result column="update_time_" property="updateTime"/>
  30. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  31. </resultMap>
  32. <!-- 根据主键查询一条记录 -->
  33. <select id="get" resultMap="Goods">
  34. SELECT * FROM goods WHERE id_ = #{id}
  35. </select>
  36. <!-- 全查询 -->
  37. <select id="findAll" resultMap="Goods">
  38. SELECT * FROM goods ORDER BY id_
  39. </select>
  40. <!-- 向数据库增加一条记录 -->
  41. <insert id="insert" parameterType="com.ym.mec.web.dal.entity.Goods" useGeneratedKeys="true" keyColumn="id"
  42. keyProperty="id">
  43. INSERT INTO goods
  44. (id_,goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,sell_count_,market_price_,discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,complement_goods_id_list_,update_time_,create_time_)
  45. VALUES(#{id},#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{sellCount},#{marketPrice},#{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
  46. #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},#{publishTime},#{complementGoodsIdList},now(),now())
  47. </insert>
  48. <!-- 根据主键查询一条记录 -->
  49. <update id="update" parameterType="com.ym.mec.web.dal.entity.Goods">
  50. UPDATE goods
  51. <set>
  52. <if test="specification != null">
  53. specification_ = #{specification},
  54. </if>
  55. <if test="status != null">
  56. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  57. </if>
  58. <if test="isTop != null">
  59. is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  60. </if>
  61. <if test="sn != null">
  62. sn_ = #{sn},
  63. </if>
  64. <if test="marketPrice != null">
  65. market_price_ = #{marketPrice},
  66. </if>
  67. <if test="memo != null">
  68. memo_ = #{memo},
  69. </if>
  70. <if test="isNew != null">
  71. is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  72. </if>
  73. <if test="groupPurchasePrice != null">
  74. group_purchase_price_ = #{groupPurchasePrice},
  75. </if>
  76. <if test="name != null">
  77. name_ = #{name},
  78. </if>
  79. <if test="stockCount != null">
  80. stock_count_ = #{stockCount},
  81. </if>
  82. <if test="goodsCategoryId != null">
  83. goods_category_id_ = #{goodsCategoryId},
  84. </if>
  85. <if test="brand != null">
  86. brand_ = #{brand},
  87. </if>
  88. <if test="brief != null">
  89. brief_ = #{brief},
  90. </if>
  91. <if test="updateTime != null">
  92. update_time_ = #{updateTime},
  93. </if>
  94. <if test="discountPrice != null">
  95. discount_price_ = #{discountPrice},
  96. </if>
  97. <if test="sellCount != null">
  98. sell_count_ = #{sellCount},
  99. </if>
  100. <if test="image != null">
  101. image_ = #{image},
  102. </if>
  103. <if test="desc != null">
  104. desc_ = #{desc},
  105. </if>
  106. <if test="publishTime != null">
  107. publish_time_ = #{publishTime},
  108. </if>
  109. <if test="complementGoodsIdList != null">
  110. complement_goods_id_list_ = #{complementGoodsIdList},
  111. </if>
  112. </set>
  113. WHERE id_ = #{id}
  114. </update>
  115. <!-- 根据主键删除一条记录 -->
  116. <delete id="delete">
  117. DELETE FROM goods WHERE id_ = #{id}
  118. </delete>
  119. <!-- 分页查询 -->
  120. <select id="queryPage" resultMap="Goods" parameterType="map">
  121. SELECT * FROM goods ORDER BY id_
  122. <include refid="global.limit"/>
  123. </select>
  124. <!-- 查询当前表的总记录数 -->
  125. <select id="queryCount" resultType="int">
  126. SELECT COUNT(*) FROM goods
  127. </select>
  128. <select id="findGoodsBySubId" resultMap="Goods">
  129. SELECT g.* FROM subject_goods_mapper sgm LEFT JOIN goods g ON sgm.goods_id_ = g.id_
  130. WHERE sgm.subject_id_ = #{subjectId} AND g.goods_category_id_ = #{goodsCategoryId}
  131. </select>
  132. <!-- 根据 -->
  133. <select id="findGoodsNumByCategoryId" resultType="int">
  134. SELECT COUNT(*) FROM goods WHERE goods_category_id_ = #{goodsCategoryId}
  135. </select>
  136. </mapper>