LiveGoodsMapperMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.biz.dal.dao.LiveGoodsMapperDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.LiveGoodsMapper" id="LiveGoodsMapper">
  9. <result column="id_" property="id" />
  10. <result column="goods_id_" property="goodsId" />
  11. <result column="live_id_" property="liveId" />
  12. <result column="sell_count_" property="sellCount" />
  13. <result column="status_" property="status" />
  14. <result column="create_time_" property="createTime" />
  15. <result column="update_time_" property="updateTime" />
  16. </resultMap>
  17. <!-- 根据主键查询一条记录 -->
  18. <select id="get" resultMap="LiveGoodsMapper" >
  19. SELECT * FROM live_goods_mapper WHERE id_ = #{id}
  20. </select>
  21. <!-- 全查询 -->
  22. <select id="findAll" resultMap="LiveGoodsMapper">
  23. SELECT * FROM live_goods_mapper ORDER BY id_
  24. </select>
  25. <!-- 向数据库增加一条记录 -->
  26. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LiveGoodsMapper" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  27. INSERT INTO live_goods_mapper (goods_id_,live_id_,sell_count_,status_,create_time_,update_time_)
  28. VALUES(#{goodsId},#{liveId},#{sellCount},#{status},NOW(),NOW())
  29. </insert>
  30. <!-- 根据主键查询一条记录 -->
  31. <update id="update" parameterType="com.ym.mec.biz.dal.entity.LiveGoodsMapper">
  32. UPDATE live_goods_mapper <set>
  33. <if test="status != null">
  34. status_ = #{status},
  35. </if>
  36. <if test="liveId != null">
  37. live_id_ = #{liveId},
  38. </if>
  39. <if test="sellCount != null">
  40. sell_count_ = #{sellCount},
  41. </if>
  42. <if test="goodsId != null">
  43. goods_id_ = #{goodsId},
  44. </if>
  45. update_time_ = NOW()
  46. </set> WHERE id_ = #{id}
  47. </update>
  48. <update id="updateStatus">
  49. UPDATE live_goods_mapper SET status_ = #{status},update_time_ = NOW()
  50. WHERE id_ = #{liveGoodsId}
  51. <if test="liveId != null and liveId != ''">
  52. AND live_id_ = #{liveId}
  53. </if>
  54. </update>
  55. <!-- 根据主键删除一条记录 -->
  56. <delete id="delete" >
  57. DELETE FROM live_goods_mapper WHERE id_ = #{id}
  58. </delete>
  59. <sql id="queryPageSql">
  60. <where>
  61. <if test="liveId != null and liveId != ''">
  62. AND lgm.live_id_ = #{liveId}
  63. </if>
  64. <if test="search != null and search != ''">
  65. AND (lg.name_ LIKE '%${search}%' OR lg.id_ = ${search})
  66. </if>
  67. <if test="status != null">
  68. AND lgm.status_ = #{status}
  69. </if>
  70. </where>
  71. </sql>
  72. <!-- 分页查询 -->
  73. <select id="queryPage" resultMap="LiveGoodsMapper" parameterType="map">
  74. SELECT lg.*,lg.status_ FROM live_goods_mapper lgm
  75. LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
  76. <include refid="queryPageSql" />
  77. ORDER BY lgm.id_
  78. <include refid="global.limit"/>
  79. </select>
  80. <!-- 查询当前表的总记录数 -->
  81. <select id="queryCount" resultType="int">
  82. SELECT COUNT(lgm.id_) FROM live_goods_mapper lgm
  83. LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
  84. <include refid="queryPageSql" />
  85. </select>
  86. <select id="findByLiveGoodsIdAndStatus" resultMap="LiveGoodsMapper">
  87. SELECT * FROM live_goods_mapper WHERE goods_id_ = #{goodsId} AND status_ = #{status}
  88. </select>
  89. <select id="findByLiveIdAndGoodsId" resultMap="LiveGoodsMapper">
  90. SELECT * FROM live_goods_mapper WHERE live_id_ = #{liveId} AND goods_id_ = #{goodsId}
  91. </select>
  92. <resultMap id="LiveGoodsMapperDto" type="com.ym.mec.biz.dal.dto.LiveGoodsMapperDto">
  93. <result column="id_" property="id" />
  94. <result column="image_" property="image" />
  95. <result column="sell_count_" property="sellCount" />
  96. <result column="status_" property="status" />
  97. <result column="name_" property="name" />
  98. <result column="original_price_" property="originalPrice" />
  99. <result column="current_price_" property="currentPrice" />
  100. <result column="brief_" property="brief" />
  101. <result column="desc_" property="desc" />
  102. <result column="memo_" property="memo" />
  103. </resultMap>
  104. <select id="getLiveGoodsList" resultMap="LiveGoodsMapperDto">
  105. SELECT lg.id_,lg.image_,lgm.sell_count_,
  106. lgm.status_,lg.name_,lg.original_price_,lg.current_price_,lg.brief_,lg.desc_,lg.memo_
  107. FROM live_goods_mapper lgm
  108. LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
  109. WHERE lgm.live_id_ = #{liveId}
  110. </select>
  111. </mapper>