Skip to content

Tickets save search#68

Open
timk01 wants to merge 7 commits intomainfrom
tickets_save_search
Open

Tickets save search#68
timk01 wants to merge 7 commits intomainfrom
tickets_save_search

Conversation

@timk01
Copy link
Copy Markdown
Collaborator

@timk01 timk01 commented Dec 11, 2022

Tickets save search

Comment thread telegram-bot/src/main/java/ru/otus/flightsearch/service/BotBuyerService.java Outdated
Comment thread telegram-bot/src/main/java/ru/otus/flightsearch/service/TicketEditor.java Outdated
Comment thread telegram-bot/src/main/java/ru/otus/flightsearch/service/TicketEditor.java Outdated
Comment thread telegram-bot/src/main/java/ru/otus/flightsearch/component/FlightSearcherBot.java Outdated
Comment thread buyer/src/main/java/ru/otus/buyer/controller/BuyerController.java Outdated
added ticket entity, ticketrecord
added mapped to botservice
changed error handler to specific one
changed error handler to specific one

@PostMapping
public void saveUserData(@RequestBody BuyerRecord buyerRecord) {
@PostMapping("/buyer-info-save")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do no use verbs in the path: https://restfulapi.net/resource-naming/

@Setter
@Accessors(chain = true)
public class Buyer {
public class BuyerModel {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is the reason to change name?


public List<TicketRecordDto> getTickets(/*Long buyerId*/) {
return ticketRepository.findAll().stream().map(ticketModelTicketRecordDtoConverter::convert).toList();
// return ticketRepository.findById(buyerId).stream().toList();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please remove redundant comments


import org.springframework.data.annotation.Id;

public record BuyerRecordDto(@Id Long id, String firstName, boolean isBot, String lastName, String userName) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do you named the class with Record suffix?

Timestamp returnDate, Integer numberOfChanges, Long duration, Long distance) {

@Override
public String toString() {
Copy link
Copy Markdown
Collaborator

@LostKali LostKali Dec 30, 2022

Choose a reason for hiding this comment

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

Do we need special format of to string instead of the produced by the record feature?

processAirportRequest(update);
} else if (inputMessage.startsWith(SAVE_TICKET)) {
saveTicket(update);
} else if (inputMessage.startsWith(SHOW_SAVED_TICKETS)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please try to use the Strategy pattern

public void postBuyerInfo(BuyerRecordDto buyerRecordDto) {
BuyerRecordDto sendBuyerRecordDto = restTemplate.postForObject
(
builder.setPath(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do not create path for every method call

if (sendBuyerRecord != null) {
log.info("posted info: {}", sendBuyerRecord.id());
public void saveBuyerChosenTicket(String sendTicketRecord) {
ObjectMapper objectMapper = new ObjectMapper();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

define as a bean and inject into the class

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