-
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
feat: add clubs + subscriptions #19
base: master
Are you sure you want to change the base?
Conversation
src/main/java/com/chessgrinder/chessgrinder/entities/SubscriptionEntity.java
Show resolved
Hide resolved
|
||
@Secured(RoleEntity.Roles.ADMIN) | ||
@PostMapping | ||
public void createClub() { |
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.
здесь тоже надо сделать чтобы принималось dto
не дефолты.
плз
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.
нам не нуден эндпоинт для создания дефолтного клуба. он будет создан и так черещ миграции. этот метод не нужен. нужен просто "сощдать клуб"
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.
Не понял, но да ладно: просто удалю метод
В таком случае константы тоже не нужны, поэтому и их удаляю
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.
константа нужна только одна - ID дефолтного клуба
@@ -238,4 +239,26 @@ public void signUp( | |||
.build() | |||
); | |||
} | |||
|
|||
@Secured(RoleEntity.Roles.ADMIN) | |||
@PatchMapping("/{userId}/subscription") |
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.
PostMapping plz
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.
Ну да, там уже стоит POST
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.
а, ой, put
src/main/java/com/chessgrinder/chessgrinder/entities/SubscriptionEntity.java
Show resolved
Hide resolved
src/main/resources/db/migration/V202406080000__create_table__clubs_table.sql
Outdated
Show resolved
Hide resolved
028cefc
to
9d7e552
Compare
|
||
@Secured(RoleEntity.Roles.ADMIN) | ||
@PostMapping | ||
public void createClub() { |
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.
нам не нуден эндпоинт для создания дефолтного клуба. он будет создан и так черещ миграции. этот метод не нужен. нужен просто "сощдать клуб"
} | ||
|
||
@Secured(RoleEntity.Roles.ADMIN) | ||
@PatchMapping |
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.
PutMapping
и путь /clubs/:id
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.
Ну как бы этот айдишник можно передавать в ДТО, ну да ладно
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.
да, можно, но по restful спецификации айдишник должен быть в пути. айдишник в дто мы либо проверяем на равенство либо тупо игнорируем
src/main/java/com/chessgrinder/chessgrinder/controller/ClubController.java
Show resolved
Hide resolved
private String description; | ||
private String location; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm") |
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.
у нас кажжется в других дто использовалась константа для формата. можешь ее найти м заиспользовать?
src/main/java/com/chessgrinder/chessgrinder/controller/UserController.java
Outdated
Show resolved
Hide resolved
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.
- add clubDto to tournamentDto
on request
POST /tournament
create tournament with link to the tournamentDto.club
or if club==null, then club=clubRepo.findById(ApplicationConstants.DEFAULT_CLUB_ID)
} | ||
|
||
@Secured(RoleEntity.Roles.ADMIN) | ||
@PostMapping("/createClub") |
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.
just /
@PathVariable UUID clubId, | ||
@RequestBody ClubDto clubDto | ||
) { | ||
ClubEntity club = clubRepository.findById(clubId).orElseThrow( |
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.
nitpick: optional: line separator before dot
src/main/java/com/chessgrinder/chessgrinder/controller/ClubController.java
Outdated
Show resolved
Hide resolved
.user(user) | ||
.build(); | ||
|
||
subscriptionRepository.save(subscription); |
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.
- create method
GET /user/{:id}/subscription
to get all subscriptions of user
UserEntity user = userRepository.findById(userId).orElseThrow(); | ||
ClubEntity club = clubRepository.findById(UUID.fromString(data.getClub().getId())).orElseThrow(); | ||
SubscriptionLevelEntity subscriptionLevel = subscriptionLevelRepository.findById( | ||
UUID.fromString(data.getSubscriptionLevel().getId())).orElseThrow(); |
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.
nitpick: return 404 not found by id :id
@Override | ||
List<ClubEntity> findAll(); |
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.
there is another base interface which already returns list from find all
see other repositories
List<ClubEntity> clubs = clubRepository.findAll(); | ||
|
||
return clubs.stream().map(clubMapper::toDto) | ||
.sorted(Comparator.comparing(ClubDto::getRegistrationDate)) |
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.
remove
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.
or you can initially sort entities by createdAt, then map them all
src/main/resources/db/migration/V202406080000__create_table__clubs_table.sql
Show resolved
Hide resolved
UNIQUE(name, location) | ||
); | ||
|
||
INSERT INTO clubs_table (id, name, description, location) |
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.
- createdBy = "DATABASE MIGRATION TOOL"
); | ||
|
||
INSERT INTO clubs_table (id, name, description, location) | ||
VALUES('12345678-9abc-def0-1234-56789abcdef0', 'DEFAULT CLUB', 'DEFAULT DESCRIPTION', 'DEFAULT LOCATION'); |
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.
why dont u change to more random UUID?
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.
replace with random plz
src/main/java/com/chessgrinder/chessgrinder/chessengine/JavafoPairingStrategyImpl.java
Outdated
Show resolved
Hide resolved
… getById, SubscriptionMapper
ea734a9
to
ac249ca
Compare
ac249ca
to
025e759
Compare
…fer/ChessGrinder into feature/create-clubs # Conflicts: # src/main/java/com/chessgrinder/chessgrinder/controller/ClubController.java # src/main/java/com/chessgrinder/chessgrinder/controller/UserController.java # src/main/java/com/chessgrinder/chessgrinder/service/TournamentService.java
3826d65
to
665bdd1
Compare
@vladimirshefer