fix validation and 500 bugs
This commit is contained in:
@@ -7,6 +7,7 @@ import com.petshop.backend.dto.chat.MessageResponse;
|
||||
import com.petshop.backend.dto.chat.UpdateConversationRequest;
|
||||
import com.petshop.backend.entity.Message;
|
||||
import com.petshop.backend.entity.User;
|
||||
import com.petshop.backend.exception.ResourceNotFoundException;
|
||||
import com.petshop.backend.repository.MessageRepository;
|
||||
import com.petshop.backend.repository.UserRepository;
|
||||
import com.petshop.backend.service.ChatAttachmentStorageService;
|
||||
@@ -115,7 +116,7 @@ public class ChatController {
|
||||
public ResponseEntity<Resource> getMessageAttachment(@PathVariable Long messageId) {
|
||||
User user = getCurrentUser();
|
||||
Message message = messageRepository.findById(messageId)
|
||||
.orElseThrow(() -> new RuntimeException("Message not found"));
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Message not found with id: " + messageId));
|
||||
|
||||
if (!chatService.hasConversationAccess(message.getConversationId(), user.getId(), user.getRole())) {
|
||||
throw new AccessDeniedException("Access denied to this message attachment");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.petshop.backend.dto.appointment;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
@@ -21,7 +22,7 @@ public class AppointmentRequest {
|
||||
@NotNull(message = "Appointment time is required")
|
||||
private LocalTime appointmentTime;
|
||||
|
||||
@NotNull(message = "Appointment status is required")
|
||||
@NotBlank(message = "Appointment status is required")
|
||||
private String appointmentStatus;
|
||||
|
||||
private Long petId;
|
||||
|
||||
@@ -18,6 +18,7 @@ public class ServiceRequest {
|
||||
@Positive(message = "Price must be positive")
|
||||
private BigDecimal servicePrice;
|
||||
|
||||
@NotNull(message = "Service duration is required")
|
||||
@Positive(message = "Duration must be positive")
|
||||
private Integer serviceDuration;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user