StationPersonnelMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. <result property="delFlag" column="del_flag" />
  15. </resultMap>
  16. <sql id="selectStationPersonnelVo">
  17. select personnel_id, personnel_name, gun_no, station_id, d.dept_name as station_name, qr_code, personnel_phone,p.del_flag
  18. from station_personnel p join sys_dept d on p.station_id = d.dept_id
  19. </sql>
  20. <select id="selectStationPersonnelList" parameterType="StationPersonnel" resultMap="StationPersonnelResult">
  21. <include refid="selectStationPersonnelVo"/>
  22. where p.del_flag ='0'
  23. <if test="personnelName != null and personnelName != ''"> and p.personnel_name like concat('%', #{personnelName}, '%')</if>
  24. <if test="gunNo != null and gunNo != ''"> and p.gun_no = #{gunNo}</if>
  25. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  26. <if test="stationName != null and stationName != ''"> and d.dept_name like concat('%', #{stationName}, '%')</if>
  27. <if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
  28. <if test="personnelPhone != null and personnelPhone != ''"> and personnel_phone = #{personnelPhone}</if>
  29. <if test="stationIdList != null ">
  30. and p.station_id in
  31. <foreach item="item" index="index" collection="stationIdList"
  32. open="(" separator="," close=")">
  33. #{item}
  34. </foreach>
  35. </if>
  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. <if test="delFlag != null">del_flag,</if>
  52. </trim>
  53. <trim prefix="values (" suffix=")" suffixOverrides=",">
  54. <if test="personnelId != null">#{personnelId},</if>
  55. <if test="personnelName != null">#{personnelName},</if>
  56. <if test="gunNo != null">#{gunNo},</if>
  57. <if test="stationId != null">#{stationId},</if>
  58. <if test="qrCode != null">#{qrCode},</if>
  59. <if test="personnelPhone != null">#{personnelPhone},</if>
  60. <if test="delFlag != null">#{delFlag},</if>
  61. </trim>
  62. </insert>
  63. <update id="updateStationPersonnel" parameterType="StationPersonnel">
  64. update station_personnel
  65. <trim prefix="SET" suffixOverrides=",">
  66. <if test="personnelName != null">personnel_name = #{personnelName},</if>
  67. <if test="gunNo != null">gun_no = #{gunNo},</if>
  68. <if test="stationId != null">station_id = #{stationId},</if>
  69. <if test="qrCode != null">qr_code = #{qrCode},</if>
  70. <if test="personnelPhone != null">personnel_phone = #{personnelPhone},</if>
  71. <if test="delFlag != null">del_flag = #{delFlag},</if>
  72. </trim>
  73. where personnel_id = #{personnelId}
  74. </update>
  75. <delete id="deleteStationPersonnelById" parameterType="Long">
  76. delete from station_personnel where personnel_id = #{personnelId}
  77. </delete>
  78. <delete id="deleteStationPersonnelByIds" parameterType="String">
  79. update station_personnel set del_flag = '1' where personnel_id in
  80. <foreach collection="array" item="personnelId" open="(" separator="," close=")">
  81. #{personnelId}
  82. </foreach>
  83. </delete>
  84. </mapper>