StationOilGunMapper.xml 3.6 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.yijia.station.mapper.StationOilGunMapper">
  6. <resultMap type="StationOilGun" id="StationOilGunResult">
  7. <result property="oilGunId" column="oil_gun_id" />
  8. <result property="oilGunNo" column="oil_gun_no" />
  9. <result property="oilName" column="oil_name" />
  10. <result property="oilPrice" column="oil_price" />
  11. <result property="stationId" column="station_id" />
  12. <result property="stationName" column="station_name" />
  13. <result property="date" column="date" />
  14. </resultMap>
  15. <select id="selectStationOilGunList" parameterType="StationOilGun" resultMap="StationOilGunResult">
  16. select oil_gun_id, oil_gun_no, oil_name, oil_price, station_id,d.dept_name as station_name, date
  17. from station_oil_gun g join sys_dept d on g.station_id =d.dept_id
  18. <where>
  19. <if test="oilGunNo != null and oilGunNo != ''"> and g.oil_gun_no = #{oilGunNo}</if>
  20. <if test="stationId != null "> and station_id = #{stationId}</if>
  21. <if test="stationIdList != null ">
  22. and station_id in
  23. <foreach item="item" index="index" collection="stationIdList"
  24. open="(" separator="," close=")">
  25. #{item}
  26. </foreach>
  27. </if>
  28. </where>
  29. </select>
  30. <select id="selectStationOilGunById" parameterType="Long" resultMap="StationOilGunResult">
  31. select oil_gun_id, oil_gun_no, oil_name, oil_price, station_id,d.dept_name as station_name, date
  32. from station_oil_gun g join sys_dept d on g.station_id =d.dept_id
  33. where g.oil_gun_id = #{oilGunId}
  34. </select>
  35. <insert id="insertStationOilGun" parameterType="StationOilGun" useGeneratedKeys="true" keyProperty="oilGunId">
  36. insert into station_oil_gun
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="oilGunNo != null">oil_gun_no,</if>
  39. <if test="oilName != null">oil_name,</if>
  40. <if test="oilPrice != null">oil_price,</if>
  41. <if test="stationId != null">station_id,</if>
  42. <if test="date != null">date,</if>
  43. </trim>
  44. <trim prefix="values (" suffix=")" suffixOverrides=",">
  45. <if test="oilGunNo != null">#{oilGunNo},</if>
  46. <if test="oilName != null">#{oilName},</if>
  47. <if test="oilPrice != null">#{oilPrice},</if>
  48. <if test="stationId != null">#{stationId},</if>
  49. <if test="date != null">#{date},</if>
  50. </trim>
  51. </insert>
  52. <update id="updateStationOilGun" parameterType="StationOilGun">
  53. update station_oil_gun
  54. <trim prefix="SET" suffixOverrides=",">
  55. <if test="oilGunNo != null">oil_gun_no = #{oilGunNo},</if>
  56. <if test="oilName != null">oil_name = #{oilName},</if>
  57. <if test="oilPrice != null">oil_price = #{oilPrice},</if>
  58. <if test="stationId != null">station_id = #{stationId},</if>
  59. <if test="date != null">date = #{date},</if>
  60. </trim>
  61. where oil_gun_id = #{oilGunId}
  62. </update>
  63. <delete id="deleteStationOilGunById" parameterType="Long">
  64. delete from station_oil_gun where oil_gun_id = #{oilGunId}
  65. </delete>
  66. <delete id="deleteStationOilGunByIds" parameterType="String">
  67. delete from station_oil_gun where oil_gun_id in
  68. <foreach item="oilGunId" collection="array" open="(" separator="," close=")">
  69. #{oilGunId}
  70. </foreach>
  71. </delete>
  72. </mapper>