Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

sedub01
Copy link
Collaborator

@sedub01 sedub01 commented Jun 9, 2024

@sedub01 sedub01 requested a review from vladimirshefer June 9, 2024 10:32

@Secured(RoleEntity.Roles.ADMIN)
@PostMapping
public void createClub() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь тоже надо сделать чтобы принималось dto
не дефолты.
плз

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нам не нуден эндпоинт для создания дефолтного клуба. он будет создан и так черещ миграции. этот метод не нужен. нужен просто "сощдать клуб"

Copy link
Collaborator Author

@sedub01 sedub01 Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не понял, но да ладно: просто удалю метод

В таком случае константы тоже не нужны, поэтому и их удаляю

Copy link
Owner

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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostMapping plz

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну да, там уже стоит POST

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а, ой, put

@sedub01 sedub01 force-pushed the feature/create-clubs branch from 028cefc to 9d7e552 Compare June 9, 2024 15:41

@Secured(RoleEntity.Roles.ADMIN)
@PostMapping
public void createClub() {
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PutMapping
и путь /clubs/:id

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну как бы этот айдишник можно передавать в ДТО, ну да ладно

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, можно, но по restful спецификации айдишник должен быть в пути. айдишник в дто мы либо проверяем на равенство либо тупо игнорируем

private String description;
private String location;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у нас кажжется в других дто использовалась константа для формата. можешь ее найти м заиспользовать?

Copy link
Owner

@vladimirshefer vladimirshefer left a 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")
Copy link
Owner

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(
Copy link
Owner

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

.user(user)
.build();

subscriptionRepository.save(subscription);
Copy link
Owner

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

Comment on lines 249 to 252
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();
Copy link
Owner

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

Comment on lines 11 to 14
@Override
List<ClubEntity> findAll();
Copy link
Owner

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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Owner

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

UNIQUE(name, location)
);

INSERT INTO clubs_table (id, name, description, location)
Copy link
Owner

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');
Copy link
Owner

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?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with random plz

…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
@sedub01 sedub01 force-pushed the feature/create-clubs branch from 3826d65 to 665bdd1 Compare June 15, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants