SaleStatementMapper.xml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.example.mapper.SaleStatementMapper">
  6. <sql id="Base_Column_List">
  7. id,shop_id,count,time_over,product_id,amount
  8. </sql>
  9. <select id="selectAll" resultType="com.example.entity.SaleStatement">
  10. select
  11. <include refid="Base_Column_List" />
  12. from sale_statement
  13. <where>
  14. <if test="id != null"> and id = #{id}</if>
  15. <if test="shopId != null"> and shop_id = #{shopId}</if>
  16. <if test="count != null"> and count = #{count}</if>
  17. <if test="timeOver != null"> and time_over like concat('%', #{timeOver}, '%')</if>
  18. <if test="productId != null"> and product_id = #{productId}</if>
  19. <if test="amount != null"> and amount = #{amount}</if>
  20. </where>
  21. order by id desc
  22. </select>
  23. <select id="selectById" resultType="com.example.entity.SaleStatement">
  24. select
  25. <include refid="Base_Column_List" />
  26. from sale_statement
  27. where id = #{id}
  28. </select>
  29. <delete id="deleteById">
  30. delete from sale_statement
  31. where id = #{id}
  32. </delete>
  33. <insert id="insert" parameterType="com.example.entity.SaleStatement" useGeneratedKeys="true">
  34. insert into sale_statement
  35. <trim prefix="(" suffix=")" suffixOverrides=",">
  36. <if test="id != null">id,</if>
  37. <if test="shopId != null">shop_id,</if>
  38. <if test="count != null">count,</if>
  39. <if test="timeOver != null">time_over,</if>
  40. <if test="productId != null">product_id,</if>
  41. <if test="amount != null">amount,</if>
  42. </trim>
  43. <trim prefix="values (" suffix=")" suffixOverrides=",">
  44. <if test="id != null">#{id},</if>
  45. <if test="shopId != null">#{shopId},</if>
  46. <if test="count != null">#{count},</if>
  47. <if test="timeOver != null">#{timeOver},</if>
  48. <if test="productId != null">#{productId},</if>
  49. <if test="amount != null">#{amount},</if>
  50. </trim>
  51. </insert>
  52. <update id="updateById" parameterType="com.example.entity.SaleStatement">
  53. update sale_statement
  54. <set>
  55. <if test="shopId != null">
  56. shop_id = #{shopId},
  57. </if>
  58. <if test="count != null">
  59. count = #{count},
  60. </if>
  61. <if test="timeOver != null">
  62. time_over = #{timeOver},
  63. </if>
  64. <if test="productId != null">
  65. product_id = #{productId},
  66. </if>
  67. <if test="amount != null">
  68. amount = #{amount},
  69. </if>
  70. </set>
  71. where id = #{id}
  72. </update>
  73. </mapper>