-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeleteSponsorHandler.java
More file actions
42 lines (35 loc) · 1.45 KB
/
DeleteSponsorHandler.java
File metadata and controls
42 lines (35 loc) · 1.45 KB
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
package com.test.handlers;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import com.test.config.CoreComponent;
import com.test.config.DaggerCoreComponent;
import com.test.service.SponsorService;
import com.test.utils.HandlerUtils;
import lombok.extern.slf4j.Slf4j;
import javax.inject.Inject;
@Slf4j
public class DeleteSponsorHandler extends ApiHandler {
@Inject
SponsorService sponsorService;
protected final CoreComponent coreComponent;
public DeleteSponsorHandler() {
coreComponent = DaggerCoreComponent.builder().build();
coreComponent.inject(this);
}
@Override
public APIGatewayProxyResponseEvent handle(APIGatewayProxyRequestEvent input, Context context) {
try {
String sponsorId = input.getPathParameters().get("id");
if (sponsorId == null || sponsorId.trim().isEmpty()) {
return HandlerUtils.buildBadRequestError("Sponsor ID is required");
}
sponsorService.deleteSponsorById(sponsorId);
return new APIGatewayProxyResponseEvent()
.withStatusCode(204);
} catch (Exception e) {
log.error("Error deleting sponsor: {}", e.getMessage(), e);
return HandlerUtils.buildServerError("Error deleting sponsor");
}
}
}