11package edu .tamu .app .controller ;
22
3- import static edu .tamu .weaver .response .ApiStatus .SUCCESS ;
43import static edu .tamu .weaver .response .ApiStatus .INVALID ;
4+ import static edu .tamu .weaver .response .ApiStatus .SUCCESS ;
55import static edu .tamu .weaver .validation .model .BusinessValidationType .CREATE ;
66
77import org .springframework .beans .factory .annotation .Autowired ;
1212import org .springframework .web .bind .annotation .RequestMapping ;
1313import org .springframework .web .bind .annotation .RestController ;
1414
15+ import edu .tamu .app .enums .IdeaState ;
1516import edu .tamu .app .exception .UserNotFoundException ;
1617import edu .tamu .app .model .Idea ;
1718import edu .tamu .app .model .repo .IdeaRepo ;
1819import edu .tamu .app .model .request .FilteredPageRequest ;
20+ import edu .tamu .app .model .request .IssueRequest ;
21+ import edu .tamu .app .service .ProjectService ;
1922import edu .tamu .weaver .auth .annotation .WeaverCredentials ;
2023import edu .tamu .weaver .auth .model .Credentials ;
2124import edu .tamu .weaver .response .ApiResponse ;
@@ -29,6 +32,9 @@ public class IdeaController {
2932 @ Autowired
3033 private IdeaRepo ideaRepo ;
3134
35+ @ Autowired
36+ private ProjectService projectService ;
37+
3238 @ RequestMapping ("/page" )
3339 @ PreAuthorize ("hasRole('SERVICE_MANAGER')" )
3440 public ApiResponse page (@ RequestBody FilteredPageRequest filteredPageRequest ) {
@@ -66,6 +72,15 @@ public ApiResponse reject(@WeaverValidatedModel Idea idea) {
6672 return response ;
6773 }
6874
75+ @ RequestMapping ("/helpdesk" )
76+ @ PreAuthorize ("hasRole('SERVICE_MANAGER')" )
77+ public ApiResponse helpdesk (@ WeaverValidatedModel Idea idea , @ WeaverCredentials Credentials credentials ) {
78+ idea .setState (IdeaState .SENT_TO_HELPDESK );
79+ idea = ideaRepo .update (idea );
80+ IssueRequest request = new IssueRequest (idea , credentials );
81+ return projectService .submitIssueRequest (request );
82+ }
83+
6984 @ Transactional
7085 @ RequestMapping ("/remove" )
7186 @ PreAuthorize ("hasRole('SERVICE_MANAGER')" )
0 commit comments