-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCommunityController.java
38 lines (27 loc) · 1.01 KB
/
CommunityController.java
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
package com.example.fanaticbackend.controller;
import com.example.fanaticbackend.model.Community;
import com.example.fanaticbackend.service.CommunityService;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/v1/communities")
@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class CommunityController {
final CommunityService communityService;
@GetMapping("{communityName}")
public ResponseEntity<Community> getCommunityByName(
@PathVariable String communityName
) {
Community community = communityService.findCommunityByTeamElseThrow(communityName);
return ResponseEntity.ok(community);
}
@PostMapping("")
public ResponseEntity<Boolean> createAll() {
communityService.createAllCommunities();
return ResponseEntity.ok(true);
}
}