StationPersonnelMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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, d.dept_name as station_name, qr_code, personnel_phone
  17. from station_personnel p join sys_dept d on p.station_id = d.dept_id
  18. </sql>
  19. <select id="selectStationPersonnelList" parameterType="StationPersonnel" resultMap="StationPersonnelResult">
  20. <include refid="selectStationPersonnelVo"/>
  21. <where>
  22. <if test="personnelName != null and personnelName != ''"> and personnel_name like concat('%', #{personnelName}, '%')</if>
  23. <if test="gunNo != null and gunNo != ''"> and gun_no = #{gunNo}</if>
  24. <if test="stationId != null "> and station_id = #{stationId}</if>
  25. <if test="stationName != null and stationName != ''"> and d.dept_name like concat('%', #{stationName}, '%')</if>
  26. <if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
  27. <if test="personnelPhone != null and personnelPhone != ''"> and personnel_phone = #{personnelPhone}</if>
  28. <if test="stationIdList != null ">
  29. and station_id in
  30. <foreach item="item" index="index" collection="stationIdList"
  31. open="(" separator="," close=")">
  32. #{item}
  33. </foreach>
  34. </if>
  35. </where>
  36. order by personnel_id desc
  37. </select>
  38. <select id="selectStationPersonnelById" parameterType="Long" resultMap="StationPersonnelResult">
  39. <include refid="selectStationPersonnelVo"/>
  40. where personnel_id = #{personnelId}
  41. </select>
  42. <insert id="insertStationPersonnel" parameterType="StationPersonnel">
  43. insert into station_personnel
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="personnelId != null">personnel_id,</if>
  46. <if test="personnelName != null">personnel_name,</if>
  47. <if test="gunNo != null">gun_no,</if>
  48. <if test="stationId != null">station_id,</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="qrCode != null">#{qrCode},</if>
  58. <if test="personnelPhone != null">#{personnelPhone},</if>
  59. </trim>
  60. </insert>
  61. <update id="updateStationPersonnel" parameterType="StationPersonnel">
  62. update station_personnel
  63. <trim prefix="SET" suffixOverrides=",">
  64. <if test="personnelName != null">personnel_name = #{personnelName},</if>
  65. <if test="gunNo != null">gun_no = #{gunNo},</if>
  66. <if test="stationId != null">station_id = #{stationId},</if>
  67. <if test="qrCode != null">qr_code = #{qrCode},</if>
  68. <if test="personnelPhone != null">personnel_phone = #{personnelPhone},</if>
  69. </trim>
  70. where personnel_id = #{personnelId}
  71. </update>
  72. <delete id="deleteStationPersonnelById" parameterType="Long">
  73. delete from station_personnel where personnel_id = #{personnelId}
  74. </delete>
  75. <delete id="deleteStationPersonnelByIds" parameterType="String">
  76. delete from station_personnel where personnel_id in
  77. <foreach item="personnelId" collection="array" open="(" separator="," close=")">
  78. #{personnelId}
  79. </foreach>
  80. </delete>
  81. </mapper>