select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, 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, status, remark, create_by, create_time )values( #{roleId}, #{roleName}, #{roleKey}, #{roleSort}, #{dataScope}, #{status}, #{remark}, #{createBy}, sysdate() ) update sys_role role_name = #{roleName}, role_key = #{roleKey}, role_sort = #{roleSort}, data_scope = #{dataScope}, 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}