-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced attendance object with transaction #64
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import com.pecacm.backend.constants.Constants; | ||
import com.pecacm.backend.entities.Event; | ||
import com.pecacm.backend.enums.Branch; | ||
import com.pecacm.backend.enums.EventRole; | ||
import com.pecacm.backend.exception.AcmException; | ||
import com.pecacm.backend.model.EndEventDetails; | ||
import com.pecacm.backend.services.EventService; | ||
|
@@ -76,11 +77,11 @@ public ResponseEntity<List<Event>> getEventsByBranch(@PathVariable Branch branch | |
|
||
@GetMapping("/user/{userId}") | ||
@PreAuthorize(Constants.HAS_ROLE_MEMBER_AND_ABOVE) | ||
public ResponseEntity<List<Event>> getUserEventsByRole(@PathVariable Integer userId, @RequestParam("role") @Nullable String role) { | ||
if (role == null){ | ||
return ResponseEntity.ok(eventService.getUserEvents(userId)); | ||
public ResponseEntity<List<Event>> getUserEventsByRole(@PathVariable Integer userId, @RequestParam("role") @Nullable EventRole eventRole) { | ||
if (eventRole == null){ | ||
return ResponseEntity.ok(eventService.getUserEventsByRole(userId, EventRole.PARTICIPANT)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to #51 if event role is not provided all events should be returned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now returning all events |
||
} | ||
return ResponseEntity.ok(eventService.getUserEventsByRole(userId, role)); | ||
return ResponseEntity.ok(eventService.getUserEventsByRole(userId, eventRole)); | ||
} | ||
|
||
@PostMapping | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package com.pecacm.backend.repository; | ||
|
||
import com.pecacm.backend.entities.Transaction; | ||
import com.pecacm.backend.enums.EventRole; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface TransactionRepository extends JpaRepository<Transaction, Integer> { | ||
List<Transaction> findByUserIdAndRole(Integer userId, EventRole role); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldnt it be better to get emai from jwt instead of passing user id in url ? @harshjohar 🤔
Rest lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, actually better idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed userId from path