From 969f29ce9e67137370372fa602c13efb25c7a1a7 Mon Sep 17 00:00:00 2001 From: Maslyna Date: Wed, 12 Apr 2023 16:58:09 +0200 Subject: [PATCH 1/4] Refactored code: - login and register now returns only TokenDTO --- .../user/controller/AuthenticationController.java | 5 +++-- .../java/com/provedcode/user/model/dto/TokenDTO.java | 6 ++++++ .../user/service/AuthenticationService.java | 6 +++--- .../user/service/impl/AuthenticationServiceImpl.java | 11 +++++------ 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/provedcode/user/model/dto/TokenDTO.java diff --git a/src/main/java/com/provedcode/user/controller/AuthenticationController.java b/src/main/java/com/provedcode/user/controller/AuthenticationController.java index 2a04c69..5789835 100644 --- a/src/main/java/com/provedcode/user/controller/AuthenticationController.java +++ b/src/main/java/com/provedcode/user/controller/AuthenticationController.java @@ -2,6 +2,7 @@ import com.provedcode.user.model.dto.RegistrationDTO; import com.provedcode.user.model.dto.SessionInfoDTO; +import com.provedcode.user.model.dto.TokenDTO; import com.provedcode.user.service.AuthenticationService; import jakarta.validation.Valid; import lombok.AllArgsConstructor; @@ -18,13 +19,13 @@ public class AuthenticationController { AuthenticationService authenticationService; @PostMapping("/login") - SessionInfoDTO login(Authentication authentication) { + TokenDTO login(Authentication authentication) { return authenticationService.login(authentication.getName(), authentication.getAuthorities()); } @PostMapping("/register") @ResponseStatus(HttpStatus.CREATED) - SessionInfoDTO register(@RequestBody @Valid RegistrationDTO user) { + TokenDTO register(@RequestBody @Valid RegistrationDTO user) { return authenticationService.register(user); } diff --git a/src/main/java/com/provedcode/user/model/dto/TokenDTO.java b/src/main/java/com/provedcode/user/model/dto/TokenDTO.java new file mode 100644 index 0000000..60f09ef --- /dev/null +++ b/src/main/java/com/provedcode/user/model/dto/TokenDTO.java @@ -0,0 +1,6 @@ +package com.provedcode.user.model.dto; + +public record TokenDTO( + String token +) { +} diff --git a/src/main/java/com/provedcode/user/service/AuthenticationService.java b/src/main/java/com/provedcode/user/service/AuthenticationService.java index 743015d..c48751d 100644 --- a/src/main/java/com/provedcode/user/service/AuthenticationService.java +++ b/src/main/java/com/provedcode/user/service/AuthenticationService.java @@ -1,12 +1,12 @@ package com.provedcode.user.service; import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.SessionInfoDTO; +import com.provedcode.user.model.dto.TokenDTO; import org.springframework.security.core.GrantedAuthority; import java.util.Collection; public interface AuthenticationService { - SessionInfoDTO login(String name, Collection authorities); - SessionInfoDTO register(RegistrationDTO user); + TokenDTO login(String name, Collection authorities); + TokenDTO register(RegistrationDTO user); } diff --git a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java index 8911bb6..005f204 100644 --- a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java +++ b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java @@ -4,7 +4,7 @@ import com.provedcode.talent.repo.TalentRepository; import com.provedcode.user.model.Role; import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.SessionInfoDTO; +import com.provedcode.user.model.dto.TokenDTO; import com.provedcode.user.model.entity.Authority; import com.provedcode.user.model.entity.UserInfo; import com.provedcode.user.repo.AuthorityRepository; @@ -40,12 +40,12 @@ public class AuthenticationServiceImpl implements AuthenticationService { PasswordEncoder passwordEncoder; @Transactional - public SessionInfoDTO login(String name, Collection authorities) { - return new SessionInfoDTO("User {%s} log-in".formatted(name), generateJWTToken(name, authorities)); + public TokenDTO login(String name, Collection authorities) { + return new TokenDTO(generateJWTToken(name, authorities)); } @Transactional - public SessionInfoDTO register(RegistrationDTO user) { + public TokenDTO register(RegistrationDTO user) { if (userInfoRepository.existsByLogin(user.login())) { throw new ResponseStatusException(HttpStatus.CONFLICT, String.format("user with login = {%s} already exists", user.login())); @@ -72,8 +72,7 @@ public SessionInfoDTO register(RegistrationDTO user) { log.info("user with login {%s} was saved, his authorities: %s".formatted(userLogin, userAuthorities)); - return new SessionInfoDTO("User: {%s} was registered".formatted(userLogin), - generateJWTToken(userLogin, userAuthorities)); + return new TokenDTO(generateJWTToken(userLogin, userAuthorities)); } private String generateJWTToken(String name, Collection authorities) { From 2595c90d8316a9e810461985f63b8d3451c6e006 Mon Sep 17 00:00:00 2001 From: Maslyna Date: Wed, 12 Apr 2023 17:06:52 +0200 Subject: [PATCH 2/4] Refactored code: - DB content RickRolled :) --- src/main/resources/data.sql | 236 ++++++++++++++++++------------------ 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 6165325..a91ac91 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -11,11 +11,11 @@ values ('Serhii', 'Soloviov', 'Java-Developer', 'https://i.pinimg.com/564x/e1/08 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Serhii Soloviov bio', 'Serhii Soloviov addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Java Core'); insert into talent_talents (talent_id, talent_name) @@ -31,17 +31,17 @@ values ((select id from talent order by id desc limit 1), 'second_contact'); insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2022-01-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2022-01-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2023-03-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-03-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'HIDDEN', '2021-06-08 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'HIDDEN', '2021-06-08 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'SerhiiSoloviov@gmail.com', 'password'); @@ -54,11 +54,11 @@ values ('Mykhailo', 'Ordyntsev', 'Java-Developer', 'https://i.pinimg.com/564x/c2 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Mykhailo Ordyntsev bio', 'Mykhailo Ordyntsev addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Java Core'); insert into talent_talents (talent_id, talent_name) @@ -74,17 +74,17 @@ values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_sec insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'DRAFT', '2022-08-07 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'DRAFT', '2022-08-07 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'HIDDEN', '2022-04-08 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'HIDDEN', '2022-04-08 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2022-09-02 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2022-09-02 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev@gmail.com', 'password'); @@ -97,11 +97,11 @@ values ('Denis', 'Boyko', 'Java-Developer', 'https://i.pinimg.com/564x/2a/0c/08/ insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Denis Boyko bio', 'Denis Boyko addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Java Core'); insert into talent_talents (talent_id, talent_name) @@ -115,17 +115,17 @@ values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_con insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'DenisBoyko_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'DRAFT', '2022-02-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'DRAFT', '2022-02-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2021-09-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2021-09-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-04-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-04-04 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'DenisBoyko@gmail.com', 'password'); @@ -138,11 +138,11 @@ values ('Ihor', 'Schurenko', 'Java-Developer', 'https://i.pinimg.com/564x/e1/11/ insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Ihor Shchurenko bio', 'Ihor Shchurenko addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Java Core'); insert into talent_talents (talent_id, talent_name) @@ -154,21 +154,21 @@ values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'IhorShchurenko_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2021-08-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2021-08-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2022-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2022-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-05-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-05-04 16:00:19'); insert into user_info (talent_id, login, password) -values ((select id from talent order by id desc limit 1), 'DmytroUzun@gmail.com', 'password'); +values ((select id from talent order by id desc limit 1), 'IhorShchurenko@gmail.com', 'password'); insert into user_authorities (user_id, authority_id) values ((select id from user_info order by id desc limit 1), (select authority.id from authority where id = 1)); @@ -178,11 +178,11 @@ values ('Dmytro', 'Uzun', 'Dev-Ops', 'https://i.pinimg.com/564x/1c/af/87/1caf877 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Dmytro Uzun bio', 'Dmytro Uzun addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Git'); insert into talent_talents (talent_id, talent_name) @@ -196,18 +196,18 @@ values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_con insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'DmytroUzun_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-02-08 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-02-08 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2021-03-03 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2021-03-03 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-09-05 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-09-05 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'DmytroUzun@gmail.com', 'password'); @@ -220,11 +220,11 @@ values ('Viktor', 'Voloshko', 'Dev-Ops', 'https://i.pinimg.com/564x/a9/51/ab/a95 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Viktor Voloshko bio', 'Viktor Voloshko addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Git'); insert into talent_talents (talent_id, talent_name) @@ -236,18 +236,18 @@ values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'HIDDEN', '2022-02-09 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'HIDDEN', '2022-02-09 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2020-04-02 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2020-04-02 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-08-06 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-08-06 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'ViktorVoloshko@gmail.com', 'password'); @@ -260,11 +260,11 @@ values ('Olha', 'Moiseienko', 'QA', 'https://i.pinimg.com/564x/6d/9d/43/6d9d437b insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Olha Moiseienko bio', 'Olha Moiseienko addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Git'); insert into talent_talents (talent_id, talent_name) @@ -278,18 +278,18 @@ values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'HIDDEN', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'HIDDEN', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'PUBLISHED', '2022-09-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'PUBLISHED', '2022-09-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2021-01-09 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2021-01-09 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko@gmail.com', 'password'); @@ -302,11 +302,11 @@ values ('Maxim', 'Kiyashko', 'QA', 'https://i.pinimg.com/564x/80/2d/58/802d58b03 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Maxim Kiyashko', 'Ihor Shchurenko addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Git'); insert into talent_talents (talent_id, talent_name) @@ -318,18 +318,18 @@ values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_ insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'MaximKiyashko_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-08-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-08-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2023-01-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-01-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'PUBLISHED', '2023-02-09 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'PUBLISHED', '2023-02-09 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'MaximKiyashko@gmail.com', 'password'); @@ -342,11 +342,11 @@ values ('Nikolaiev', 'Oleksii', 'QA', 'https://i.pinimg.com/564x/54/d1/0d/54d10d insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Nikolaiev Oleksii bio', 'Nikolaiev Oleksii addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'QA'); insert into talent_talents (talent_id, talent_name) @@ -360,18 +360,18 @@ values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_seco insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'HIDDEN', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'HIDDEN', '2023-06-04 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio@gmail.com', 'password'); @@ -384,11 +384,11 @@ values ('Artem', 'Lytvynenko', 'QA', 'https://i.pinimg.com/564x/87/63/55/8763550 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Artem Lytvynenko bio', 'Artem Lytvynenko addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'QA'); insert into talent_talents (talent_id, talent_name) @@ -400,18 +400,18 @@ values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_secon insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'HIDDEN', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'HIDDEN', '2023-06-04 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko@gmail.com', 'password'); @@ -424,11 +424,11 @@ values ('Daniil', 'Yevtukhov', 'Java-Script-Developer', 'https://i.pinimg.com/56 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Daniil Yevtukhov bio', 'Daniil Yevtukhov addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'JavaScript Core'); insert into talent_talents (talent_id, talent_name) @@ -440,18 +440,18 @@ values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_secon insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'HIDDEN', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'HIDDEN', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov@gmail.com', 'password'); @@ -464,11 +464,11 @@ values ('Ruslan', 'Morozov', 'Java-Script-Developer', 'https://i.pinimg.com/736x insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Ruslan Morozov bio', 'Ruslan Morozov addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'JavaScript Core'); insert into talent_talents (talent_id, talent_name) @@ -482,18 +482,18 @@ values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_ insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'RuslanMorozov_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'RuslanMorozov@gmail.com', 'password'); @@ -506,11 +506,11 @@ values ('Ihor', 'Kopieichykov', 'Java-Script-Developer', 'https://i.pinimg.com/5 insert into talent_description (talent_id, BIO, addition_info) values((select id from talent order by id desc limit 1), 'Ihor Kopieichykov bio', 'Ihor Kopieichykov addition info'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_first_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_second_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_third_link'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'JavaScript Core'); insert into talent_talents (talent_id, talent_name) @@ -524,18 +524,18 @@ values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_seco insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_third_contact'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://first_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://second_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'http://third_file'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://first_link', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'PUBLISHED', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://second_link', 'text to second proof', 'PUBLISHED', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'PUBLISHED', '2023-06-04 16:00:19'); insert into talent_proofs (talent_id, link, text, status, created) -values ((select id from talent order by id desc limit 1), 'http://third_link', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19'); +values ((select id from talent order by id desc limit 1), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'IhorKopieichykov@gmail.com', 'password'); From 417972785bc05ba5898c9ffcfe87f9ae81494df1 Mon Sep 17 00:00:00 2001 From: Denis Boyko Date: Wed, 12 Apr 2023 19:17:02 +0300 Subject: [PATCH 3/4] add ID in TokenDTO --- .../controller/AuthenticationController.java | 1 - .../provedcode/user/model/dto/TokenDTO.java | 3 +- .../impl/AuthenticationServiceImpl.java | 42 +++++++++++-------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/provedcode/user/controller/AuthenticationController.java b/src/main/java/com/provedcode/user/controller/AuthenticationController.java index 5789835..17ae87b 100644 --- a/src/main/java/com/provedcode/user/controller/AuthenticationController.java +++ b/src/main/java/com/provedcode/user/controller/AuthenticationController.java @@ -1,7 +1,6 @@ package com.provedcode.user.controller; import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.SessionInfoDTO; import com.provedcode.user.model.dto.TokenDTO; import com.provedcode.user.service.AuthenticationService; import jakarta.validation.Valid; diff --git a/src/main/java/com/provedcode/user/model/dto/TokenDTO.java b/src/main/java/com/provedcode/user/model/dto/TokenDTO.java index 60f09ef..582e687 100644 --- a/src/main/java/com/provedcode/user/model/dto/TokenDTO.java +++ b/src/main/java/com/provedcode/user/model/dto/TokenDTO.java @@ -1,6 +1,7 @@ package com.provedcode.user.model.dto; public record TokenDTO( - String token + String token, + Long id ) { } diff --git a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java index 005f204..a74091e 100644 --- a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java +++ b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java @@ -24,10 +24,12 @@ import java.time.Instant; import java.util.Collection; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import static java.time.temporal.ChronoUnit.MINUTES; +import static org.springframework.http.HttpStatus.NOT_FOUND; @Service @AllArgsConstructor @@ -41,27 +43,31 @@ public class AuthenticationServiceImpl implements AuthenticationService { @Transactional public TokenDTO login(String name, Collection authorities) { - return new TokenDTO(generateJWTToken(name, authorities)); + Optional id = userInfoRepository.findByLogin(name).map(userInfo -> userInfo.getTalentId()); + if (id.isEmpty()) { + throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); + } + return new TokenDTO(generateJWTToken(name, authorities), id.get()); } @Transactional public TokenDTO register(RegistrationDTO user) { if (userInfoRepository.existsByLogin(user.login())) { throw new ResponseStatusException(HttpStatus.CONFLICT, - String.format("user with login = {%s} already exists", user.login())); + String.format("user with login = {%s} already exists", user.login())); } Talent talent = Talent.builder() - .firstName(user.firstName()) - .lastName(user.lastName()) - .specialization(user.specialization()) - .build(); + .firstName(user.firstName()) + .lastName(user.lastName()) + .specialization(user.specialization()) + .build(); talentEntityRepository.save(talent); UserInfo userInfo = UserInfo.builder() - .talentId(talent.getId()) - .login(user.login()) - .password(passwordEncoder.encode(user.password())) - .build(); + .talentId(talent.getId()) + .login(user.login()) + .password(passwordEncoder.encode(user.password())) + .build(); userInfo.setAuthorities(Set.of(authorityRepository.findByAuthority(Role.TALENT).orElseThrow())); userInfoRepository.save(userInfo); @@ -72,7 +78,7 @@ public TokenDTO register(RegistrationDTO user) { log.info("user with login {%s} was saved, his authorities: %s".formatted(userLogin, userAuthorities)); - return new TokenDTO(generateJWTToken(userLogin, userAuthorities)); + return new TokenDTO(generateJWTToken(userLogin, userAuthorities), talent.getId()); } private String generateJWTToken(String name, Collection authorities) { @@ -80,13 +86,13 @@ private String generateJWTToken(String name, Collection Date: Wed, 12 Apr 2023 19:57:36 +0300 Subject: [PATCH 4/4] rename TokenDTO to UserInfoDTO and add login,firstName,lastName,image --- .../controller/AuthenticationController.java | 6 ++-- .../provedcode/user/model/dto/TokenDTO.java | 7 ----- .../user/model/dto/UserInfoDTO.java | 15 +++++++++ .../user/service/AuthenticationService.java | 6 ++-- .../impl/AuthenticationServiceImpl.java | 31 ++++++++++++++++--- 5 files changed, 47 insertions(+), 18 deletions(-) delete mode 100644 src/main/java/com/provedcode/user/model/dto/TokenDTO.java create mode 100644 src/main/java/com/provedcode/user/model/dto/UserInfoDTO.java diff --git a/src/main/java/com/provedcode/user/controller/AuthenticationController.java b/src/main/java/com/provedcode/user/controller/AuthenticationController.java index 17ae87b..cba29cd 100644 --- a/src/main/java/com/provedcode/user/controller/AuthenticationController.java +++ b/src/main/java/com/provedcode/user/controller/AuthenticationController.java @@ -1,7 +1,7 @@ package com.provedcode.user.controller; import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.TokenDTO; +import com.provedcode.user.model.dto.UserInfoDTO; import com.provedcode.user.service.AuthenticationService; import jakarta.validation.Valid; import lombok.AllArgsConstructor; @@ -18,13 +18,13 @@ public class AuthenticationController { AuthenticationService authenticationService; @PostMapping("/login") - TokenDTO login(Authentication authentication) { + UserInfoDTO login(Authentication authentication) { return authenticationService.login(authentication.getName(), authentication.getAuthorities()); } @PostMapping("/register") @ResponseStatus(HttpStatus.CREATED) - TokenDTO register(@RequestBody @Valid RegistrationDTO user) { + UserInfoDTO register(@RequestBody @Valid RegistrationDTO user) { return authenticationService.register(user); } diff --git a/src/main/java/com/provedcode/user/model/dto/TokenDTO.java b/src/main/java/com/provedcode/user/model/dto/TokenDTO.java deleted file mode 100644 index 582e687..0000000 --- a/src/main/java/com/provedcode/user/model/dto/TokenDTO.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.provedcode.user.model.dto; - -public record TokenDTO( - String token, - Long id -) { -} diff --git a/src/main/java/com/provedcode/user/model/dto/UserInfoDTO.java b/src/main/java/com/provedcode/user/model/dto/UserInfoDTO.java new file mode 100644 index 0000000..4b2a1f1 --- /dev/null +++ b/src/main/java/com/provedcode/user/model/dto/UserInfoDTO.java @@ -0,0 +1,15 @@ +package com.provedcode.user.model.dto; + +import lombok.Builder; + +@Builder +public record UserInfoDTO( + String token, + Long id, + String login, + String firstName, + String lastName, + String image + +) { +} diff --git a/src/main/java/com/provedcode/user/service/AuthenticationService.java b/src/main/java/com/provedcode/user/service/AuthenticationService.java index c48751d..7814ac8 100644 --- a/src/main/java/com/provedcode/user/service/AuthenticationService.java +++ b/src/main/java/com/provedcode/user/service/AuthenticationService.java @@ -1,12 +1,12 @@ package com.provedcode.user.service; import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.TokenDTO; +import com.provedcode.user.model.dto.UserInfoDTO; import org.springframework.security.core.GrantedAuthority; import java.util.Collection; public interface AuthenticationService { - TokenDTO login(String name, Collection authorities); - TokenDTO register(RegistrationDTO user); + UserInfoDTO login(String name, Collection authorities); + UserInfoDTO register(RegistrationDTO user); } diff --git a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java index a74091e..654a377 100644 --- a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java +++ b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java @@ -4,7 +4,7 @@ import com.provedcode.talent.repo.TalentRepository; import com.provedcode.user.model.Role; import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.TokenDTO; +import com.provedcode.user.model.dto.UserInfoDTO; import com.provedcode.user.model.entity.Authority; import com.provedcode.user.model.entity.UserInfo; import com.provedcode.user.repo.AuthorityRepository; @@ -42,16 +42,30 @@ public class AuthenticationServiceImpl implements AuthenticationService { PasswordEncoder passwordEncoder; @Transactional - public TokenDTO login(String name, Collection authorities) { + public UserInfoDTO login(String name, Collection authorities) { Optional id = userInfoRepository.findByLogin(name).map(userInfo -> userInfo.getTalentId()); if (id.isEmpty()) { throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); } - return new TokenDTO(generateJWTToken(name, authorities), id.get()); + + Optional userInfo = userInfoRepository.findByLogin(name); + if (userInfo.isEmpty()) { + throw new ResponseStatusException(NOT_FOUND, String.format("talent with name = %s not found", name)); + } + Optional talent = talentEntityRepository.findById(userInfo.get().getTalentId()); + + return UserInfoDTO.builder() + .token(generateJWTToken(name, authorities)) + .id(talent.get().getId()) + .login(userInfo.get().getLogin()) + .firstName(talent.get().getFirstName()) + .lastName(talent.get().getLastName()) + .image(talent.get().getImage()) + .build(); } @Transactional - public TokenDTO register(RegistrationDTO user) { + public UserInfoDTO register(RegistrationDTO user) { if (userInfoRepository.existsByLogin(user.login())) { throw new ResponseStatusException(HttpStatus.CONFLICT, String.format("user with login = {%s} already exists", user.login())); @@ -78,7 +92,14 @@ public TokenDTO register(RegistrationDTO user) { log.info("user with login {%s} was saved, his authorities: %s".formatted(userLogin, userAuthorities)); - return new TokenDTO(generateJWTToken(userLogin, userAuthorities), talent.getId()); + return UserInfoDTO.builder() + .token(generateJWTToken(userLogin, userAuthorities)) + .id(talent.getId()) + .login(userInfo.getLogin()) + .firstName(talent.getFirstName()) + .lastName(talent.getLastName()) + .image(talent.getImage()) + .build(); } private String generateJWTToken(String name, Collection authorities) {