-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into frontend-user-agreement
- Loading branch information
Showing
169 changed files
with
14,298 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
app/backend/src/main/java/com/app/gamereview/controller/GroupController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.app.gamereview.controller; | ||
|
||
import com.app.gamereview.dto.request.group.*; | ||
import com.app.gamereview.dto.response.group.GetGroupResponseDto; | ||
import com.app.gamereview.dto.response.tag.AddGroupTagResponseDto; | ||
import com.app.gamereview.model.Group; | ||
import com.app.gamereview.model.User; | ||
import com.app.gamereview.service.GroupService; | ||
import com.app.gamereview.service.ReviewService; | ||
import com.app.gamereview.util.validation.annotation.AdminRequired; | ||
import com.app.gamereview.util.validation.annotation.AuthorizationRequired; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.validation.Valid; | ||
import org.springdoc.core.annotations.ParameterObject; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.data.mongodb.core.query.Update; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/group") | ||
@Validated | ||
public class GroupController { | ||
|
||
@Value("${SECRET_KEY}") | ||
private String secret_key = "${SECRET_KEY}"; | ||
|
||
private final GroupService groupService; | ||
|
||
@Autowired | ||
public GroupController( | ||
GroupService groupService | ||
) { | ||
this.groupService = groupService; | ||
} | ||
|
||
@GetMapping("/get-all") | ||
public ResponseEntity<List<GetGroupResponseDto>> getReviews( | ||
@ParameterObject GetAllGroupsFilterRequestDto filter) { | ||
List<GetGroupResponseDto> groups = groupService.getAllGroups(filter); | ||
return ResponseEntity.ok(groups); | ||
} | ||
|
||
@GetMapping("/get") | ||
public ResponseEntity<GetGroupResponseDto> getGroup(@RequestParam String id) { | ||
GetGroupResponseDto group = groupService.getGroupById(id); | ||
|
||
return ResponseEntity.ok(group); | ||
} | ||
|
||
@AuthorizationRequired | ||
@PostMapping("/create") | ||
public ResponseEntity<Group> createGroup(@Valid @RequestBody CreateGroupRequestDto createGroupRequestDto, | ||
@RequestHeader String Authorization, HttpServletRequest request) { | ||
User user = (User) request.getAttribute("authenticatedUser"); | ||
Group groupToCreate = groupService.createGroup(createGroupRequestDto, user); | ||
return ResponseEntity.ok(groupToCreate); | ||
} | ||
|
||
@AuthorizationRequired | ||
@PutMapping("/update") | ||
public ResponseEntity<Group> editGroup(@RequestParam String id, | ||
@Valid @RequestBody UpdateGroupRequestDto updateGroupRequestDto, | ||
@RequestHeader String Authorization, HttpServletRequest request) { | ||
Group updatedGroup = groupService.updateGroup(id,updateGroupRequestDto); | ||
return ResponseEntity.ok(updatedGroup); | ||
} | ||
|
||
@AuthorizationRequired | ||
@DeleteMapping("/delete") | ||
public ResponseEntity<Boolean> deleteGroup(String identifier, | ||
@RequestHeader String Authorization, HttpServletRequest request) { | ||
User user = (User) request.getAttribute("authenticatedUser"); | ||
Boolean response = groupService.deleteGroup(identifier); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
@AuthorizationRequired | ||
@PostMapping("/add-tag") | ||
public ResponseEntity<AddGroupTagResponseDto> addGroupTag( | ||
@Valid @RequestBody AddGroupTagRequestDto addGroupTagRequestDto) { | ||
AddGroupTagResponseDto response = groupService.addGroupTag(addGroupTagRequestDto); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
@AuthorizationRequired | ||
@DeleteMapping("/remove-tag") | ||
public ResponseEntity<Boolean> removeGroupTag( | ||
@Valid @RequestBody RemoveGroupTagRequestDto removeGroupTagRequestDto) { | ||
Boolean response = groupService.removeGroupTag(removeGroupTagRequestDto); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
@AuthorizationRequired | ||
@PostMapping("/join") | ||
public ResponseEntity<Boolean> joinGroup(@RequestParam String id, | ||
@RequestHeader String Authorization, HttpServletRequest request) { | ||
User user = (User) request.getAttribute("authenticatedUser"); | ||
Boolean joined = groupService.joinGroup(id, user); | ||
return ResponseEntity.ok(joined); | ||
} | ||
|
||
@AuthorizationRequired | ||
@PostMapping("/leave") | ||
public ResponseEntity<Boolean> leaveGroup(@RequestParam String id, | ||
@RequestHeader String Authorization, HttpServletRequest request) { | ||
User user = (User) request.getAttribute("authenticatedUser"); | ||
Boolean leave = groupService.leaveGroup(id, user); | ||
return ResponseEntity.ok(leave); | ||
} | ||
|
||
@AuthorizationRequired | ||
@PutMapping("/ban-user") | ||
public ResponseEntity<Boolean> banUser(@RequestParam String groupId, @RequestParam String userId, @RequestHeader String Authorization, HttpServletRequest request) { | ||
User user = (User) request.getAttribute("authenticatedUser"); | ||
Boolean result = groupService.banUser(groupId, userId, user); | ||
return ResponseEntity.ok(result); | ||
} | ||
@AuthorizationRequired | ||
@PutMapping("/add-moderator") | ||
public ResponseEntity<Boolean> addModerator(@RequestParam String groupId, @RequestParam String userId, @RequestHeader String Authorization, HttpServletRequest request) { | ||
User user = (User) request.getAttribute("authenticatedUser"); | ||
Boolean result = groupService.addModerator(groupId, userId, user); | ||
return ResponseEntity.ok(result); | ||
} | ||
|
||
@AuthorizationRequired | ||
@AdminRequired | ||
@PutMapping("/remove-moderator") | ||
public ResponseEntity<Boolean> removeModerator(@RequestParam String groupId, @RequestParam String userId, @RequestHeader String Authorization, HttpServletRequest request) { | ||
Boolean result = groupService.removeModerator(groupId, userId); | ||
return ResponseEntity.ok(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dto/request/tag/AddGameTagRequestDto.java → ...to/request/game/AddGameTagRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/backend/src/main/java/com/app/gamereview/dto/request/game/RemoveGameTagRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.app.gamereview.dto.request.game; | ||
|
||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.Pattern; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class RemoveGameTagRequestDto { | ||
|
||
@NotEmpty(message = "Game Id field cannot be null or empty") | ||
@Pattern(regexp = "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", | ||
message = "Game Id has Invalid Id (UUID) format") | ||
private String gameId; | ||
|
||
@NotEmpty(message = "Tag Id field cannot be null or empty") | ||
@Pattern(regexp = "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", | ||
message = "Tag Id has Invalid Id (UUID) format") | ||
private String tagId; | ||
} |
Oops, something went wrong.