1
0

SysDeptDao.xml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.admin.dao.SysDeptDao">
  4. <select id="queryObject" resultType="com.kmall.admin.entity.SysDeptEntity">
  5. select * from sys_dept where dept_id = #{value} and del_flag = 0
  6. </select>
  7. <select id="queryList" resultType="com.kmall.admin.entity.SysDeptEntity">
  8. select d.*,(select p.name from sys_dept p where p.dept_id = d.parent_id) as parentName
  9. from sys_dept d where d.del_flag = 0
  10. <if test="deptFilter != null">
  11. and d.dept_id in (${deptFilter})
  12. </if>
  13. <choose>
  14. <when test="sidx != null and sidx.trim() != ''">
  15. order by d.${sidx} ${order}
  16. </when>
  17. <otherwise>
  18. order by d.order_num asc
  19. </otherwise>
  20. </choose>
  21. <if test="offset != null and limit != null">
  22. limit #{offset}, #{limit}
  23. </if>
  24. </select>
  25. <insert id="save" parameterType="com.kmall.admin.entity.SysDeptEntity" useGeneratedKeys="true" keyProperty="deptId">
  26. insert into sys_dept
  27. (
  28. `parent_id`,
  29. `name`,
  30. `order_num`
  31. )
  32. values
  33. (
  34. #{parentId},
  35. #{name},
  36. #{orderNum}
  37. )
  38. </insert>
  39. <update id="update" parameterType="com.kmall.admin.entity.SysDeptEntity">
  40. update sys_dept
  41. <set>
  42. <if test="parentId != null">`parent_id` = #{parentId}, </if>
  43. <if test="name != null">`name` = #{name}, </if>
  44. <if test="orderNum != null">`order_num` = #{orderNum}</if>
  45. </set>
  46. where dept_id = #{deptId}
  47. </update>
  48. <update id="delete">
  49. update sys_dept set del_flag = -1 where dept_id = #{value}
  50. </update>
  51. <select id="queryDetpIdList" resultType="long">
  52. select dept_id from sys_dept where parent_id = #{value} and del_flag = 0
  53. </select>
  54. </mapper>