StationOilPriceMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.yijia.station.mapper.StationOilPriceMapper">
  6. <resultMap type="StationOilPrice" id="StationOilPriceResult">
  7. <result property="oilPriceId" column="oil_price_id" />
  8. <result property="oilName" column="oil_name" />
  9. <result property="oilPrice" column="oil_price" />
  10. <result property="stationId" column="station_id" />
  11. <result property="stationNanme" column="station_nanme" />
  12. <result property="date" column="date" />
  13. </resultMap>
  14. <sql id="selectStationOilPriceVo">
  15. select oil_price_id, oil_name, oil_price, station_id, station_nanme, date from station_oil_price
  16. </sql>
  17. <select id="selectStationOilPriceList" parameterType="StationOilPrice" resultMap="StationOilPriceResult">
  18. <include refid="selectStationOilPriceVo"/>
  19. <where>
  20. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  21. <if test="oilPrice != null and oilPrice != ''"> and oil_price = #{oilPrice}</if>
  22. <if test="stationId != null "> and station_id = #{stationId}</if>
  23. <if test="stationNanme != null and stationNanme != ''"> and station_nanme = #{stationNanme}</if>
  24. <if test="date != null "> and date = #{date}</if>
  25. <if test="stationIdList != null ">
  26. and station_id in
  27. <foreach item="item" index="index" collection="stationIdList"
  28. open="(" separator="," close=")">
  29. #{item}
  30. </foreach>
  31. </if>
  32. </where>
  33. </select>
  34. <select id="oilNameInfo" parameterType="StationOilPrice" resultMap="StationOilPriceResult">
  35. <include refid="selectStationOilPriceVo"/>
  36. <where>
  37. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  38. <if test="oilPrice != null and oilPrice != ''"> and oil_price = #{oilPrice}</if>
  39. <if test="stationId != null "> and station_id = #{stationId}</if>
  40. <if test="stationNanme != null and stationNanme != ''"> and station_nanme = #{stationNanme}</if>
  41. <if test="date != null "> and date = #{date}</if>
  42. <if test="stationIdList != null ">
  43. and station_id in
  44. <foreach item="item" index="index" collection="stationIdList"
  45. open="(" separator="," close=")">
  46. #{item}
  47. </foreach>
  48. </if>
  49. and oil_name!="非油品"
  50. </where>
  51. </select>
  52. <select id="selectStationOilPriceById" parameterType="Long" resultMap="StationOilPriceResult">
  53. <include refid="selectStationOilPriceVo"/>
  54. where oil_price_id = #{oilPriceId}
  55. </select>
  56. <insert id="insertStationOilPrice" parameterType="StationOilPrice" useGeneratedKeys="true" keyProperty="oilPriceId">
  57. insert into station_oil_price
  58. <trim prefix="(" suffix=")" suffixOverrides=",">
  59. <if test="oilName != null">oil_name,</if>
  60. <if test="oilPrice != null">oil_price,</if>
  61. <if test="stationId != null">station_id,</if>
  62. <if test="stationNanme != null">station_nanme,</if>
  63. <if test="date != null">date,</if>
  64. </trim>
  65. <trim prefix="values (" suffix=")" suffixOverrides=",">
  66. <if test="oilName != null">#{oilName},</if>
  67. <if test="oilPrice != null">#{oilPrice},</if>
  68. <if test="stationId != null">#{stationId},</if>
  69. <if test="stationNanme != null">#{stationNanme},</if>
  70. <if test="date != null">#{date},</if>
  71. </trim>
  72. </insert>
  73. <update id="updateStationOilPrice" parameterType="StationOilPrice">
  74. update station_oil_price
  75. <trim prefix="SET" suffixOverrides=",">
  76. <if test="oilName != null">oil_name = #{oilName},</if>
  77. <if test="oilPrice != null">oil_price = #{oilPrice},</if>
  78. <if test="stationId != null">station_id = #{stationId},</if>
  79. <if test="stationNanme != null">station_nanme = #{stationNanme},</if>
  80. <if test="date != null">date = #{date},</if>
  81. </trim>
  82. where oil_price_id = #{oilPriceId}
  83. </update>
  84. <delete id="deleteStationOilPriceById" parameterType="Long">
  85. delete from station_oil_price where oil_price_id = #{oilPriceId}
  86. </delete>
  87. <delete id="deleteStationOilPriceByIds" parameterType="String">
  88. delete from station_oil_price where oil_price_id in
  89. <foreach item="oilPriceId" collection="array" open="(" separator="," close=")">
  90. #{oilPriceId}
  91. </foreach>
  92. </delete>
  93. </mapper>