22
33import com .jobtracker .dto .application .*;
44import com .jobtracker .service .ApplicationService ;
5+ import io .swagger .v3 .oas .annotations .Operation ;
6+ import io .swagger .v3 .oas .annotations .Parameter ;
7+ import io .swagger .v3 .oas .annotations .media .Content ;
8+ import io .swagger .v3 .oas .annotations .media .Schema ;
9+ import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
10+ import io .swagger .v3 .oas .annotations .tags .Tag ;
511import jakarta .validation .Valid ;
612import org .springframework .format .annotation .DateTimeFormat ;
713import org .springframework .http .HttpStatus ;
1218import java .util .List ;
1319import java .util .Map ;
1420
21+ @ Tag (name = "Applications" , description = "Job application management endpoints" )
1522@ RestController
1623@ RequestMapping ("/api/applications" )
1724public class ApplicationController {
@@ -22,60 +29,140 @@ public ApplicationController(ApplicationService applicationService) {
2229 this .applicationService = applicationService ;
2330 }
2431
32+ @ Operation (
33+ summary = "Create a job application" ,
34+ description = "Creates a new job application for the authenticated user" ,
35+ responses = {
36+ @ ApiResponse (responseCode = "201" , description = "Application created" ,
37+ content = @ Content (schema = @ Schema (implementation = ApplicationResponse .class ))),
38+ @ ApiResponse (responseCode = "400" , description = "Validation error" )
39+ }
40+ )
2541 @ PostMapping
2642 public ResponseEntity <ApplicationResponse > create (@ Valid @ RequestBody ApplicationRequest request ) {
2743 return ResponseEntity .status (HttpStatus .CREATED ).body (applicationService .create (request ));
2844 }
2945
46+ @ Operation (
47+ summary = "Get application by ID" ,
48+ description = "Returns a single job application owned by the authenticated user" ,
49+ responses = {
50+ @ ApiResponse (responseCode = "200" , description = "Application found" ,
51+ content = @ Content (schema = @ Schema (implementation = ApplicationResponse .class ))),
52+ @ ApiResponse (responseCode = "404" , description = "Application not found" )
53+ }
54+ )
3055 @ GetMapping ("/{id}" )
31- public ResponseEntity <ApplicationResponse > getById (@ PathVariable Long id ) {
56+ public ResponseEntity <ApplicationResponse > getById (
57+ @ Parameter (description = "Application ID" , required = true ) @ PathVariable Long id ) {
3258 return ResponseEntity .ok (applicationService .getById (id ));
3359 }
3460
61+ @ Operation (
62+ summary = "Update a job application" ,
63+ description = "Replaces all fields of an existing job application" ,
64+ responses = {
65+ @ ApiResponse (responseCode = "200" , description = "Application updated" ,
66+ content = @ Content (schema = @ Schema (implementation = ApplicationResponse .class ))),
67+ @ ApiResponse (responseCode = "400" , description = "Validation error" ),
68+ @ ApiResponse (responseCode = "404" , description = "Application not found" )
69+ }
70+ )
3571 @ PutMapping ("/{id}" )
36- public ResponseEntity <ApplicationResponse > update (@ PathVariable Long id ,
37- @ Valid @ RequestBody ApplicationRequest request ) {
72+ public ResponseEntity <ApplicationResponse > update (
73+ @ Parameter (description = "Application ID" , required = true ) @ PathVariable Long id ,
74+ @ Valid @ RequestBody ApplicationRequest request ) {
3875 return ResponseEntity .ok (applicationService .update (id , request ));
3976 }
4077
78+ @ Operation (
79+ summary = "Update application status" ,
80+ description = "Partially updates only the status field of an application" ,
81+ responses = {
82+ @ ApiResponse (responseCode = "200" , description = "Status updated" ,
83+ content = @ Content (schema = @ Schema (implementation = ApplicationResponse .class ))),
84+ @ ApiResponse (responseCode = "404" , description = "Application not found" )
85+ }
86+ )
4187 @ PatchMapping ("/{id}/status" )
42- public ResponseEntity <ApplicationResponse > updateStatus (@ PathVariable Long id ,
43- @ Valid @ RequestBody UpdateStatusRequest request ) {
88+ public ResponseEntity <ApplicationResponse > updateStatus (
89+ @ Parameter (description = "Application ID" , required = true ) @ PathVariable Long id ,
90+ @ Valid @ RequestBody UpdateStatusRequest request ) {
4491 return ResponseEntity .ok (applicationService .updateStatus (id , request ));
4592 }
4693
94+ @ Operation (
95+ summary = "Update recruiter DM reminder" ,
96+ description = "Enables or disables the recruiter DM reminder for an application" ,
97+ responses = {
98+ @ ApiResponse (responseCode = "200" , description = "Reminder updated" ,
99+ content = @ Content (schema = @ Schema (implementation = ApplicationResponse .class ))),
100+ @ ApiResponse (responseCode = "404" , description = "Application not found" )
101+ }
102+ )
47103 @ PatchMapping ("/{id}/reminder" )
48- public ResponseEntity <ApplicationResponse > updateReminder (@ PathVariable Long id ,
49- @ Valid @ RequestBody UpdateReminderRequest request ) {
104+ public ResponseEntity <ApplicationResponse > updateReminder (
105+ @ Parameter (description = "Application ID" , required = true ) @ PathVariable Long id ,
106+ @ Valid @ RequestBody UpdateReminderRequest request ) {
50107 return ResponseEntity .ok (applicationService .updateReminder (id , request ));
51108 }
52109
110+ @ Operation (
111+ summary = "Delete a job application" ,
112+ responses = {
113+ @ ApiResponse (responseCode = "200" , description = "Application deleted" ),
114+ @ ApiResponse (responseCode = "404" , description = "Application not found" )
115+ }
116+ )
53117 @ DeleteMapping ("/{id}" )
54- public ResponseEntity <Map <String , String >> delete (@ PathVariable Long id ) {
118+ public ResponseEntity <Map <String , String >> delete (
119+ @ Parameter (description = "Application ID" , required = true ) @ PathVariable Long id ) {
55120 applicationService .delete (id );
56121 return ResponseEntity .ok (Map .of ("message" , "Application deleted successfully" ));
57122 }
58123
124+ @ Operation (
125+ summary = "List job applications" ,
126+ description = "Returns a paginated, filterable list of job applications for the authenticated user" ,
127+ responses = {
128+ @ ApiResponse (responseCode = "200" , description = "Page of applications" ,
129+ content = @ Content (schema = @ Schema (implementation = ApplicationPageResponse .class )))
130+ }
131+ )
59132 @ GetMapping
60133 public ResponseEntity <ApplicationPageResponse > getAll (
61- @ RequestParam (required = false ) String status ,
62- @ RequestParam (required = false ) String recruiterName ,
63- @ RequestParam (required = false ) @ DateTimeFormat (iso = DateTimeFormat .ISO .DATE ) LocalDate applicationDateFrom ,
64- @ RequestParam (required = false ) @ DateTimeFormat (iso = DateTimeFormat .ISO .DATE ) LocalDate applicationDateTo ,
65- @ RequestParam (required = false ) Boolean interviewScheduled ,
66- @ RequestParam (required = false ) Boolean recruiterDmReminderEnabled ,
67- @ RequestParam (defaultValue = "0" ) int page ,
68- @ RequestParam (defaultValue = "10" ) int size ,
69- @ RequestParam (required = false ) String sort ) {
134+ @ Parameter ( description = "Filter by status" ) @ RequestParam (required = false ) String status ,
135+ @ Parameter ( description = "Filter by recruiter name" ) @ RequestParam (required = false ) String recruiterName ,
136+ @ Parameter ( description = "Filter from date (yyyy-MM-dd)" ) @ RequestParam (required = false ) @ DateTimeFormat (iso = DateTimeFormat .ISO .DATE ) LocalDate applicationDateFrom ,
137+ @ Parameter ( description = "Filter to date (yyyy-MM-dd)" ) @ RequestParam (required = false ) @ DateTimeFormat (iso = DateTimeFormat .ISO .DATE ) LocalDate applicationDateTo ,
138+ @ Parameter ( description = "Filter by interview scheduled flag" ) @ RequestParam (required = false ) Boolean interviewScheduled ,
139+ @ Parameter ( description = "Filter by recruiter DM reminder flag" ) @ RequestParam (required = false ) Boolean recruiterDmReminderEnabled ,
140+ @ Parameter ( description = "Page number (0-based)" ) @ RequestParam (defaultValue = "0" ) int page ,
141+ @ Parameter ( description = "Page size" ) @ RequestParam (defaultValue = "10" ) int size ,
142+ @ Parameter ( description = "Sort field" ) @ RequestParam (required = false ) String sort ) {
70143 return ResponseEntity .ok (applicationService .getAll (status , recruiterName , applicationDateFrom ,
71144 applicationDateTo , interviewScheduled , recruiterDmReminderEnabled , page , size , sort ));
72145 }
73146
147+ @ Operation (
148+ summary = "Get upcoming applications" ,
149+ description = "Returns applications with upcoming next-step dates" ,
150+ responses = {
151+ @ ApiResponse (responseCode = "200" , description = "List of upcoming applications" )
152+ }
153+ )
74154 @ GetMapping ("/upcoming" )
75155 public ResponseEntity <List <ApplicationResponse >> getUpcoming () {
76156 return ResponseEntity .ok (applicationService .getUpcoming ());
77157 }
78158
159+ @ Operation (
160+ summary = "Get overdue applications" ,
161+ description = "Returns applications whose next-step date has already passed" ,
162+ responses = {
163+ @ ApiResponse (responseCode = "200" , description = "List of overdue applications" )
164+ }
165+ )
79166 @ GetMapping ("/overdue" )
80167 public ResponseEntity <List <ApplicationResponse >> getOverdue () {
81168 return ResponseEntity .ok (applicationService .getOverdue ());
0 commit comments