-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #554 from bounswe/feature/BE-552-need-and-resource…
…-entity-consistency Feature/be 552 need and resource entity consistency
- Loading branch information
Showing
28 changed files
with
325 additions
and
23 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
resq/backend/resq/src/main/java/com/groupa1/resq/controller/EventController.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,38 @@ | ||
package com.groupa1.resq.controller; | ||
|
||
|
||
import com.groupa1.resq.request.CreateEventRequest; | ||
import com.groupa1.resq.service.EventService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import com.groupa1.resq.response.EventResponse; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/event") | ||
public class EventController { | ||
|
||
@Autowired | ||
private EventService eventService; | ||
|
||
@PreAuthorize("hasRole('RESPONDER') or hasRole('COORDINATOR') or hasRole('FACILITATOR') or hasRole('VICTIM')") | ||
@PostMapping("/createEvent") | ||
public ResponseEntity<String> createEvent(@RequestBody CreateEventRequest createEventRequest){ | ||
return eventService.createEvent(createEventRequest); | ||
} | ||
|
||
@PreAuthorize("hasRole('RESPONDER') or hasRole('COORDINATOR') or hasRole('FACILITATOR') or hasRole('VICTIM')") | ||
@GetMapping("/viewEvents") | ||
public ResponseEntity<List<EventResponse>> viewEvents(@RequestParam Long reporterId) { | ||
return eventService.viewEvents( reporterId); | ||
} | ||
|
||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
resq/backend/resq/src/main/java/com/groupa1/resq/dto/EventDto.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,25 @@ | ||
package com.groupa1.resq.dto; | ||
|
||
|
||
import com.groupa1.resq.entity.User; | ||
import lombok.Data; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
public class EventDto { | ||
|
||
private Long reporterId; | ||
|
||
private String description; | ||
|
||
private LocalDateTime reportDate; | ||
|
||
private boolean isVerified; | ||
|
||
private BigDecimal eventLatitude; | ||
private BigDecimal eventLongitude; | ||
|
||
|
||
} |
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
38 changes: 38 additions & 0 deletions
38
resq/backend/resq/src/main/java/com/groupa1/resq/entity/Event.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,38 @@ | ||
package com.groupa1.resq.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor | ||
@Entity | ||
@Table( name = "EVENT") | ||
@Data | ||
@EqualsAndHashCode(callSuper = true, exclude = {"reporter"}) | ||
@ToString(callSuper = true, exclude = {"reporter"}) | ||
public class Event extends BaseEntity { | ||
|
||
//@Enumerated(EnumType.STRING) | ||
//private EEventType eventType; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "reporter_id") | ||
private User reporter; | ||
|
||
@Column(length = 2048) | ||
private String description; | ||
|
||
private LocalDateTime reportDate; | ||
|
||
private boolean isVerified; | ||
|
||
private BigDecimal eventLatitude; | ||
private BigDecimal eventLongitude; | ||
|
||
} | ||
|
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
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
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
9 changes: 9 additions & 0 deletions
9
resq/backend/resq/src/main/java/com/groupa1/resq/entity/enums/EEventType.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,9 @@ | ||
package com.groupa1.resq.entity.enums; | ||
|
||
public enum EEventType { | ||
FIRE, | ||
EARTHQUAKE, | ||
FLOOD, | ||
TSUNAMI, | ||
OTHER | ||
} |
6 changes: 4 additions & 2 deletions
6
resq/backend/resq/src/main/java/com/groupa1/resq/entity/enums/EGender.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.groupa1.resq.entity.enums; | ||
|
||
public enum EGender { | ||
MALE, | ||
FEMALE | ||
MAN, | ||
WOMAN, | ||
CHILDREN_BOY, CHILDREN_GIRL, | ||
BABY | ||
} |
7 changes: 7 additions & 0 deletions
7
resq/backend/resq/src/main/java/com/groupa1/resq/entity/enums/ESize.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,7 @@ | ||
package com.groupa1.resq.entity.enums; | ||
|
||
public enum ESize { | ||
XL, L, M, S, XS, // For Gender: MAN, WOMAN | ||
AGE_0_2, AGE_2_4, // For Gender: BABY | ||
AGE_4_8, AGE_8_12, AGE_12_18, // For Gender: CHILDREN_BOY, CHILDREN_GIRL | ||
} |
15 changes: 15 additions & 0 deletions
15
resq/backend/resq/src/main/java/com/groupa1/resq/repository/EventRepository.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,15 @@ | ||
package com.groupa1.resq.repository; | ||
|
||
|
||
import com.groupa1.resq.entity.Event; | ||
import com.groupa1.resq.entity.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface EventRepository extends JpaRepository<Event, Long> { | ||
List<Event> findByReporter(User reporter); | ||
|
||
} |
Oops, something went wrong.