gpt生成測試

slan_wyf發表於2024-06-27
        List<CoursePO> courses = sqlMapper.queryCourse();
        List<StudentPO> students = sqlMapper.queryStudent();
        List<RelationPO> relations = sqlMapper.queryRelation();
//        studentPOS.stream().filter()


        Set<String> femaleStudents = students.stream()
                .filter(student -> student.getSex().equals("女"))
                .map(StudentPO::getName)
                .collect(Collectors.toSet());

        Set<String> foreignLanguageCourses = courses.stream()
                .filter(course -> course.getName().equals("外語"))
                .map(CoursePO::getName)
                .collect(Collectors.toSet());

        Set<String> result = relations.stream()
                .filter(r1 -> relations.stream()
                        .filter(r2 -> r1.getCourseName().equals(r2.getCourseName()))
                        .anyMatch(r2 -> femaleStudents.contains(r2.getStudentName()) || foreignLanguageCourses.contains(r2.getCourseName())))
                .map(RelationPO::getStudentName)
                .collect(Collectors.toSet());

        // Print the results
        result.forEach(System.out::println);

相關文章