Skip to content

Commit 83c6394

Browse files
committed
2024-10-28 - feedback - external reviewer - server-side
1 parent 8179528 commit 83c6394

File tree

4 files changed

+45
-25
lines changed

4 files changed

+45
-25
lines changed

server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestExternalRecipientController.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package com.objectcomputing.checkins.services.feedback_request;
22

33
import com.objectcomputing.checkins.exceptions.BadArgException;
4+
import com.objectcomputing.checkins.security.ImpersonationController;
45
import com.objectcomputing.checkins.services.feedback_external_recipient.FeedbackExternalRecipientServices;
56
import io.micronaut.core.annotation.Nullable;
67
import io.micronaut.core.convert.format.Format;
78
import io.micronaut.http.HttpResponse;
8-
import io.micronaut.http.annotation.Body;
9-
import io.micronaut.http.annotation.Controller;
10-
import io.micronaut.http.annotation.Get;
11-
import io.micronaut.http.annotation.Put;
9+
import io.micronaut.http.MediaType;
10+
import io.micronaut.http.annotation.*;
1211
import io.micronaut.scheduling.TaskExecutors;
1312
import io.micronaut.scheduling.annotation.ExecuteOn;
1413
import io.micronaut.security.annotation.Secured;
@@ -17,6 +16,8 @@
1716
import io.swagger.v3.oas.annotations.tags.Tag;
1817
import jakarta.validation.Valid;
1918
import jakarta.validation.constraints.NotNull;
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
2021

2122
import java.net.URI;
2223
import java.time.LocalDate;
@@ -32,23 +33,43 @@ public class FeedbackRequestExternalRecipientController {
3233

3334
private final FeedbackRequestServices feedbackReqServices;
3435
private final FeedbackExternalRecipientServices feedbackExternalRecipientServices;
36+
private static final Logger LOG = LoggerFactory.getLogger(FeedbackRequestExternalRecipientController.class);
3537

3638
public FeedbackRequestExternalRecipientController(FeedbackRequestServices feedbackRequestServices, FeedbackExternalRecipientServices feedbackExternalRecipientServices) {
3739
this.feedbackReqServices = feedbackRequestServices;
3840
this.feedbackExternalRecipientServices = feedbackExternalRecipientServices;
3941
}
4042

41-
@Get("/{?creatorId,requesteeId,recipientId,oldestDate,reviewPeriodId,templateId,externalRecipientId,requesteeIds}")
42-
public List<FeedbackRequestResponseDTO> findByValues(@Nullable UUID creatorId, @Nullable UUID requesteeId, @Nullable UUID recipientId, @Nullable @Format("yyyy-MM-dd") LocalDate oldestDate, @Nullable UUID reviewPeriodId, @Nullable UUID templateId, @Nullable UUID externalRecipientId, @Nullable List<UUID> requesteeIds) {
43-
if (externalRecipientId == null) {
44-
throw new BadArgException("Missing required parameter: externalRecipientId");
43+
@Get("/{id}")
44+
public HttpResponse<FeedbackRequestResponseDTO> getById(UUID id) {
45+
FeedbackRequest feedbackRequest = feedbackReqServices.getById(id);
46+
if (feedbackRequest.getExternalRecipientId() == null) {
47+
throw new BadArgException("This feedback request is not for an external recipient");
4548
}
49+
return feedbackRequest == null ? HttpResponse.notFound() : HttpResponse.ok(feedbackRequestFromEntity(feedbackRequest))
50+
.headers(headers -> headers.location(URI.create("/feedback_request" + feedbackRequest.getId())));
51+
}
52+
53+
@Get("/{?creatorId,requesteeId,recipientId,oldestDate,reviewPeriodId,templateId,externalRecipientId,requesteeIds}")
54+
public List<FeedbackRequestResponseDTO> findByValues(@Nullable UUID creatorId, @Nullable UUID requesteeId, @Nullable UUID recipientId, @Nullable @Format("yyyy-MM-dd") LocalDate oldestDate, @Nullable UUID reviewPeriodId, @Nullable UUID templateId, UUID externalRecipientId, @Nullable List<UUID> requesteeIds) {
4655
return feedbackReqServices.findByValues(creatorId, requesteeId, recipientId, oldestDate, reviewPeriodId, templateId, externalRecipientId, requesteeIds)
4756
.stream()
4857
.map(this::feedbackRequestFromEntity)
4958
.toList();
5059
}
5160

61+
@Get("/hello")
62+
@Produces(MediaType.TEXT_HTML)
63+
public String hello() {
64+
return "<html><body><h1>Hello, World!</h1></body></html>";
65+
}
66+
67+
@Get("/submitForExternalRecipient")
68+
public HttpResponse<?> redirectToReactPage() {
69+
LOG.info("FeedbackRequestExternalRecipientController, redirectToReactPage");
70+
return HttpResponse.redirect(URI.create("/feedback/submitForExternalRecipient"));
71+
}
72+
5273
/**
5374
* Update a feedback request
5475
*
@@ -65,23 +86,6 @@ public HttpResponse<FeedbackRequestResponseDTO> update(@Body @Valid @NotNull Fee
6586
.headers(headers -> headers.location(URI.create("/feedback_request/" + savedFeedback.getId())));
6687
}
6788

68-
/**
69-
* Get feedback request by ID
70-
*
71-
* @param id {@link UUID} ID of the request
72-
* @return {@link FeedbackRequestResponseDTO}
73-
*/
74-
//@Secured(SecurityRule.IS_ANONYMOUS)
75-
@Get("/{id}")
76-
public HttpResponse<FeedbackRequestResponseDTO> getById(UUID id) {
77-
FeedbackRequest feedbackRequest = feedbackReqServices.getById(id);
78-
if (feedbackRequest.getExternalRecipientId() == null) {
79-
throw new BadArgException("Missing required parameter: externalRecipientId");
80-
}
81-
return feedbackRequest == null ? HttpResponse.notFound() : HttpResponse.ok(feedbackRequestFromEntity(feedbackRequest))
82-
.headers(headers -> headers.location(URI.create("/feedback_request" + feedbackRequest.getId())));
83-
}
84-
8589
private FeedbackRequestResponseDTO feedbackRequestFromEntity(FeedbackRequest feedbackRequest) {
8690
FeedbackRequestResponseDTO dto = new FeedbackRequestResponseDTO();
8791
dto.setId(feedbackRequest.getId());

server/src/main/resources/application-local.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ micronaut:
2626
http-method: GET
2727
access:
2828
- isAnonymous()
29+
- pattern: /feedback/submitForExternalRecipient/**
30+
access:
31+
- isAnonymous()
2932
---
3033
datasources:
3134
default:

web-ui/src/components/routes/Routes.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import KudosPage from '../../pages/KudosPage';
4343
import ManageKudosPage from '../../pages/ManageKudosPage';
4444
import SkillCategoriesPage from '../../pages/SkillCategoriesPage';
4545
import SkillCategoryEditPage from '../../pages/SkillCategoryEditPage';
46+
import FeedbackRequestForExternalRecipientPage from "../../pages/FeedbackRequestForExternalRecipientPage.jsx";
4647

4748
export default function Routes() {
4849
const { state } = useContext(AppContext);
@@ -199,6 +200,9 @@ export default function Routes() {
199200
<Route path="/feedback/submit">
200201
<FeedbackSubmitPage />
201202
</Route>
203+
<Route path="/feedback/submitForExternalRecipient">
204+
<FeedbackRequestForExternalRecipientPage />
205+
</Route>
202206
<Route exact path="/admin/manage-kudos">
203207
<Header title="Manage Kudos"></Header>
204208
<ManageKudosPage />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
function FeedbackRequestForExternalRecipientPage() {
4+
return (
5+
<h1>Hello, World!</h1>
6+
);
7+
}
8+
9+
export default FeedbackRequestForExternalRecipientPage;

0 commit comments

Comments
 (0)