repair badge images -> set to Base64 for transport
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
package SuMoC.backend.gamification.badges;
|
||||
|
||||
import SuMoC.backend.gamification.badges.models.Badge;
|
||||
import SuMoC.backend.user.dtos.MaximalUserDTO;
|
||||
import SuMoC.backend.gamification.badges.models.BadgeDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.CacheControl;
|
||||
@@ -34,13 +32,13 @@ public class BadgeController {
|
||||
@Operation(summary = "Create a new badge")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "201", description = "Badge created successfully",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Badge.class))),
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadgeDTO.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid input data"),
|
||||
@ApiResponse(responseCode = "409", description = "Badge already exists")
|
||||
})
|
||||
@PostMapping("/createBadge")
|
||||
public ResponseEntity<Badge> createBadge(@RequestBody @Valid Badge badge) {
|
||||
Badge createdBadge = badgeService.createBadge(badge);
|
||||
public ResponseEntity<BadgeDTO> createBadge(@RequestBody @Valid BadgeDTO badge) {
|
||||
BadgeDTO createdBadge = badgeService.createBadge(badge);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdBadge);
|
||||
}
|
||||
|
||||
@@ -61,14 +59,14 @@ public class BadgeController {
|
||||
@Operation(summary = "Modify a badge by ID")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Badge modified successfully",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Badge.class))),
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadgeDTO.class))),
|
||||
@ApiResponse(responseCode = "404", description = "Badge not found"),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid input data")
|
||||
})
|
||||
@PutMapping("/modifyBadge")
|
||||
public ResponseEntity<Badge> modifyBadgeById(
|
||||
@RequestBody @Valid Badge badge) {
|
||||
Badge modifiedBadge = badgeService.modifyBadge(badge);
|
||||
public ResponseEntity<BadgeDTO> modifyBadgeById(
|
||||
@RequestBody @Valid BadgeDTO badge) {
|
||||
BadgeDTO modifiedBadge = badgeService.modifyBadge(badge);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modifiedBadge);
|
||||
}
|
||||
|
||||
@@ -76,13 +74,13 @@ public class BadgeController {
|
||||
@Operation(summary = "Get a badge by ID")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Badge retrieved successfully",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Badge.class))),
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = BadgeDTO.class))),
|
||||
@ApiResponse(responseCode = "304", description = "Not modified since last request"),
|
||||
@ApiResponse(responseCode = "404", description = "Badge not found")
|
||||
})
|
||||
@GetMapping("/getBadge/{badgeId}")
|
||||
public ResponseEntity<Badge> getBadgeById(@PathVariable Long badgeId) {
|
||||
Badge badge = badgeService.getBadgeById(badgeId);
|
||||
public ResponseEntity<BadgeDTO> getBadgeById(@PathVariable Long badgeId) {
|
||||
BadgeDTO badge = badgeService.getBadgeById(badgeId);
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(356, TimeUnit.DAYS))
|
||||
.body(badge);
|
||||
@@ -94,14 +92,14 @@ public class BadgeController {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Badges retrieved successfully",
|
||||
content = @Content(mediaType = "application/json",
|
||||
array = @ArraySchema(schema = @Schema(implementation = Badge.class))
|
||||
array = @ArraySchema(schema = @Schema(implementation = BadgeDTO.class))
|
||||
)),
|
||||
@ApiResponse(responseCode = "304", description = "Not modified since last request"),
|
||||
@ApiResponse(responseCode = "404", description = "No badges found")
|
||||
})
|
||||
@GetMapping("/getAllBadges")
|
||||
public ResponseEntity<List<Badge>> getAllBadges(){
|
||||
List<Badge> badges = badgeService.getAllBadges();
|
||||
public ResponseEntity<List<BadgeDTO>> getAllBadges(){
|
||||
List<BadgeDTO> badges = badgeService.getAllBadges();
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(365, TimeUnit.DAYS))
|
||||
.body(badges);
|
||||
|
||||
Reference in New Issue
Block a user