QwDeptMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.fs.qw.mapper.QwDeptMapper">
  6. <resultMap type="QwDept" id="QwDeptResult">
  7. <result property="id" column="id" />
  8. <result property="deptId" column="dept_id" />
  9. <result property="deptName" column="dept_name" />
  10. <result property="parentid" column="parentid" />
  11. <result property="companyId" column="company_id" />
  12. <result property="corpId" column="corp_id" />
  13. </resultMap>
  14. <sql id="selectQwDeptVo">
  15. select id, dept_id, dept_name, parentid, company_id, corp_id from qw_dept
  16. </sql>
  17. <select id="selectQwDeptList" parameterType="QwDept" resultMap="QwDeptResult">
  18. <include refid="selectQwDeptVo"/>
  19. <where>
  20. <if test="deptId != null "> and dept_id = #{deptId}</if>
  21. <if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
  22. <if test="parentid != null "> and parentid = #{parentid}</if>
  23. <if test="companyId != null "> and company_id = #{companyId}</if>
  24. <if test="corpId != null "> and corp_id = #{corpId}</if>
  25. </where>
  26. </select>
  27. <select id="selectQwDeptById" parameterType="Long" resultMap="QwDeptResult">
  28. <include refid="selectQwDeptVo"/>
  29. where id = #{id}
  30. </select>
  31. <insert id="insertQwDept" parameterType="QwDept">
  32. insert into qw_dept
  33. <trim prefix="(" suffix=")" suffixOverrides=",">
  34. <if test="id != null">id,</if>
  35. <if test="deptId != null">dept_id,</if>
  36. <if test="deptName != null">dept_name,</if>
  37. <if test="parentid != null">parentid,</if>
  38. <if test="companyId != null">company_id,</if>
  39. <if test="corpId != null">corp_id,</if>
  40. </trim>
  41. <trim prefix="values (" suffix=")" suffixOverrides=",">
  42. <if test="id != null">#{id},</if>
  43. <if test="deptId != null">#{deptId},</if>
  44. <if test="deptName != null">#{deptName},</if>
  45. <if test="parentid != null">#{parentid},</if>
  46. <if test="companyId != null">#{companyId},</if>
  47. <if test="corpId != null">#{corpId},</if>
  48. </trim>
  49. </insert>
  50. <insert id="insertOrUpdateQwDept" parameterType="QwDept">
  51. insert into qw_dept
  52. <trim prefix="(" suffix=")" suffixOverrides=",">
  53. <if test="id != null">id,</if>
  54. <if test="deptId != null">dept_id,</if>
  55. <if test="deptName != null">dept_name,</if>
  56. <if test="parentid != null">parentid,</if>
  57. <if test="companyId != null">company_id,</if>
  58. <if test="corpId != null">corp_id,</if>
  59. </trim>
  60. <trim prefix="values (" suffix=")" suffixOverrides=",">
  61. <if test="id != null">#{id},</if>
  62. <if test="deptId != null">#{deptId},</if>
  63. <if test="deptName != null">#{deptName},</if>
  64. <if test="parentid != null">#{parentid},</if>
  65. <if test="companyId != null">#{companyId},</if>
  66. <if test="corpId != null">#{corpId},</if>
  67. </trim>
  68. on duplicate key update
  69. <trim suffixOverrides=",">
  70. <if test="deptId != null">dept_id = #{deptId},</if>
  71. <if test="deptName != null">dept_name = #{deptName},</if>
  72. <if test="parentid != null">parentid = #{parentid},</if>
  73. <if test="companyId != null">company_id = #{companyId},</if>
  74. <if test="corpId != null">corp_id = #{corpId},</if>
  75. </trim>
  76. </insert>
  77. <update id="updateQwDept" parameterType="QwDept">
  78. update qw_dept
  79. <trim prefix="SET" suffixOverrides=",">
  80. <if test="deptId != null">dept_id = #{deptId},</if>
  81. <if test="deptName != null">dept_name = #{deptName},</if>
  82. <if test="parentid != null">parentid = #{parentid},</if>
  83. <if test="companyId != null">company_id = #{companyId},</if>
  84. <if test="corpId != null">corp_id = #{corpId},</if>
  85. </trim>
  86. where id = #{id}
  87. </update>
  88. <delete id="deleteQwDeptById" parameterType="Long">
  89. delete from qw_dept where id = #{id}
  90. </delete>
  91. <delete id="deleteQwDeptByIds" parameterType="String">
  92. delete from qw_dept where id in
  93. <foreach item="id" collection="array" open="(" separator="," close=")">
  94. #{id}
  95. </foreach>
  96. </delete>
  97. </mapper>