2026-06-24 f4bd1f3c89d906131495a0aca5aaf82966378510
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package cn.iocoder.yudao.module.ai.tool.method;
 
import java.util.List;
import java.util.Optional;
 
/**
 * 来自 Spring AI 官方文档
 *
 * Service interface for managing Person data.
 * Defines the contract for CRUD operations and search/filter functionalities.
 */
public interface PersonService {
 
    /**
     * Creates a new Person record.
     * Assigns a unique ID to the person and stores it.
     *
     * @param personData The data for the new person (ID field is ignored). Must not be null.
     * @return The created Person record, including the generated ID.
     */
    Person createPerson(Person personData);
 
    /**
     * Retrieves a Person by their unique ID.
     *
     * @param id The ID of the person to retrieve.
     * @return An Optional containing the found Person, or an empty Optional if not found.
     */
    Optional<Person> getPersonById(int id);
 
    /**
     * Retrieves all Person records currently stored.
     *
     * @return An unmodifiable List containing all Persons. Returns an empty list if none exist.
     */
    List<Person> getAllPersons();
 
    /**
     * Updates an existing Person record identified by ID.
     * Replaces the existing data with the provided data, keeping the original ID.
     *
     * @param id                The ID of the person to update.
     * @param updatedPersonData The new data for the person (ID field is ignored). Must not be null.
     * @return true if the person was found and updated, false otherwise.
     */
    boolean updatePerson(int id, Person updatedPersonData);
 
    /**
     * Deletes a Person record identified by ID.
     *
     * @param id The ID of the person to delete.
     * @return true if the person was found and deleted, false otherwise.
     */
    boolean deletePerson(int id);
 
    /**
     * Searches for Persons whose job title contains the given query string (case-insensitive).
     *
     * @param jobTitleQuery The string to search for within job titles. Can be null or blank.
     * @return An unmodifiable List of matching Persons. Returns an empty list if no matches or query is invalid.
     */
    List<Person> searchByJobTitle(String jobTitleQuery);
 
    /**
     * Filters Persons by their exact sex (case-insensitive).
     *
     * @param sex The sex to filter by (e.g., "Male", "Female"). Can be null or blank.
     * @return An unmodifiable List of matching Persons. Returns an empty list if no matches or filter is invalid.
     */
    List<Person> filterBySex(String sex);
 
    /**
     * Filters Persons by their exact age.
     *
     * @param age The age to filter by.
     * @return An unmodifiable List of matching Persons. Returns an empty list if no matches.
     */
    List<Person> filterByAge(int age);
 
}