select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time from sys_dept d insert into sys_dept( dept_id, parent_id, dept_name, ancestors, order_num, leader, phone, email, status, create_by, create_time )values( #{deptId}, #{parentId}, #{deptName}, #{ancestors}, #{orderNum}, #{leader}, #{phone}, #{email}, #{status}, #{createBy}, getdate() ) update sys_dept parent_id = #{parentId}, dept_name = #{deptName}, ancestors = #{ancestors}, order_num = #{orderNum}, leader = #{leader}, phone = #{phone}, email = #{email}, status = #{status}, update_by = #{updateBy}, update_time = getdate() where dept_id = #{deptId} update sys_dept set ancestors = when #{item.deptId} then #{item.ancestors} where dept_id in #{item.deptId} update sys_dept set status = '0' where dept_id in #{deptId} update sys_dept set del_flag = '2' where dept_id = #{deptId}