select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, r.status, r.del_flag, r.create_time, r.remark from sys_role r left join sys_user_role ur on ur.role_id = r.role_id left join sys_user u on u.user_id = ur.user_id left join sys_dept d on u.dept_id = d.dept_id insert into sys_role( role_id, role_name, role_key, role_sort, data_scope, menu_check_strictly, dept_check_strictly, status, remark, create_by, create_time )values( #{roleId}, #{roleName}, #{roleKey}, #{roleSort}, #{dataScope}, #{menu_check_strictly}, #{dept_check_strictly}, #{status}, #{remark}, #{createBy}, sysdate() ) update sys_role role_name = #{roleName}, role_key = #{roleKey}, role_sort = #{roleSort}, data_scope = #{dataScope}, menu_check_strictly = #{menuCheckStrictly}, dept_check_strictly = #{deptCheckStrictly}, status = #{status}, remark = #{remark}, update_by = #{updateBy}, update_time = sysdate() where role_id = #{roleId} update sys_user set status = #{status} where user_id = #{userId} delete from sys_role where role_id = #{roleId} update sys_role set del_flag = '2' where role_id in #{roleId}