StationPersonnelMapper.xml 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.StationPersonnelMapper">
  6. <resultMap type="StationPersonnel" id="StationPersonnelResult">
  7. <result property="personnelId" column="personnel_id" />
  8. <result property="personnelName" column="personnel_name" />
  9. <result property="gunNo" column="gun_no" />
  10. <result property="stationId" column="station_id" />
  11. <result property="stationName" column="station_name" />
  12. <result property="qrCode" column="qr_code" />
  13. <result property="personnelPhone" column="personnel_phone" />
  14. </resultMap>
  15. <sql id="selectStationPersonnelVo">
  16. select personnel_id, personnel_name, gun_no, station_id, station_name, qr_code, personnel_phone from station_personnel
  17. </sql>
  18. <select id="selectStationPersonnelList" parameterType="StationPersonnel" resultMap="StationPersonnelResult">
  19. <include refid="selectStationPersonnelVo"/>
  20. <where>
  21. <if test="personnelName != null and personnelName != ''"> and personnel_name like concat('%', #{personnelName}, '%')</if>
  22. <if test="gunNo != null and gunNo != ''"> and gun_no = #{gunNo}</if>
  23. <if test="stationId != null "> and station_id = #{stationId}</if>
  24. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  25. <if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
  26. <if test="personnelPhone != null and personnelPhone != ''"> and personnel_phone = #{personnelPhone}</if>
  27. <if test="stationIdList != null ">
  28. and station_id in
  29. <foreach item="item" index="index" collection="stationIdList"
  30. open="(" separator="," close=")">
  31. #{item}
  32. </foreach>
  33. </if>
  34. </where>
  35. order by personnel_id desc
  36. </select>
  37. <select id="selectStationPersonnelById" parameterType="Long" resultMap="StationPersonnelResult">
  38. <include refid="selectStationPersonnelVo"/>
  39. where personnel_id = #{personnelId}
  40. </select>
  41. <insert id="insertStationPersonnel" parameterType="StationPersonnel">
  42. insert into station_personnel
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="personnelId != null">personnel_id,</if>
  45. <if test="personnelName != null">personnel_name,</if>
  46. <if test="gunNo != null">gun_no,</if>
  47. <if test="stationId != null">station_id,</if>
  48. <if test="stationName != null">station_name,</if>
  49. <if test="qrCode != null">qr_code,</if>
  50. <if test="personnelPhone != null">personnel_phone,</if>
  51. </trim>
  52. <trim prefix="values (" suffix=")" suffixOverrides=",">
  53. <if test="personnelId != null">#{personnelId},</if>
  54. <if test="personnelName != null">#{personnelName},</if>
  55. <if test="gunNo != null">#{gunNo},</if>
  56. <if test="stationId != null">#{stationId},</if>
  57. <if test="stationName != null">#{stationName},</if>
  58. <if test="qrCode != null">#{qrCode},</if>
  59. <if test="personnelPhone != null">#{personnelPhone},</if>
  60. </trim>
  61. </insert>
  62. <update id="updateStationPersonnel" parameterType="StationPersonnel">
  63. update station_personnel
  64. <trim prefix="SET" suffixOverrides=",">
  65. <if test="personnelName != null">personnel_name = #{personnelName},</if>
  66. <if test="gunNo != null">gun_no = #{gunNo},</if>
  67. <if test="stationId != null">station_id = #{stationId},</if>
  68. <if test="stationName != null">station_name = #{stationName},</if>
  69. <if test="qrCode != null">qr_code = #{qrCode},</if>
  70. <if test="personnelPhone != null">personnel_phone = #{personnelPhone},</if>
  71. </trim>
  72. where personnel_id = #{personnelId}
  73. </update>
  74. <delete id="deleteStationPersonnelById" parameterType="Long">
  75. delete from station_personnel where personnel_id = #{personnelId}
  76. </delete>
  77. <delete id="deleteStationPersonnelByIds" parameterType="String">
  78. delete from station_personnel where personnel_id in
  79. <foreach item="personnelId" collection="array" open="(" separator="," close=")">
  80. #{personnelId}
  81. </foreach>
  82. </delete>
  83. </mapper>