From 9f01f390d8836757876a24039193764c47cb2643 Mon Sep 17 00:00:00 2001 From: Maslyna Date: Mon, 3 Apr 2023 22:04:04 +0200 Subject: [PATCH 01/30] Changed db structure --- .../controller/AuthenticationController.java | 64 +- .../user/mapper/impl/UserInfoMapperImpl.java | 6 +- .../user/model/entity/Authority.java | 5 + .../user/model/entity/UserAuthority.java | 54 +- .../user/model/entity/UserInfo.java | 13 +- .../user/repo/UserAuthorityRepository.java | 10 - .../impl/AuthenticationServiceImpl.java | 197 ++-- src/main/resources/data.sql | 842 +++++++++--------- src/main/resources/schema.sql | 44 +- 9 files changed, 615 insertions(+), 620 deletions(-) delete mode 100644 src/main/java/com/provedcode/user/repo/UserAuthorityRepository.java diff --git a/src/main/java/com/provedcode/user/controller/AuthenticationController.java b/src/main/java/com/provedcode/user/controller/AuthenticationController.java index 4bd9bd0..d4ef163 100644 --- a/src/main/java/com/provedcode/user/controller/AuthenticationController.java +++ b/src/main/java/com/provedcode/user/controller/AuthenticationController.java @@ -1,32 +1,32 @@ -package com.provedcode.user.controller; - -import com.provedcode.user.model.dto.RegistrationDTO; -import com.provedcode.user.model.dto.SessionInfoDTO; -import com.provedcode.user.service.AuthenticationService; -import jakarta.validation.Valid; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.security.core.Authentication; -import org.springframework.web.bind.annotation.*; - -@RestController -@AllArgsConstructor -@Slf4j -@RequestMapping("/api/talents") -@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE}) -public class AuthenticationController { - AuthenticationService authenticationService; - - @PostMapping("/login") - SessionInfoDTO login(Authentication authentication) { - return authenticationService.login(authentication.getName(), authentication.getAuthorities()); - } - - @PostMapping("/register") - @ResponseStatus(HttpStatus.CREATED) - SessionInfoDTO register(@RequestBody @Valid RegistrationDTO user) { - return authenticationService.register(user); - } - -} +//package com.provedcode.user.controller; +// +//import com.provedcode.user.model.dto.RegistrationDTO; +//import com.provedcode.user.model.dto.SessionInfoDTO; +//import com.provedcode.user.service.AuthenticationService; +//import jakarta.validation.Valid; +//import lombok.AllArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.http.HttpStatus; +//import org.springframework.security.core.Authentication; +//import org.springframework.web.bind.annotation.*; +// +//@RestController +//@AllArgsConstructor +//@Slf4j +//@RequestMapping("/api/talents") +//@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE}) +//public class AuthenticationController { +// AuthenticationService authenticationService; +// +// @PostMapping("/login") +// SessionInfoDTO login(Authentication authentication) { +// return authenticationService.login(authentication.getName(), authentication.getAuthorities()); +// } +// +// @PostMapping("/register") +// @ResponseStatus(HttpStatus.CREATED) +// SessionInfoDTO register(@RequestBody @Valid RegistrationDTO user) { +// return authenticationService.register(user); +// } +// +//} diff --git a/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java b/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java index 9db05e9..a0c4a5f 100644 --- a/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java +++ b/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java @@ -13,11 +13,9 @@ public class UserInfoMapperImpl implements UserInfoMapper { public UserDetails toUserDetails(UserInfo user) { return User.withUsername(user.getLogin()) .password(user.getPassword()) - .authorities(user.getUserAuthorities() + .authorities(user.getAuthorities() .stream() - .map(i -> new SimpleGrantedAuthority( - i.getAuthority() - .getAuthority())) + .map(i -> new SimpleGrantedAuthority(i.getAuthority())) .toList()) .build(); } diff --git a/src/main/java/com/provedcode/user/model/entity/Authority.java b/src/main/java/com/provedcode/user/model/entity/Authority.java index dc8a965..69c4713 100644 --- a/src/main/java/com/provedcode/user/model/entity/Authority.java +++ b/src/main/java/com/provedcode/user/model/entity/Authority.java @@ -6,6 +6,9 @@ import lombok.Getter; import lombok.Setter; +import java.util.LinkedHashSet; +import java.util.Set; + @Getter @Setter @Entity @@ -19,4 +22,6 @@ public class Authority { @NotNull @Column(name = "authority", length = 20) private String authority; + @ManyToMany(mappedBy = "authorities", cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + private Set userInfoes = new LinkedHashSet<>(); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/user/model/entity/UserAuthority.java b/src/main/java/com/provedcode/user/model/entity/UserAuthority.java index d8bbcf7..3027027 100644 --- a/src/main/java/com/provedcode/user/model/entity/UserAuthority.java +++ b/src/main/java/com/provedcode/user/model/entity/UserAuthority.java @@ -1,27 +1,27 @@ -package com.provedcode.user.model.entity; - -import jakarta.persistence.*; -import jakarta.validation.constraints.NotNull; -import lombok.*; - -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Getter -@Setter -@Entity -@Table(name = "user_authority") -public class UserAuthority { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; - @NotNull - @ManyToOne - @JoinColumn(name = "user_id") - private UserInfo userInfo; - @NotNull - @ManyToOne - @JoinColumn(name = "authority_id") - private Authority authority; -} \ No newline at end of file +//package com.provedcode.user.model.entity; +// +//import jakarta.persistence.*; +//import jakarta.validation.constraints.NotNull; +//import lombok.*; +// +//@Builder +//@AllArgsConstructor +//@NoArgsConstructor +//@Getter +//@Setter +//@Entity +//@Table(name = "user_authority") +//public class UserAuthority { +// @Id +// @GeneratedValue(strategy = GenerationType.IDENTITY) +// @Column(name = "id", nullable = false) +// private Long id; +// @NotNull +// @ManyToOne +// @JoinColumn(name = "user_id") +// private UserInfo userInfo; +// @NotNull +// @ManyToOne +// @JoinColumn(name = "authority_id") +// private Authority authority; +//} \ No newline at end of file diff --git a/src/main/java/com/provedcode/user/model/entity/UserInfo.java b/src/main/java/com/provedcode/user/model/entity/UserInfo.java index 2f7efca..a7fb306 100644 --- a/src/main/java/com/provedcode/user/model/entity/UserInfo.java +++ b/src/main/java/com/provedcode/user/model/entity/UserInfo.java @@ -22,8 +22,8 @@ public class UserInfo { @Column(name = "id", nullable = false) private Long id; @NotNull - @Column(name = "user_id") - private Long userId; + @Column(name = "talent_id") + private Long talentId; @NotEmpty @NotNull @Column(name = "login", length = 100) @@ -33,8 +33,11 @@ public class UserInfo { @Column(name = "password") private String password; @OneToOne(orphanRemoval = true) - @JoinColumn(name = "user_id", insertable = false, updatable = false) + @JoinColumn(name = "talent_id", insertable = false, updatable = false) private Talent talent; - @OneToMany(mappedBy = "userInfo", orphanRemoval = true, fetch = FetchType.EAGER) - private Set userAuthorities = new LinkedHashSet<>(); + @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + @JoinTable(name = "user_authorities", + joinColumns = @JoinColumn(name = "user_id"), + inverseJoinColumns = @JoinColumn(name = "authority_id")) + private Set authorities = new LinkedHashSet<>(); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/user/repo/UserAuthorityRepository.java b/src/main/java/com/provedcode/user/repo/UserAuthorityRepository.java deleted file mode 100644 index ef91bfc..0000000 --- a/src/main/java/com/provedcode/user/repo/UserAuthorityRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.provedcode.user.repo; - -import com.provedcode.user.model.entity.UserAuthority; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; -import java.util.Set; - -public interface UserAuthorityRepository extends JpaRepository { -} \ No newline at end of file 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 45fc34f..73a0200 100644 --- a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java +++ b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java @@ -1,100 +1,97 @@ -package com.provedcode.user.service.impl; - -import com.provedcode.talent.model.entity.Talent; -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.entity.UserAuthority; -import com.provedcode.user.model.entity.UserInfo; -import com.provedcode.user.repo.AuthorityRepository; -import com.provedcode.user.repo.UserAuthorityRepository; -import com.provedcode.user.repo.UserInfoRepository; -import com.provedcode.user.service.AuthenticationService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.oauth2.jwt.JwtClaimsSet; -import org.springframework.security.oauth2.jwt.JwtEncoder; -import org.springframework.security.oauth2.jwt.JwtEncoderParameters; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.server.ResponseStatusException; - -import java.time.Instant; -import java.util.Collection; -import java.util.Set; -import java.util.stream.Collectors; - -import static java.time.temporal.ChronoUnit.MINUTES; - -@Service -@AllArgsConstructor -@Slf4j -public class AuthenticationServiceImpl implements AuthenticationService { - JwtEncoder jwtEncoder; - UserInfoRepository userInfoRepository; - TalentRepository talentEntityRepository; - UserAuthorityRepository userAuthorityRepository; - AuthorityRepository authorityRepository; - PasswordEncoder passwordEncoder; - - @Transactional - public SessionInfoDTO login(String name, Collection authorities) { - return new SessionInfoDTO("User {%s} log-in".formatted(name), generateJWTToken(name, authorities)); - } - - @Transactional - public SessionInfoDTO register(RegistrationDTO user) { - if (userInfoRepository.existsByLogin(user.login())) { - throw new ResponseStatusException(HttpStatus.CONFLICT, - String.format("user with login = {%s} already exists", user.login())); - } - Talent talent = Talent.builder() - .firstName(user.firstName()) - .lastName(user.lastName()) - .specialization(user.specialization()) - .build(); - talentEntityRepository.save(talent); - - UserInfo userInfo = UserInfo.builder() - .userId(talent.getId()) - .login(user.login()) - .password(passwordEncoder.encode(user.password())) - .build(); - UserAuthority userAuthority = UserAuthority.builder() - .userInfo(userInfo) - .authority(authorityRepository.findByAuthority(Role.TALENT.toString()) - .orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "this authority does`t exist"))) - .build(); - - userInfo.setUserAuthorities(Set.of(userAuthority)); - userAuthority.setUserInfo(userInfoRepository.save(userInfo)); - userAuthorityRepository.save(userAuthority); - - String userLogin = userInfo.getLogin(); - Collection userAuthorities = userInfo.getUserAuthorities().stream().map(i -> new SimpleGrantedAuthority(i.getAuthority().getAuthority())).toList(); - - 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)); - } - - private String generateJWTToken(String name, Collection authorities) { - log.info("=== POST /login === auth.name = {}", name); - log.info("=== POST /login === auth = {}", authorities); - var now = Instant.now(); - var claims = JwtClaimsSet.builder() - .issuer("self") - .issuedAt(now) - .expiresAt(now.plus(5, MINUTES)) - .subject(name) - .claim("scope", authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.joining(" "))) - .build(); - return jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue(); - } - -} +//package com.provedcode.user.service.impl; +// +//import com.provedcode.talent.model.entity.Talent; +//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.entity.UserInfo; +//import com.provedcode.user.repo.AuthorityRepository; +//import com.provedcode.user.repo.UserInfoRepository; +//import com.provedcode.user.service.AuthenticationService; +//import lombok.AllArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.http.HttpStatus; +//import org.springframework.security.core.GrantedAuthority; +//import org.springframework.security.core.authority.SimpleGrantedAuthority; +//import org.springframework.security.crypto.password.PasswordEncoder; +//import org.springframework.security.oauth2.jwt.JwtClaimsSet; +//import org.springframework.security.oauth2.jwt.JwtEncoder; +//import org.springframework.security.oauth2.jwt.JwtEncoderParameters; +//import org.springframework.stereotype.Service; +//import org.springframework.transaction.annotation.Transactional; +//import org.springframework.web.server.ResponseStatusException; +// +//import java.time.Instant; +//import java.util.Collection; +//import java.util.Set; +//import java.util.stream.Collectors; +// +//import static java.time.temporal.ChronoUnit.MINUTES; +// +//@Service +//@AllArgsConstructor +//@Slf4j +//public class AuthenticationServiceImpl implements AuthenticationService { +// JwtEncoder jwtEncoder; +// UserInfoRepository userInfoRepository; +// TalentRepository talentEntityRepository; +// AuthorityRepository authorityRepository; +// PasswordEncoder passwordEncoder; +// +//// @Transactional +//// public SessionInfoDTO login(String name, Collection authorities) { +//// return new SessionInfoDTO("User {%s} log-in".formatted(name), generateJWTToken(name, authorities)); +//// } +//// +//// @Transactional +//// public SessionInfoDTO register(RegistrationDTO user) { +//// if (userInfoRepository.existsByLogin(user.login())) { +//// throw new ResponseStatusException(HttpStatus.CONFLICT, +//// String.format("user with login = {%s} already exists", user.login())); +//// } +//// Talent talent = Talent.builder() +//// .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(); +//// UserAuthority userAuthority = UserAuthority.builder() +//// .userInfo(userInfo) +//// .authority(authorityRepository.findByAuthority(Role.TALENT.toString()) +//// .orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "this authority does`t exist"))) +//// .build(); +//// +//// userInfo.setUserAuthorities(Set.of(userAuthority)); +//// userAuthority.setUserInfo(userInfoRepository.save(userInfo)); +//// userAuthorityRepository.save(userAuthority); +//// +//// String userLogin = userInfo.getLogin(); +//// Collection userAuthorities = userInfo.getUserAuthorities().stream().map(i -> new SimpleGrantedAuthority(i.getAuthority().getAuthority())).toList(); +//// +//// 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)); +//// } +// +// private String generateJWTToken(String name, Collection authorities) { +// log.info("=== POST /login === auth.name = {}", name); +// log.info("=== POST /login === auth = {}", authorities); +// var now = Instant.now(); +// var claims = JwtClaimsSet.builder() +// .issuer("self") +// .issuedAt(now) +// .expiresAt(now.plus(5, MINUTES)) +// .subject(name) +// .claim("scope", authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.joining(" "))) +// .build(); +// return jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue(); +// } +// +//} diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 7e1c2fb..dc177fd 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,12 +1,12 @@ insert into authority (id, authority) values (1, 'ROLE_TALENT'); --- FOR USER AUTHORITY --- SELECT USER_INFO.ID , LOGIN , PASSWORD, USER_ID , AUTHORITY FROM --- USER_INFO --- JOIN USER_AUTHORITY ON USER_ID = USER_INFO.ID --- JOIN AUTHORITY ON AUTHORITY.ID = AUTHORITY_ID - - +-- -- FOR USER AUTHORITY +-- -- SELECT USER_INFO.ID , LOGIN , PASSWORD, talent_id , AUTHORITY FROM +-- -- USER_INFO +-- -- JOIN user_authorities ON talent_id = USER_INFO.ID +-- -- JOIN AUTHORITY ON AUTHORITY.ID = id +-- +-- insert into talent (first_name, last_name, specialization, image) values ('Serhii', 'Soloviov', 'Java-Developer', 'https://i.pinimg.com/564x/e1/08/49/e10849923a8b2e85a7adf494ebd063e6.jpg'); insert into talent_description (talent_id, BIO, addition_info) @@ -38,420 +38,420 @@ values ((select id from talent order by id desc limit 1), 'second_file'); insert into talent_attached_file (talent_id, attached_file) values ((select id from talent order by id desc limit 1), 'third_file'); -insert into user_info (user_id, login, password) +insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'SerhiiSoloviov', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Mykhailo', 'Ordyntsev', 'Java-Developer', 'https://i.pinimg.com/564x/c2/41/31/c24131fe00218467721ba5bacdf0a256.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Java Core'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Hibernate'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Spring Boot'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_contact'); -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), 'MykhailoOrdyntsev_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Denis', 'Boyko', 'Java-Developer', 'https://i.pinimg.com/564x/2a/0c/08/2a0c08c421e253ca895c3fdc8c9e08d9.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Java Core'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Spring Security'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Spring Core'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'DenisBoyko_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_contact'); -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), 'DenisBoyko_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'DenisBoyko_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'DenisBoyko', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Ihor', 'Schurenko', 'Java-Developer', 'https://i.pinimg.com/564x/e1/11/2f/e1112f0b7b63644dc3e313084936dedb.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Java Core'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'REST API'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'IhorShchurenko_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_contact'); -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), 'IhorShchurenko_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'IhorShchurenko_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'DmytroUzun', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Dmytro', 'Uzun', 'Dev-Ops', 'https://i.pinimg.com/564x/1c/af/87/1caf8771ef3edf351f6f2bf6f1c0a276.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Docker'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Mentor'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'DmytroUzun_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_contact'); -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), 'DmytroUzun_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'DmytroUzun_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'DmytroUzun', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Viktor', 'Voloshko', 'Dev-Ops', 'https://i.pinimg.com/564x/a9/51/ab/a951ab682413b89617235e65564c1e5e.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Docker'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_contact'); -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), 'ViktorVoloshko_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'ViktorVoloshko', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Olha', 'Moiseienko', 'QA', 'https://i.pinimg.com/564x/6d/9d/43/6d9d437baf4db114c047d927307beb84.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Jira'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'QA'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_contact'); -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), 'OlhaMoiseienko_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko _third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Maxim', 'Kiyashko', 'QA', 'https://i.pinimg.com/564x/80/2d/58/802d58b0302985f9486893d499d3634d.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'QA'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'MaximKiyashko_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_contact'); -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), 'MaximKiyashko_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'MaximKiyashko_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'MaximKiyashko', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Nikolaiev', 'Oleksii', 'QA', 'https://i.pinimg.com/564x/54/d1/0d/54d10dfce64afefabc9fbbce5de82c87.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'QA'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_skill'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_contact'); -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), 'NikolaievOleksii_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Artem', 'Lytvynenko', 'QA', 'https://i.pinimg.com/564x/87/63/55/87635509c5fa7ee496ec351fa7e67eaa.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'QA'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Git'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_contact'); -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), 'ArtemLytvynenko_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Daniil', 'Yevtukhov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/fe/b1/37/feb137d88a3d1c8fb28796db6cbc576f.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'JavaScript Core'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'React'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_contact'); -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), 'DaniilYevtukhov_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Ruslan', 'Morozov', 'Java-Script-Developer', 'https://i.pinimg.com/736x/36/ae/0e/36ae0ea4aad656f7c3d3175bc33b8399.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'JavaScript Core'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'React'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Node.js'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'RuslanMorozov_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_contact'); -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), 'RuslanMorozov_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'RuslanMorozov_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'RuslanMorozov', 'password'); -insert into user_authority (user_id, authority_id) -values ((select id from user_info order by id desc limit 1), - (select authority.id from authority where id = 1)); - -insert into talent (first_name, last_name, specialization, image) -values ('Ihor', 'Kopieichykov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/0d/f0/83/0df083121bac75f64e3d93c7c5682d04.jpg'); -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'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_second_link'); -insert into talent_link (talent_id, link) -values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_third_link'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'JavaScript Core'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'React'); -insert into talent_skill (talent_id, skill) -values ((select id from talent order by id desc limit 1), 'Angular'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_first_contact'); -insert into talent_contact (talent_id, contact) -values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_contact'); -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), 'IhorKopieichykov_first_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_file'); -insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_third_file'); - -insert into user_info (user_id, login, password) -values ((select id from talent order by id desc limit 1), 'IhorKopieichykov', 'password'); -insert into user_authority (user_id, authority_id) +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)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Mykhailo', 'Ordyntsev', 'Java-Developer', 'https://i.pinimg.com/564x/c2/41/31/c24131fe00218467721ba5bacdf0a256.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Java Core'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Hibernate'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Spring Boot'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_contact'); +-- 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), 'MykhailoOrdyntsev_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Denis', 'Boyko', 'Java-Developer', 'https://i.pinimg.com/564x/2a/0c/08/2a0c08c421e253ca895c3fdc8c9e08d9.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Java Core'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Spring Security'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Spring Core'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'DenisBoyko_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_contact'); +-- 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), 'DenisBoyko_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'DenisBoyko_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'DenisBoyko', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Ihor', 'Schurenko', 'Java-Developer', 'https://i.pinimg.com/564x/e1/11/2f/e1112f0b7b63644dc3e313084936dedb.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Java Core'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'REST API'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_contact'); +-- 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), 'IhorShchurenko_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'DmytroUzun', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Dmytro', 'Uzun', 'Dev-Ops', 'https://i.pinimg.com/564x/1c/af/87/1caf8771ef3edf351f6f2bf6f1c0a276.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Docker'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Mentor'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'DmytroUzun_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_contact'); +-- 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), 'DmytroUzun_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'DmytroUzun_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'DmytroUzun', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Viktor', 'Voloshko', 'Dev-Ops', 'https://i.pinimg.com/564x/a9/51/ab/a951ab682413b89617235e65564c1e5e.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Docker'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_contact'); +-- 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), 'ViktorVoloshko_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Olha', 'Moiseienko', 'QA', 'https://i.pinimg.com/564x/6d/9d/43/6d9d437baf4db114c047d927307beb84.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Jira'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'QA'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_contact'); +-- 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), 'OlhaMoiseienko_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko _third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Maxim', 'Kiyashko', 'QA', 'https://i.pinimg.com/564x/80/2d/58/802d58b0302985f9486893d499d3634d.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'QA'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_contact'); +-- 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), 'MaximKiyashko_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'MaximKiyashko', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Nikolaiev', 'Oleksii', 'QA', 'https://i.pinimg.com/564x/54/d1/0d/54d10dfce64afefabc9fbbce5de82c87.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'QA'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_skill'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_contact'); +-- 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), 'NikolaievOleksii_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Artem', 'Lytvynenko', 'QA', 'https://i.pinimg.com/564x/87/63/55/87635509c5fa7ee496ec351fa7e67eaa.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'QA'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Git'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_contact'); +-- 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), 'ArtemLytvynenko_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Daniil', 'Yevtukhov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/fe/b1/37/feb137d88a3d1c8fb28796db6cbc576f.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'React'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_contact'); +-- 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), 'DaniilYevtukhov_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Ruslan', 'Morozov', 'Java-Script-Developer', 'https://i.pinimg.com/736x/36/ae/0e/36ae0ea4aad656f7c3d3175bc33b8399.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'React'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Node.js'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_contact'); +-- 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), 'RuslanMorozov_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'RuslanMorozov', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); +-- +-- insert into talent (first_name, last_name, specialization, image) +-- values ('Ihor', 'Kopieichykov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/0d/f0/83/0df083121bac75f64e3d93c7c5682d04.jpg'); +-- 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'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_second_link'); +-- insert into talent_link (talent_id, link) +-- values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_third_link'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'React'); +-- insert into talent_skill (talent_id, skill) +-- values ((select id from talent order by id desc limit 1), 'Angular'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_first_contact'); +-- insert into talent_contact (talent_id, contact) +-- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_contact'); +-- 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), 'IhorKopieichykov_first_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_file'); +-- insert into talent_attached_file (talent_id, attached_file) +-- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_third_file'); +-- +-- insert into user_info (talent_id, login, password) +-- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov', 'password'); +-- insert into user_authorities (talent_id, id) +-- values ((select id from user_info order by id desc limit 1), +-- (select authority.id from authority where id = 1)); diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 2166cfd..51d130c 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -4,9 +4,9 @@ drop table IF EXISTS talent_link CASCADE ; drop table IF EXISTS talent_contact CASCADE ; drop table IF EXISTS talent_attached_file CASCADE ; drop table IF EXISTS talent_skill CASCADE ; -drop table IF EXISTS user_authority CASCADE ; drop table IF EXISTS user_info CASCADE ; -drop table IF EXISTS authority CASCADE ; +drop table IF EXISTS user_authorities CASCADE ; +drop table IF EXISTS authority_user_infoes CASCADE ; create TABLE talent ( id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, @@ -64,29 +64,31 @@ create TABLE talent_attached_file ( alter table talent_attached_file add CONSTRAINT FK_TALENT_ATTACHED_FILE_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); --user tables-- -create TABLE user_info ( - id BIGINT AUTO_INCREMENT NOT NULL, - user_id BIGINT NOT NULL, - login VARCHAR(100) NOT NULL, - password VARCHAR(255) NOT NULL, - CONSTRAINT pk_user_info PRIMARY KEY (id) +CREATE TABLE authority +( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + authority VARCHAR(20) NOT NULL, + CONSTRAINT pk_authority PRIMARY KEY (id) ); -alter table user_info add CONSTRAINT FK_USER_INFO_ON_USER FOREIGN KEY (user_id) REFERENCES talent (id); - -create TABLE authority ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - authority VARCHAR(20) NOT NULL, - CONSTRAINT pk_authority PRIMARY KEY (id) +CREATE TABLE user_info +( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + login VARCHAR(100) NOT NULL, + password VARCHAR(255) NOT NULL, + CONSTRAINT pk_user_info PRIMARY KEY (id) ); -create TABLE user_authority ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - user_id BIGINT, - authority_id BIGINT, - CONSTRAINT pk_user_authority PRIMARY KEY (id) +CREATE TABLE user_authorities +( + user_id BIGINT NOT NULL, + authority_id BIGINT NOT NULL, + CONSTRAINT pk_user_authorities PRIMARY KEY (user_id, authority_id) ); -alter table user_authority add CONSTRAINT FK_USER_AUTHORITY_ON_AUTHORITY FOREIGN KEY (authority_id) REFERENCES authority (id); +ALTER TABLE user_info ADD CONSTRAINT FK_USER_INFO_ON_USER_UUID FOREIGN KEY (talent_id) REFERENCES talent (id); + +ALTER TABLE user_authorities ADD CONSTRAINT fk_useaut_on_authority FOREIGN KEY (authority_id) REFERENCES authority (id); -alter table user_authority add CONSTRAINT FK_USER_AUTHORITY_ON_USER FOREIGN KEY (user_id) REFERENCES user_info (id); \ No newline at end of file +ALTER TABLE user_authorities ADD CONSTRAINT fk_useaut_on_user_info FOREIGN KEY (user_id) REFERENCES user_info (id); From b1e4c3efcf866269b03797d53623f171caa550e8 Mon Sep 17 00:00:00 2001 From: Maslyna Date: Tue, 4 Apr 2023 22:02:19 +0200 Subject: [PATCH 02/30] Changed DB structure --- .../com/provedcode/config/SecurityConfig.java | 1 + .../provedcode/talent/TalentController.java | 4 +- .../talent/mapper/impl/TalentMapperImpl.java | 4 +- .../talent/model/dto/FullTalentDTO.java | 4 +- .../talent/model/dto/ShortTalentDTO.java | 2 +- .../talent/model/entity/Talent.java | 11 +- .../{TalentSkill.java => TalentTalents.java} | 8 +- .../talent/model/response/ShortTalent.java | 2 - .../talent/repo/TalentRepository.java | 9 +- .../talent/repo/TalentSkillRepository.java | 6 +- .../talent/service/TalentService.java | 2 +- .../service/impl/TalentServiceImpl.java | 90 ++++----- .../controller/AuthenticationController.java | 64 +++--- .../user/mapper/impl/UserInfoMapperImpl.java | 2 + .../user/model/entity/UserAuthority.java | 27 --- .../impl/AuthenticationServiceImpl.java | 188 +++++++++--------- src/main/resources/data.sql | 74 +++---- src/main/resources/schema.sql | 18 +- 18 files changed, 240 insertions(+), 276 deletions(-) rename src/main/java/com/provedcode/talent/model/entity/{TalentSkill.java => TalentTalents.java} (81%) delete mode 100644 src/main/java/com/provedcode/user/model/entity/UserAuthority.java diff --git a/src/main/java/com/provedcode/config/SecurityConfig.java b/src/main/java/com/provedcode/config/SecurityConfig.java index 6591a05..7128df4 100644 --- a/src/main/java/com/provedcode/config/SecurityConfig.java +++ b/src/main/java/com/provedcode/config/SecurityConfig.java @@ -43,6 +43,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.authorizeHttpRequests(c -> c .requestMatchers("/actuator/health").permitAll() // for DevOps .requestMatchers(antMatcher("/h2/**")).permitAll() + .requestMatchers(antMatcher("/api/talents/login")).permitAll() .requestMatchers(antMatcher("/api/talents/**")).permitAll() .anyRequest().authenticated() ); diff --git a/src/main/java/com/provedcode/talent/TalentController.java b/src/main/java/com/provedcode/talent/TalentController.java index b1e5f8d..ece8230 100644 --- a/src/main/java/com/provedcode/talent/TalentController.java +++ b/src/main/java/com/provedcode/talent/TalentController.java @@ -26,7 +26,9 @@ public class TalentController { @PreAuthorize("hasRole('TALENT')") @GetMapping("/talents/{id}") - FullTalentDTO getTalent(@PathVariable("id") long id) { + FullTalentDTO getTalent(@PathVariable("id") long id, Authentication authentication) { + log.info("get-talent auth = {}", authentication); + log.info("get-talent auth.name = {}", authentication.getAuthorities()); return talentService.getTalentById(id); } diff --git a/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java b/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java index 2b0794b..bfa97f4 100644 --- a/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java +++ b/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java @@ -16,7 +16,7 @@ public ShortTalentDTO talentToShortTalentDTO(Talent talent) { .firstName(talent.getFirstName()) .lastName(talent.getLastName()) .specialization(talent.getSpecialization()) - .skills(talent.getTalentSkills().stream().map(TalentSkill::getSkill).toList()) + .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) .build(); } @@ -33,7 +33,7 @@ public FullTalentDTO talentToFullTalentDTO(Talent talent) { .specialization(talent.getSpecialization()) .links(talent.getTalentLinks().stream().map(TalentLink::getLink).toList()) .contacts(talent.getTalentContacts().stream().map(TalentContact::getContact).toList()) - .skills(talent.getTalentSkills().stream().map(TalentSkill::getSkill).toList()) + .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) .attachedFiles( talent.getTalentAttachedFiles().stream().map(TalentAttachedFile::getAttachedFile) .toList()) diff --git a/src/main/java/com/provedcode/talent/model/dto/FullTalentDTO.java b/src/main/java/com/provedcode/talent/model/dto/FullTalentDTO.java index dc5d09b..54fb184 100644 --- a/src/main/java/com/provedcode/talent/model/dto/FullTalentDTO.java +++ b/src/main/java/com/provedcode/talent/model/dto/FullTalentDTO.java @@ -3,9 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.provedcode.annotations.UrlList; import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.Builder; -import org.hibernate.validator.constraints.URL; import java.util.List; @@ -24,7 +22,7 @@ public record FullTalentDTO( @JsonProperty("additional_info") String additionalInfo, String bio, - List skills, + List talents, @UrlList List links, List contacts, diff --git a/src/main/java/com/provedcode/talent/model/dto/ShortTalentDTO.java b/src/main/java/com/provedcode/talent/model/dto/ShortTalentDTO.java index 491bcdb..d252bcd 100644 --- a/src/main/java/com/provedcode/talent/model/dto/ShortTalentDTO.java +++ b/src/main/java/com/provedcode/talent/model/dto/ShortTalentDTO.java @@ -11,6 +11,6 @@ public record ShortTalentDTO( String firstName, String lastName, String specialization, - List skills + List talents ) { } diff --git a/src/main/java/com/provedcode/talent/model/entity/Talent.java b/src/main/java/com/provedcode/talent/model/entity/Talent.java index a8cc0df..c5bb6a7 100644 --- a/src/main/java/com/provedcode/talent/model/entity/Talent.java +++ b/src/main/java/com/provedcode/talent/model/entity/Talent.java @@ -2,7 +2,6 @@ import jakarta.persistence.*; import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.*; import lombok.experimental.Accessors; import org.hibernate.validator.constraints.URL; @@ -40,17 +39,17 @@ public class Talent { @OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) private List talentLinks = new ArrayList<>(); @OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) - private List talentSkills = new ArrayList<>(); + private List talentTalents = new ArrayList<>(); @OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) private List talentContacts = new ArrayList<>(); @OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) private List talentAttachedFiles = new ArrayList<>(); - public void addTalentSkill(TalentSkill talentSkill) { - talentSkills.add(talentSkill); + public void addTalentSkill(TalentTalents talentTalents) { + this.talentTalents.add(talentTalents); } - public void removeTalentSkill(TalentSkill talentSkill) { - talentSkills.remove(talentSkill); + public void removeTalentSkill(TalentTalents talentTalents) { + this.talentTalents.remove(talentTalents); } } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/model/entity/TalentSkill.java b/src/main/java/com/provedcode/talent/model/entity/TalentTalents.java similarity index 81% rename from src/main/java/com/provedcode/talent/model/entity/TalentSkill.java rename to src/main/java/com/provedcode/talent/model/entity/TalentTalents.java index 884fb87..0eef149 100644 --- a/src/main/java/com/provedcode/talent/model/entity/TalentSkill.java +++ b/src/main/java/com/provedcode/talent/model/entity/TalentTalents.java @@ -10,8 +10,8 @@ @Getter @Setter @Entity -@Table(name = "talent_skill") -public class TalentSkill { +@Table(name = "talent_talents") +public class TalentTalents { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) @@ -19,8 +19,8 @@ public class TalentSkill { @NotNull @Column(name = "talent_id", nullable = false) private Long talentId; - @Column(name = "skill") - private String skill; + @Column(name = "talent_name") + private String talentName; @NotNull @ManyToOne @JoinColumn(name = "talent_id", insertable = false, updatable = false) diff --git a/src/main/java/com/provedcode/talent/model/response/ShortTalent.java b/src/main/java/com/provedcode/talent/model/response/ShortTalent.java index 532ff26..c8f5e93 100644 --- a/src/main/java/com/provedcode/talent/model/response/ShortTalent.java +++ b/src/main/java/com/provedcode/talent/model/response/ShortTalent.java @@ -1,7 +1,5 @@ package com.provedcode.talent.model.response; -import com.provedcode.talent.model.entity.TalentSkill; - import java.util.List; public record ShortTalent( diff --git a/src/main/java/com/provedcode/talent/repo/TalentRepository.java b/src/main/java/com/provedcode/talent/repo/TalentRepository.java index 57723f6..e0359c3 100644 --- a/src/main/java/com/provedcode/talent/repo/TalentRepository.java +++ b/src/main/java/com/provedcode/talent/repo/TalentRepository.java @@ -1,16 +1,11 @@ package com.provedcode.talent.repo; import com.provedcode.talent.model.entity.Talent; -import com.provedcode.talent.model.entity.TalentSkill; +import com.provedcode.talent.model.entity.TalentTalents; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; -public interface TalentRepository extends - JpaRepository { - @Transactional - @Modifying - @Query("update Talent t set t.talentSkills = ?1") - int updateTalentSkillsBy(TalentSkill talentSkills); +public interface TalentRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java b/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java index 2c0648e..e9bef7d 100644 --- a/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java +++ b/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java @@ -1,11 +1,11 @@ package com.provedcode.talent.repo; import com.provedcode.talent.model.entity.Talent; -import com.provedcode.talent.model.entity.TalentSkill; +import com.provedcode.talent.model.entity.TalentTalents; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; -public interface TalentSkillRepository extends JpaRepository { - List deleteByTalent(Talent talent); +public interface TalentSkillRepository extends JpaRepository { + List deleteByTalent(Talent talent); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/service/TalentService.java b/src/main/java/com/provedcode/talent/service/TalentService.java index 838f74d..6e5ecb7 100644 --- a/src/main/java/com/provedcode/talent/service/TalentService.java +++ b/src/main/java/com/provedcode/talent/service/TalentService.java @@ -1,10 +1,10 @@ package com.provedcode.talent.service; -import com.provedcode.talent.model.dto.FullTalentDTO; import com.provedcode.talent.model.dto.ShortTalentDTO; import com.provedcode.user.model.dto.SessionInfoDTO; import org.springframework.security.core.Authentication; import org.springframework.data.domain.Page; +import com.provedcode.talent.model.dto.FullTalentDTO; import java.util.Optional; diff --git a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java index 900920f..1e3251e 100644 --- a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java +++ b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java @@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; +import org.springframework.http.HttpStatus; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -31,7 +32,6 @@ @AllArgsConstructor @Transactional public class TalentServiceImpl implements TalentService { - private final AuthorityRepository authorityRepository; TalentMapper talentMapper; TalentRepository talentRepository; TalentSkillRepository talentSkillRepository; @@ -70,17 +70,17 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio Optional talent = talentRepository.findById(id); Optional userInfo = userInfoRepository.findByLogin(authentication.getName()); - if (talent.isEmpty() || userInfo.isEmpty()) { - throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); - } - if (userInfo.get().getTalent().getId() != id) { - throw new ResponseStatusException(FORBIDDEN, "you can`t update another user"); - } + userVerification(talent, userInfo, id); Talent oldTalent = talent.get(); long oldTalentId = oldTalent.getId(); TalentDescription oldTalentDescription = oldTalent.getTalentDescription(); + List oldTalentTalents = oldTalent.getTalentTalents(); + List oldTalentLinks = oldTalent.getTalentLinks(); + List oldTalentContacts = oldTalent.getTalentContacts(); + List oldTalentAttachedFile = oldTalent.getTalentAttachedFiles(); + if (oldTalentDescription != null) { oldTalentDescription .setAdditionalInfo(fullTalent.additionalInfo()) @@ -94,41 +94,46 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio .build(); } - List oldTalentSkills = oldTalent.getTalentSkills(); - oldTalentSkills.clear(); - oldTalentSkills.addAll(fullTalent.skills().stream().map(s -> TalentSkill.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .skill(s).build()).toList()); + oldTalentTalents.clear(); + if (fullTalent.talents() != null) { + oldTalentTalents.addAll(fullTalent.talents().stream().map(s -> TalentTalents.builder() + .talentId(oldTalentId) + .talent(oldTalent) + .talentName(s).build()).toList()); + } - List oldTalentLinks = oldTalent.getTalentLinks(); oldTalentLinks.clear(); - oldTalentLinks.addAll(fullTalent.links().stream().map(l -> TalentLink.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .link(l).build()).toList()); + if (fullTalent.links() != null) { + oldTalentLinks.addAll(fullTalent.links().stream().map(l -> TalentLink.builder() + .talentId(oldTalentId) + .talent(oldTalent) + .link(l).build()).toList()); + } - List oldTalentContacts = oldTalent.getTalentContacts(); oldTalentContacts.clear(); - oldTalentContacts.addAll(fullTalent.contacts().stream().map(s -> TalentContact.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .contact(s).build()).toList()); - List oldTalentAttachedFile = oldTalent.getTalentAttachedFiles(); + if (fullTalent.contacts() != null) { + oldTalentContacts.addAll(fullTalent.contacts().stream().map(s -> TalentContact.builder() + .talentId(oldTalentId) + .talent(oldTalent) + .contact(s).build()).toList()); + } + oldTalentAttachedFile.clear(); - oldTalentAttachedFile.addAll(fullTalent.attachedFiles().stream().map(s -> TalentAttachedFile.builder() - .talentId( - oldTalentId) - .talent(oldTalent) - .attachedFile(s) - .build()).toList()); + if (fullTalent.attachedFiles() != null) { + oldTalentAttachedFile.addAll(fullTalent.attachedFiles().stream().map(s -> TalentAttachedFile.builder() + .talentId( + oldTalentId) + .talent(oldTalent) + .attachedFile(s) + .build()).toList()); + } oldTalent.setFirstName(fullTalent.firstName()) .setLastName(fullTalent.lastName()) .setSpecialization(fullTalent.specialization()) .setImage(fullTalent.image()) .setTalentDescription(oldTalentDescription) - .setTalentSkills(oldTalentSkills) + .setTalentTalents(oldTalentTalents) .setTalentLinks(oldTalentLinks) .setTalentContacts(oldTalentContacts) .setTalentAttachedFiles(oldTalentAttachedFile); @@ -143,24 +148,19 @@ public SessionInfoDTO deleteTalentById(long id, Authentication authentication) { Optional talent = talentRepository.findById(id); Optional userInfo = userInfoRepository.findByLogin(authentication.getName()); - if (talent.isEmpty() || userInfo.isEmpty()) { - throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); - } - if (userInfo.get().getTalent().getId() != id) { - throw new ResponseStatusException(FORBIDDEN, "you can`t delete another user"); - } + userVerification(talent, userInfo, id); userInfoRepository.delete(userInfo.get()); talentRepository.deleteById(id); return new SessionInfoDTO("deleted", "null"); } -// public void userVerification(Optional talent, Optional userInfo, long id) { -// if (talent.isEmpty()) { -// throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); -// } -// if (userInfo.get().getTalent().getId() != id) { -// throw new ResponseStatusException(UNAUTHORIZED); -// } -// } + public void userVerification(Optional talent, Optional userInfo, long id) { + if (talent.isEmpty() || userInfo.isEmpty()) { + throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); + } + if (userInfo.get().getTalent().getId() != id) { + throw new ResponseStatusException(FORBIDDEN, "you can`t delete/update another user"); + } + } } diff --git a/src/main/java/com/provedcode/user/controller/AuthenticationController.java b/src/main/java/com/provedcode/user/controller/AuthenticationController.java index d4ef163..4bd9bd0 100644 --- a/src/main/java/com/provedcode/user/controller/AuthenticationController.java +++ b/src/main/java/com/provedcode/user/controller/AuthenticationController.java @@ -1,32 +1,32 @@ -//package com.provedcode.user.controller; -// -//import com.provedcode.user.model.dto.RegistrationDTO; -//import com.provedcode.user.model.dto.SessionInfoDTO; -//import com.provedcode.user.service.AuthenticationService; -//import jakarta.validation.Valid; -//import lombok.AllArgsConstructor; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.http.HttpStatus; -//import org.springframework.security.core.Authentication; -//import org.springframework.web.bind.annotation.*; -// -//@RestController -//@AllArgsConstructor -//@Slf4j -//@RequestMapping("/api/talents") -//@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE}) -//public class AuthenticationController { -// AuthenticationService authenticationService; -// -// @PostMapping("/login") -// SessionInfoDTO login(Authentication authentication) { -// return authenticationService.login(authentication.getName(), authentication.getAuthorities()); -// } -// -// @PostMapping("/register") -// @ResponseStatus(HttpStatus.CREATED) -// SessionInfoDTO register(@RequestBody @Valid RegistrationDTO user) { -// return authenticationService.register(user); -// } -// -//} +package com.provedcode.user.controller; + +import com.provedcode.user.model.dto.RegistrationDTO; +import com.provedcode.user.model.dto.SessionInfoDTO; +import com.provedcode.user.service.AuthenticationService; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.*; + +@RestController +@AllArgsConstructor +@Slf4j +@RequestMapping("/api/talents") +@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE}) +public class AuthenticationController { + AuthenticationService authenticationService; + + @PostMapping("/login") + SessionInfoDTO login(Authentication authentication) { + return authenticationService.login(authentication.getName(), authentication.getAuthorities()); + } + + @PostMapping("/register") + @ResponseStatus(HttpStatus.CREATED) + SessionInfoDTO register(@RequestBody @Valid RegistrationDTO user) { + return authenticationService.register(user); + } + +} diff --git a/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java b/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java index a0c4a5f..8e451e5 100644 --- a/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java +++ b/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java @@ -2,12 +2,14 @@ import com.provedcode.user.mapper.UserInfoMapper; import com.provedcode.user.model.entity.UserInfo; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Component; @Component +@Slf4j public class UserInfoMapperImpl implements UserInfoMapper { @Override public UserDetails toUserDetails(UserInfo user) { diff --git a/src/main/java/com/provedcode/user/model/entity/UserAuthority.java b/src/main/java/com/provedcode/user/model/entity/UserAuthority.java deleted file mode 100644 index 3027027..0000000 --- a/src/main/java/com/provedcode/user/model/entity/UserAuthority.java +++ /dev/null @@ -1,27 +0,0 @@ -//package com.provedcode.user.model.entity; -// -//import jakarta.persistence.*; -//import jakarta.validation.constraints.NotNull; -//import lombok.*; -// -//@Builder -//@AllArgsConstructor -//@NoArgsConstructor -//@Getter -//@Setter -//@Entity -//@Table(name = "user_authority") -//public class UserAuthority { -// @Id -// @GeneratedValue(strategy = GenerationType.IDENTITY) -// @Column(name = "id", nullable = false) -// private Long id; -// @NotNull -// @ManyToOne -// @JoinColumn(name = "user_id") -// private UserInfo userInfo; -// @NotNull -// @ManyToOne -// @JoinColumn(name = "authority_id") -// private Authority authority; -//} \ No newline at end of file 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 73a0200..feee52e 100644 --- a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java +++ b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java @@ -1,97 +1,91 @@ -//package com.provedcode.user.service.impl; -// -//import com.provedcode.talent.model.entity.Talent; -//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.entity.UserInfo; -//import com.provedcode.user.repo.AuthorityRepository; -//import com.provedcode.user.repo.UserInfoRepository; -//import com.provedcode.user.service.AuthenticationService; -//import lombok.AllArgsConstructor; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.http.HttpStatus; -//import org.springframework.security.core.GrantedAuthority; -//import org.springframework.security.core.authority.SimpleGrantedAuthority; -//import org.springframework.security.crypto.password.PasswordEncoder; -//import org.springframework.security.oauth2.jwt.JwtClaimsSet; -//import org.springframework.security.oauth2.jwt.JwtEncoder; -//import org.springframework.security.oauth2.jwt.JwtEncoderParameters; -//import org.springframework.stereotype.Service; -//import org.springframework.transaction.annotation.Transactional; -//import org.springframework.web.server.ResponseStatusException; -// -//import java.time.Instant; -//import java.util.Collection; -//import java.util.Set; -//import java.util.stream.Collectors; -// -//import static java.time.temporal.ChronoUnit.MINUTES; -// -//@Service -//@AllArgsConstructor -//@Slf4j -//public class AuthenticationServiceImpl implements AuthenticationService { -// JwtEncoder jwtEncoder; -// UserInfoRepository userInfoRepository; -// TalentRepository talentEntityRepository; -// AuthorityRepository authorityRepository; -// PasswordEncoder passwordEncoder; -// -//// @Transactional -//// public SessionInfoDTO login(String name, Collection authorities) { -//// return new SessionInfoDTO("User {%s} log-in".formatted(name), generateJWTToken(name, authorities)); -//// } -//// -//// @Transactional -//// public SessionInfoDTO register(RegistrationDTO user) { -//// if (userInfoRepository.existsByLogin(user.login())) { -//// throw new ResponseStatusException(HttpStatus.CONFLICT, -//// String.format("user with login = {%s} already exists", user.login())); -//// } -//// Talent talent = Talent.builder() -//// .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(); -//// UserAuthority userAuthority = UserAuthority.builder() -//// .userInfo(userInfo) -//// .authority(authorityRepository.findByAuthority(Role.TALENT.toString()) -//// .orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "this authority does`t exist"))) -//// .build(); -//// -//// userInfo.setUserAuthorities(Set.of(userAuthority)); -//// userAuthority.setUserInfo(userInfoRepository.save(userInfo)); -//// userAuthorityRepository.save(userAuthority); -//// -//// String userLogin = userInfo.getLogin(); -//// Collection userAuthorities = userInfo.getUserAuthorities().stream().map(i -> new SimpleGrantedAuthority(i.getAuthority().getAuthority())).toList(); -//// -//// 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)); -//// } -// -// private String generateJWTToken(String name, Collection authorities) { -// log.info("=== POST /login === auth.name = {}", name); -// log.info("=== POST /login === auth = {}", authorities); -// var now = Instant.now(); -// var claims = JwtClaimsSet.builder() -// .issuer("self") -// .issuedAt(now) -// .expiresAt(now.plus(5, MINUTES)) -// .subject(name) -// .claim("scope", authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.joining(" "))) -// .build(); -// return jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue(); -// } -// -//} +package com.provedcode.user.service.impl; + +import com.provedcode.talent.model.entity.Talent; +import com.provedcode.talent.repo.TalentRepository; +import com.provedcode.user.model.dto.RegistrationDTO; +import com.provedcode.user.model.dto.SessionInfoDTO; +import com.provedcode.user.model.entity.Authority; +import com.provedcode.user.model.entity.UserInfo; +import com.provedcode.user.repo.AuthorityRepository; +import com.provedcode.user.repo.UserInfoRepository; +import com.provedcode.user.service.AuthenticationService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.oauth2.jwt.JwtClaimsSet; +import org.springframework.security.oauth2.jwt.JwtEncoder; +import org.springframework.security.oauth2.jwt.JwtEncoderParameters; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.server.ResponseStatusException; + +import java.time.Instant; +import java.util.Collection; +import java.util.Set; +import java.util.stream.Collectors; + +import static java.time.temporal.ChronoUnit.MINUTES; + +@Service +@AllArgsConstructor +@Slf4j +public class AuthenticationServiceImpl implements AuthenticationService { + JwtEncoder jwtEncoder; + UserInfoRepository userInfoRepository; + TalentRepository talentEntityRepository; + AuthorityRepository authorityRepository; + PasswordEncoder passwordEncoder; + + @Transactional + public SessionInfoDTO login(String name, Collection authorities) { + return new SessionInfoDTO("User {%s} log-in".formatted(name), generateJWTToken(name, authorities)); + } + + @Transactional + public SessionInfoDTO register(RegistrationDTO user) { + if (userInfoRepository.existsByLogin(user.login())) { + throw new ResponseStatusException(HttpStatus.CONFLICT, + String.format("user with login = {%s} already exists", user.login())); + } + Talent talent = Talent.builder() + .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(); + userInfo.setAuthorities(Set.of(authorityRepository.findByAuthority("ROLE_TALENT").orElseThrow())); + + userInfoRepository.save(userInfo); + + String userLogin = userInfo.getLogin(); + Collection userAuthorities = userInfo.getAuthorities().stream().map(i -> new SimpleGrantedAuthority(i.getAuthority())).toList(); + + 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)); + } + + private String generateJWTToken(String name, Collection authorities) { + log.info("=== POST /login === auth.name = {}", name); + log.info("=== POST /login === auth = {}", authorities); + var now = Instant.now(); + var claims = JwtClaimsSet.builder() + .issuer("self") + .issuedAt(now) + .expiresAt(now.plus(5, MINUTES)) + .subject(name) + .claim("scope", authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.joining(" "))) + .build(); + return jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue(); + } + +} diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index dc177fd..bc95baa 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -17,13 +17,13 @@ insert into talent_link (talent_id, link) values ((select id from talent order by id desc limit 1), 'http://second_link'); insert into talent_link (talent_id, link) values ((select id from talent order by id desc limit 1), 'http://third_link'); -insert into talent_skill (talent_id, skill) +insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Java Core'); -insert into talent_skill (talent_id, skill) +insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Spring Core'); -insert into talent_skill (talent_id, skill) +insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'Spring boot'); -insert into talent_skill (talent_id, skill) +insert into talent_talents (talent_id, talent_name) values ((select id from talent order by id desc limit 1), 'H2 Database'); insert into talent_contact (talent_id, contact) values ((select id from talent order by id desc limit 1), 'first_contact'); @@ -54,13 +54,13 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Java Core'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Hibernate'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Spring Boot'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_first_contact'); @@ -91,11 +91,11 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Java Core'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Spring Security'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Spring Core'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'DenisBoyko_first_contact'); @@ -126,9 +126,9 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Java Core'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'REST API'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_first_contact'); @@ -159,11 +159,11 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Docker'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Mentor'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'DmytroUzun_first_contact'); @@ -194,9 +194,9 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Docker'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_first_contact'); @@ -227,11 +227,11 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Jira'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'QA'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_first_contact'); @@ -262,9 +262,9 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'QA'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_first_contact'); @@ -295,12 +295,12 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'QA'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_skill (talent_id, skill) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_skill'); +-- insert into talent_talents (talent_id, talents) +-- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_talents'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_first_contact'); -- insert into talent_contact (talent_id, contact) @@ -330,9 +330,9 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'QA'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Git'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_first_contact'); @@ -363,9 +363,9 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'React'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_first_contact'); @@ -396,11 +396,11 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'React'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Node.js'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_first_contact'); @@ -431,11 +431,11 @@ values ((select id from user_info order by id desc limit 1), -- values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_second_link'); -- insert into talent_link (talent_id, link) -- values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_third_link'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'React'); --- insert into talent_skill (talent_id, skill) +-- insert into talent_talents (talent_id, talents) -- values ((select id from talent order by id desc limit 1), 'Angular'); -- insert into talent_contact (talent_id, contact) -- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_first_contact'); diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 51d130c..ed32320 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -3,10 +3,10 @@ drop table IF EXISTS talent_description CASCADE ; drop table IF EXISTS talent_link CASCADE ; drop table IF EXISTS talent_contact CASCADE ; drop table IF EXISTS talent_attached_file CASCADE ; -drop table IF EXISTS talent_skill CASCADE ; +drop table IF EXISTS talent_talents CASCADE ; drop table IF EXISTS user_info CASCADE ; drop table IF EXISTS user_authorities CASCADE ; -drop table IF EXISTS authority_user_infoes CASCADE ; +drop table IF EXISTS talent_talents CASCADE ; create TABLE talent ( id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, @@ -36,14 +36,16 @@ create TABLE talent_link ( alter table talent_link add CONSTRAINT FK_TALENT_LINK_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); -create TABLE talent_skill ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - skill VARCHAR(255) NOT NULL, - CONSTRAINT pk_talent_skill PRIMARY KEY (id) +CREATE TABLE talent_talents +( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + talent_name VARCHAR(255), + CONSTRAINT pk_talent_talents PRIMARY KEY (id) ); -alter table talent_skill add CONSTRAINT FK_TALENT_SKILL_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE talent_talents + ADD CONSTRAINT FK_TALENT_TALENTS_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); create TABLE talent_contact ( id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, From b28a2970e38fd92b5d3a8be398b780bd6e25660a Mon Sep 17 00:00:00 2001 From: Maslyna Date: Tue, 4 Apr 2023 22:35:11 +0200 Subject: [PATCH 03/30] Changed data.sql file --- src/main/resources/data.sql | 833 ++++++++++++++++++------------------ 1 file changed, 416 insertions(+), 417 deletions(-) diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index bc95baa..5441157 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -5,8 +5,7 @@ values (1, 'ROLE_TALENT'); -- -- USER_INFO -- -- JOIN user_authorities ON talent_id = USER_INFO.ID -- -- JOIN AUTHORITY ON AUTHORITY.ID = id --- --- + insert into talent (first_name, last_name, specialization, image) values ('Serhii', 'Soloviov', 'Java-Developer', 'https://i.pinimg.com/564x/e1/08/49/e10849923a8b2e85a7adf494ebd063e6.jpg'); insert into talent_description (talent_id, BIO, addition_info) @@ -32,426 +31,426 @@ 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), 'first_file'); +values ((select id from talent order by id desc limit 1), 'http://first_file'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'second_file'); +values ((select id from talent order by id desc limit 1), 'http://second_file'); insert into talent_attached_file (talent_id, attached_file) -values ((select id from talent order by id desc limit 1), 'third_file'); +values ((select id from talent order by id desc limit 1), 'http://third_file'); insert into user_info (talent_id, login, password) values ((select id from talent order by id desc limit 1), 'SerhiiSoloviov', '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)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Mykhailo', 'Ordyntsev', 'Java-Developer', 'https://i.pinimg.com/564x/c2/41/31/c24131fe00218467721ba5bacdf0a256.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Java Core'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Hibernate'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Spring Boot'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_contact'); --- 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), 'MykhailoOrdyntsev_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Denis', 'Boyko', 'Java-Developer', 'https://i.pinimg.com/564x/2a/0c/08/2a0c08c421e253ca895c3fdc8c9e08d9.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Java Core'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Spring Security'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Spring Core'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'DenisBoyko_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_contact'); --- 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), 'DenisBoyko_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'DenisBoyko_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'DenisBoyko', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Ihor', 'Schurenko', 'Java-Developer', 'https://i.pinimg.com/564x/e1/11/2f/e1112f0b7b63644dc3e313084936dedb.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Java Core'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'REST API'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_contact'); --- 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), 'IhorShchurenko_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'IhorShchurenko_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'DmytroUzun', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Dmytro', 'Uzun', 'Dev-Ops', 'https://i.pinimg.com/564x/1c/af/87/1caf8771ef3edf351f6f2bf6f1c0a276.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Docker'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Mentor'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'DmytroUzun_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_contact'); --- 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), 'DmytroUzun_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'DmytroUzun_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'DmytroUzun', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Viktor', 'Voloshko', 'Dev-Ops', 'https://i.pinimg.com/564x/a9/51/ab/a951ab682413b89617235e65564c1e5e.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Docker'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_contact'); --- 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), 'ViktorVoloshko_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'ViktorVoloshko', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Olha', 'Moiseienko', 'QA', 'https://i.pinimg.com/564x/6d/9d/43/6d9d437baf4db114c047d927307beb84.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Jira'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'QA'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_contact'); --- 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), 'OlhaMoiseienko_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko _third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Maxim', 'Kiyashko', 'QA', 'https://i.pinimg.com/564x/80/2d/58/802d58b0302985f9486893d499d3634d.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'QA'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_contact'); --- 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), 'MaximKiyashko_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'MaximKiyashko_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'MaximKiyashko', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Nikolaiev', 'Oleksii', 'QA', 'https://i.pinimg.com/564x/54/d1/0d/54d10dfce64afefabc9fbbce5de82c87.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'QA'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_talents'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_contact'); --- 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), 'NikolaievOleksii_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Artem', 'Lytvynenko', 'QA', 'https://i.pinimg.com/564x/87/63/55/87635509c5fa7ee496ec351fa7e67eaa.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'QA'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Git'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_contact'); --- 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), 'ArtemLytvynenko_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Daniil', 'Yevtukhov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/fe/b1/37/feb137d88a3d1c8fb28796db6cbc576f.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'React'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_contact'); --- 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), 'DaniilYevtukhov_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Ruslan', 'Morozov', 'Java-Script-Developer', 'https://i.pinimg.com/736x/36/ae/0e/36ae0ea4aad656f7c3d3175bc33b8399.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'React'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Node.js'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_contact'); --- 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), 'RuslanMorozov_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'RuslanMorozov_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'RuslanMorozov', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); --- --- insert into talent (first_name, last_name, specialization, image) --- values ('Ihor', 'Kopieichykov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/0d/f0/83/0df083121bac75f64e3d93c7c5682d04.jpg'); --- 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'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_second_link'); --- insert into talent_link (talent_id, link) --- values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_third_link'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'JavaScript Core'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'React'); --- insert into talent_talents (talent_id, talents) --- values ((select id from talent order by id desc limit 1), 'Angular'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_first_contact'); --- insert into talent_contact (talent_id, contact) --- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_contact'); --- 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), 'IhorKopieichykov_first_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_file'); --- insert into talent_attached_file (talent_id, attached_file) --- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_third_file'); --- --- insert into user_info (talent_id, login, password) --- values ((select id from talent order by id desc limit 1), 'IhorKopieichykov', 'password'); --- insert into user_authorities (talent_id, id) --- values ((select id from user_info order by id desc limit 1), --- (select authority.id from authority where id = 1)); + +insert into talent (first_name, last_name, specialization, image) +values ('Mykhailo', 'Ordyntsev', 'Java-Developer', 'https://i.pinimg.com/564x/c2/41/31/c24131fe00218467721ba5bacdf0a256.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://MykhailoOrdyntsev_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Hibernate'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'Spring Boot'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'Git'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'MykhailoOrdyntsev', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Denis', 'Boyko', 'Java-Developer', 'https://i.pinimg.com/564x/2a/0c/08/2a0c08c421e253ca895c3fdc8c9e08d9.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://DenisBoyko_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Spring Security'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'Spring Core'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'DenisBoyko_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'DenisBoyko_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'DenisBoyko', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Ihor', 'Schurenko', 'Java-Developer', 'https://i.pinimg.com/564x/e1/11/2f/e1112f0b7b63644dc3e313084936dedb.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://IhorShchurenko_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'REST API'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'IhorShchurenko_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'IhorShchurenko_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'DmytroUzun', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Dmytro', 'Uzun', 'Dev-Ops', 'https://i.pinimg.com/564x/1c/af/87/1caf8771ef3edf351f6f2bf6f1c0a276.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://DmytroUzun_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Docker'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'Mentor'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'DmytroUzun_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'DmytroUzun_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'DmytroUzun', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Viktor', 'Voloshko', 'Dev-Ops', 'https://i.pinimg.com/564x/a9/51/ab/a951ab682413b89617235e65564c1e5e.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://ViktorVoloshko_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Docker'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'ViktorVoloshko_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'ViktorVoloshko', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Olha', 'Moiseienko', 'QA', 'https://i.pinimg.com/564x/6d/9d/43/6d9d437baf4db114c047d927307beb84.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://OlhaMoiseienko_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Jira'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'QA'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'OlhaMoiseienko', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Maxim', 'Kiyashko', 'QA', 'https://i.pinimg.com/564x/80/2d/58/802d58b0302985f9486893d499d3634d.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://MaximKiyashko_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'QA'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'MaximKiyashko_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'MaximKiyashko_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'MaximKiyashko', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Nikolaiev', 'Oleksii', 'QA', 'https://i.pinimg.com/564x/54/d1/0d/54d10dfce64afefabc9fbbce5de82c87.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://NikolaievOleksii_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Git'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_third_talents'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'NikolaievOleksii_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'NikolaievOleksiio', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Artem', 'Lytvynenko', 'QA', 'https://i.pinimg.com/564x/87/63/55/87635509c5fa7ee496ec351fa7e67eaa.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://ArtemLytvynenko_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'Git'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'ArtemLytvynenko', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Daniil', 'Yevtukhov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/fe/b1/37/feb137d88a3d1c8fb28796db6cbc576f.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://DaniilYevtukhov_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'React'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'DaniilYevtukhov', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Ruslan', 'Morozov', 'Java-Script-Developer', 'https://i.pinimg.com/736x/36/ae/0e/36ae0ea4aad656f7c3d3175bc33b8399.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://RuslanMorozov_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'React'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'Node.js'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'RuslanMorozov_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'RuslanMorozov_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'RuslanMorozov', '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)); + +insert into talent (first_name, last_name, specialization, image) +values ('Ihor', 'Kopieichykov', 'Java-Script-Developer', 'https://i.pinimg.com/564x/0d/f0/83/0df083121bac75f64e3d93c7c5682d04.jpg'); +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'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_second_link'); +insert into talent_link (talent_id, link) +values ((select id from talent order by id desc limit 1), 'http://IhorKopieichykov_third_link'); +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) +values ((select id from talent order by id desc limit 1), 'React'); +insert into talent_talents (talent_id, talent_name) +values ((select id from talent order by id desc limit 1), 'Angular'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_first_contact'); +insert into talent_contact (talent_id, contact) +values ((select id from talent order by id desc limit 1), 'IhorKopieichykov_second_contact'); +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'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://second_file'); +insert into talent_attached_file (talent_id, attached_file) +values ((select id from talent order by id desc limit 1), 'http://third_file'); + +insert into user_info (talent_id, login, password) +values ((select id from talent order by id desc limit 1), 'IhorKopieichykov', '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)); From 287d89d6bb61e8a27a906f813634a10b19d4772c Mon Sep 17 00:00:00 2001 From: Mykhailo Ordyntsev <102993813+Maslyna@users.noreply.github.com> Date: Wed, 5 Apr 2023 11:18:11 +0200 Subject: [PATCH 04/30] fix bug with login (#62) Co-authored-by: Denis Boyko --- .../com/provedcode/config/SecurityConfig.java | 43 ++++++++++++++++--- .../user/model/entity/Authority.java | 2 +- .../user/model/entity/UserInfo.java | 2 +- .../impl/AuthenticationServiceImpl.java | 3 +- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/provedcode/config/SecurityConfig.java b/src/main/java/com/provedcode/config/SecurityConfig.java index 7128df4..0a74202 100644 --- a/src/main/java/com/provedcode/config/SecurityConfig.java +++ b/src/main/java/com/provedcode/config/SecurityConfig.java @@ -5,8 +5,11 @@ import com.nimbusds.jose.jwk.source.ImmutableJWKSet; import com.provedcode.user.mapper.UserInfoMapper; import com.provedcode.user.repo.UserInfoRepository; +import jakarta.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpStatus; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -34,6 +37,7 @@ import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS; import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher; +@Slf4j @Configuration @EnableWebSecurity @EnableMethodSecurity @@ -43,25 +47,50 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.authorizeHttpRequests(c -> c .requestMatchers("/actuator/health").permitAll() // for DevOps .requestMatchers(antMatcher("/h2/**")).permitAll() - .requestMatchers(antMatcher("/api/talents/login")).permitAll() + //.requestMatchers(antMatcher("/api/talents/login")).permitAll() .requestMatchers(antMatcher("/api/talents/**")).permitAll() + .requestMatchers(antMatcher("/error")).permitAll() .anyRequest().authenticated() ); + http.exceptionHandling(c -> c + .authenticationEntryPoint((request, response, authException) -> { + log.info("Authentication failed {}, message:{}", + describe(request), + authException.getMessage()); + response.sendError( + HttpStatus.UNAUTHORIZED.value(), + authException.getMessage()); + } + ) + .accessDeniedHandler((request, response, accessDeniedException) -> { + log.info("Authorization failed {},message: {}", + describe(request), + accessDeniedException.getMessage()); + response.sendError(HttpStatus.FORBIDDEN.value(), + accessDeniedException.getMessage()); + } + ) + ); + http.httpBasic(Customizer.withDefaults()); http.csrf().disable().headers().disable(); http.sessionManagement().sessionCreationPolicy(STATELESS); http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt) - .exceptionHandling(c -> c - .authenticationEntryPoint(new BearerTokenAuthenticationEntryPoint()) - .accessDeniedHandler(new BearerTokenAccessDeniedHandler()) - ); + .exceptionHandling(c -> c + .authenticationEntryPoint(new BearerTokenAuthenticationEntryPoint()) + .accessDeniedHandler(new BearerTokenAccessDeniedHandler()) + ); return http.build(); } + public String describe(HttpServletRequest request) { + return request.getRequestURI(); + } + @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); @@ -90,8 +119,8 @@ UserDetailsService userDetailsService( UserInfoMapper mapper ) { return login -> repository.findByLogin(login) - .map(mapper::toUserDetails) - .orElseThrow(() -> new UsernameNotFoundException(login + " not found")); + .map(mapper::toUserDetails) + .orElseThrow(() -> new UsernameNotFoundException(login + " not found")); } @Bean diff --git a/src/main/java/com/provedcode/user/model/entity/Authority.java b/src/main/java/com/provedcode/user/model/entity/Authority.java index 69c4713..b892634 100644 --- a/src/main/java/com/provedcode/user/model/entity/Authority.java +++ b/src/main/java/com/provedcode/user/model/entity/Authority.java @@ -22,6 +22,6 @@ public class Authority { @NotNull @Column(name = "authority", length = 20) private String authority; - @ManyToMany(mappedBy = "authorities", cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + @ManyToMany(fetch = FetchType.EAGER, mappedBy = "authorities", cascade = {CascadeType.PERSIST, CascadeType.MERGE}) private Set userInfoes = new LinkedHashSet<>(); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/user/model/entity/UserInfo.java b/src/main/java/com/provedcode/user/model/entity/UserInfo.java index a7fb306..35c59bb 100644 --- a/src/main/java/com/provedcode/user/model/entity/UserInfo.java +++ b/src/main/java/com/provedcode/user/model/entity/UserInfo.java @@ -35,7 +35,7 @@ public class UserInfo { @OneToOne(orphanRemoval = true) @JoinColumn(name = "talent_id", insertable = false, updatable = false) private Talent talent; - @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) + @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable(name = "user_authorities", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "authority_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 feee52e..3558cad 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,6 @@ import com.provedcode.talent.repo.TalentRepository; import com.provedcode.user.model.dto.RegistrationDTO; import com.provedcode.user.model.dto.SessionInfoDTO; -import com.provedcode.user.model.entity.Authority; import com.provedcode.user.model.entity.UserInfo; import com.provedcode.user.repo.AuthorityRepository; import com.provedcode.user.repo.UserInfoRepository; @@ -81,7 +80,7 @@ private String generateJWTToken(String name, Collection Date: Wed, 5 Apr 2023 11:27:01 +0200 Subject: [PATCH 05/30] bugfix: delete didn`t work --- .../provedcode/talent/service/impl/TalentServiceImpl.java | 7 +++---- .../java/com/provedcode/user/model/entity/UserInfo.java | 2 +- src/main/resources/schema.sql | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java index 1e3251e..cf62166 100644 --- a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java +++ b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java @@ -121,8 +121,7 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio oldTalentAttachedFile.clear(); if (fullTalent.attachedFiles() != null) { oldTalentAttachedFile.addAll(fullTalent.attachedFiles().stream().map(s -> TalentAttachedFile.builder() - .talentId( - oldTalentId) + .talentId(oldTalentId) .talent(oldTalent) .attachedFile(s) .build()).toList()); @@ -150,8 +149,8 @@ public SessionInfoDTO deleteTalentById(long id, Authentication authentication) { userVerification(talent, userInfo, id); - userInfoRepository.delete(userInfo.get()); - talentRepository.deleteById(id); + userInfoRepository.delete(userInfo.orElseThrow(() -> new ResponseStatusException(NOT_IMPLEMENTED))); + talentRepository.delete(talent.orElseThrow(() -> new ResponseStatusException(NOT_IMPLEMENTED))); return new SessionInfoDTO("deleted", "null"); } diff --git a/src/main/java/com/provedcode/user/model/entity/UserInfo.java b/src/main/java/com/provedcode/user/model/entity/UserInfo.java index 35c59bb..38b1d33 100644 --- a/src/main/java/com/provedcode/user/model/entity/UserInfo.java +++ b/src/main/java/com/provedcode/user/model/entity/UserInfo.java @@ -32,7 +32,7 @@ public class UserInfo { @NotNull @Column(name = "password") private String password; - @OneToOne(orphanRemoval = true) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "talent_id", insertable = false, updatable = false) private Talent talent; @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index ed32320..94160b1 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -89,7 +89,7 @@ CREATE TABLE user_authorities CONSTRAINT pk_user_authorities PRIMARY KEY (user_id, authority_id) ); -ALTER TABLE user_info ADD CONSTRAINT FK_USER_INFO_ON_USER_UUID FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE user_info ADD CONSTRAINT FK_USER_INFO_ON_USER_ID FOREIGN KEY (talent_id) REFERENCES talent (id); ALTER TABLE user_authorities ADD CONSTRAINT fk_useaut_on_authority FOREIGN KEY (authority_id) REFERENCES authority (id); From 0688e41926c7c0f6d8427a79a9a46b0cdaf4bcc5 Mon Sep 17 00:00:00 2001 From: Maslyna Date: Wed, 5 Apr 2023 19:34:10 +0200 Subject: [PATCH 06/30] DB tried to conected to AWS RDS DB bugfix --- pom.xml | 7 +++++++ .../provedcode/talent/service/impl/TalentServiceImpl.java | 8 ++------ src/main/resources/application-dev.properties | 6 ++++-- src/main/resources/application-prod.properties | 5 ++--- src/main/resources/application.properties | 4 +--- src/main/resources/schema.sql | 1 + 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 56549a5..e0a4257 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,13 @@ spring-security-test test + + + org.postgresql + postgresql + 42.6.0 + + diff --git a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java index cf62166..2d37e80 100644 --- a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java +++ b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java @@ -10,13 +10,11 @@ import com.provedcode.talent.service.TalentService; import com.provedcode.user.model.dto.SessionInfoDTO; import com.provedcode.user.model.entity.UserInfo; -import com.provedcode.user.repo.AuthorityRepository; import com.provedcode.user.repo.UserInfoRepository; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.http.HttpStatus; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -90,8 +88,7 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio .talentId(oldTalentId) .additionalInfo(fullTalent.additionalInfo()) .bio(fullTalent.bio()) - .talent(oldTalent) - .build(); + .talent(oldTalent).build(); } oldTalentTalents.clear(); @@ -123,8 +120,7 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio oldTalentAttachedFile.addAll(fullTalent.attachedFiles().stream().map(s -> TalentAttachedFile.builder() .talentId(oldTalentId) .talent(oldTalent) - .attachedFile(s) - .build()).toList()); + .attachedFile(s).build()).toList()); } oldTalent.setFirstName(fullTalent.firstName()) diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index c8b0f61..4d1fff1 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,4 +1,6 @@ spring.datasource.username=sa -spring.datasource.url=jdbc:h2:mem:../sampleDB +spring.datasource.url=jdbc:h2:mem:testdb;MODE=PostgreSQL logging.level.web=DEBUG -logging.level.sql=DEBUG \ No newline at end of file +logging.level.sql=DEBUG +spring.jpa.hibernate.ddl-auto=none +spring.sql.init.mode=always \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 3eb12be..810d9a1 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,6 +1,5 @@ spring.datasource.username=${DB_LOGIN} spring.datasource.password=${DB_PASSWORD} -spring.datasource.url=${DB_URL} +spring.datasource.url=jdbc:postgresql://${DB_URL} spring.jpa.hibernate.ddl-auto=none -spring.sql.init.mode=always -spring.sql.init.platform=h2 \ No newline at end of file +spring.sql.init.mode=always \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ae6aba0..6986acc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,9 +4,7 @@ server.port=8080 ## spring.jackson.property-naming-strategy=SNAKE_CASE ## -logging.level.cinema.controller=info -## -spring.datasource.driverClassName=org.h2.Driver +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.h2.console.enabled=true spring.h2.console.path=/h2 spring.jpa.hibernate.ddl-auto=update diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 94160b1..6586f9f 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -7,6 +7,7 @@ drop table IF EXISTS talent_talents CASCADE ; drop table IF EXISTS user_info CASCADE ; drop table IF EXISTS user_authorities CASCADE ; drop table IF EXISTS talent_talents CASCADE ; +drop table IF EXISTS authority CASCADE ; create TABLE talent ( id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, From fccd208e53ad9446ba4f75c8195ff482e7e7b54a Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 21:59:41 +0300 Subject: [PATCH 07/30] Delete unused files --- .../talent/repo/TalentSkillRepository.java | 11 ---------- .../repo/db/TalentEntityRepository.java | 20 ------------------- 2 files changed, 31 deletions(-) delete mode 100644 src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java delete mode 100644 src/main/java/com/provedcode/talent/repo/db/TalentEntityRepository.java diff --git a/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java b/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java deleted file mode 100644 index e9bef7d..0000000 --- a/src/main/java/com/provedcode/talent/repo/TalentSkillRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.provedcode.talent.repo; - -import com.provedcode.talent.model.entity.Talent; -import com.provedcode.talent.model.entity.TalentTalents; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; - -public interface TalentSkillRepository extends JpaRepository { - List deleteByTalent(Talent talent); -} \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/repo/db/TalentEntityRepository.java b/src/main/java/com/provedcode/talent/repo/db/TalentEntityRepository.java deleted file mode 100644 index e3fa4a9..0000000 --- a/src/main/java/com/provedcode/talent/repo/db/TalentEntityRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.provedcode.talent.repo.db; - -import com.provedcode.talent.model.entity.Talent; -import com.provedcode.talent.repo.TalentRepository; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Optional; - -public interface TalentEntityRepository extends - JpaRepository, - TalentRepository { - @Transactional(readOnly = true) - Page findAll(Pageable pageable); - @Override - @Transactional(readOnly = true) - Optional findById(Long aLong); -} \ No newline at end of file From 04c857a3d7db40e9fc682159ae3f7fb131c29463 Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 22:00:17 +0300 Subject: [PATCH 08/30] Delete cors annotation --- src/main/java/com/provedcode/ProvedCodeApplication.java | 2 +- .../provedcode/user/controller/AuthenticationController.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/provedcode/ProvedCodeApplication.java b/src/main/java/com/provedcode/ProvedCodeApplication.java index fc86627..e780cab 100644 --- a/src/main/java/com/provedcode/ProvedCodeApplication.java +++ b/src/main/java/com/provedcode/ProvedCodeApplication.java @@ -6,7 +6,7 @@ @SpringBootApplication @ConfigurationPropertiesScan -public class ProvedCodeApplication { +public class ProvedCodeApplication { public static void main(String[] args) { SpringApplication.run(ProvedCodeApplication.class, args); diff --git a/src/main/java/com/provedcode/user/controller/AuthenticationController.java b/src/main/java/com/provedcode/user/controller/AuthenticationController.java index 4bd9bd0..2a04c69 100644 --- a/src/main/java/com/provedcode/user/controller/AuthenticationController.java +++ b/src/main/java/com/provedcode/user/controller/AuthenticationController.java @@ -14,7 +14,6 @@ @AllArgsConstructor @Slf4j @RequestMapping("/api/talents") -@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE}) public class AuthenticationController { AuthenticationService authenticationService; From 88235c21a64206804d10ff15f6e03d2fcb40a7d0 Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 22:01:11 +0300 Subject: [PATCH 09/30] Add cors to config, add new endpoint to permitAll --- .../com/provedcode/config/SecurityConfig.java | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/provedcode/config/SecurityConfig.java b/src/main/java/com/provedcode/config/SecurityConfig.java index 0a74202..13c0ee8 100644 --- a/src/main/java/com/provedcode/config/SecurityConfig.java +++ b/src/main/java/com/provedcode/config/SecurityConfig.java @@ -28,6 +28,8 @@ import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint; import org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler; import org.springframework.security.web.SecurityFilterChain; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -47,7 +49,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.authorizeHttpRequests(c -> c .requestMatchers("/actuator/health").permitAll() // for DevOps .requestMatchers(antMatcher("/h2/**")).permitAll() - //.requestMatchers(antMatcher("/api/talents/login")).permitAll() .requestMatchers(antMatcher("/api/talents/**")).permitAll() .requestMatchers(antMatcher("/error")).permitAll() .anyRequest().authenticated() @@ -55,38 +56,53 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti http.exceptionHandling(c -> c .authenticationEntryPoint((request, response, authException) -> { - log.info("Authentication failed {}, message:{}", - describe(request), - authException.getMessage()); - response.sendError( - HttpStatus.UNAUTHORIZED.value(), - authException.getMessage()); - } + log.info("Authentication failed {}, message:{}", + describe(request), + authException.getMessage()); + response.sendError( + HttpStatus.UNAUTHORIZED.value(), + authException.getMessage()); + } ) .accessDeniedHandler((request, response, accessDeniedException) -> { - log.info("Authorization failed {},message: {}", - describe(request), - accessDeniedException.getMessage()); - response.sendError(HttpStatus.FORBIDDEN.value(), - accessDeniedException.getMessage()); - } + log.info("Authorization failed {},message: {}", + describe(request), + accessDeniedException.getMessage()); + response.sendError(HttpStatus.FORBIDDEN.value(), + accessDeniedException.getMessage()); + } ) ); http.httpBasic(Customizer.withDefaults()); http.csrf().disable().headers().disable(); + http.cors(); + http.sessionManagement().sessionCreationPolicy(STATELESS); http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt) - .exceptionHandling(c -> c - .authenticationEntryPoint(new BearerTokenAuthenticationEntryPoint()) - .accessDeniedHandler(new BearerTokenAccessDeniedHandler()) - ); + .exceptionHandling(c -> c + .authenticationEntryPoint(new BearerTokenAuthenticationEntryPoint()) + .accessDeniedHandler(new BearerTokenAccessDeniedHandler()) + ); return http.build(); } + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("*"); + } + }; + } + public String describe(HttpServletRequest request) { return request.getRequestURI(); } @@ -119,8 +135,8 @@ UserDetailsService userDetailsService( UserInfoMapper mapper ) { return login -> repository.findByLogin(login) - .map(mapper::toUserDetails) - .orElseThrow(() -> new UsernameNotFoundException(login + " not found")); + .map(mapper::toUserDetails) + .orElseThrow(() -> new UsernameNotFoundException(login + " not found")); } @Bean From 816c733328928ac1929694cf3eb3ed51477eb2dd Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 22:01:33 +0300 Subject: [PATCH 10/30] Add new table for Proofs --- src/main/resources/schema.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 6586f9f..ff6d62c 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -66,6 +66,14 @@ create TABLE talent_attached_file ( alter table talent_attached_file add CONSTRAINT FK_TALENT_ATTACHED_FILE_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +CREATE TABLE talent_proofs ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + proof VARCHAR(100), + CONSTRAINT pk_talent_proofs PRIMARY KEY (id) +); + +ALTER TABLE talent_proofs ADD CONSTRAINT FK_TALENT_PROOFS_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); --user tables-- CREATE TABLE authority ( From 11153a35bf0687caa7e58b1434d3d542f500f7c5 Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 22:01:57 +0300 Subject: [PATCH 11/30] Moved file --- .../provedcode/talent/{ => controller}/TalentController.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename src/main/java/com/provedcode/talent/{ => controller}/TalentController.java (89%) diff --git a/src/main/java/com/provedcode/talent/TalentController.java b/src/main/java/com/provedcode/talent/controller/TalentController.java similarity index 89% rename from src/main/java/com/provedcode/talent/TalentController.java rename to src/main/java/com/provedcode/talent/controller/TalentController.java index ece8230..ead1d1e 100644 --- a/src/main/java/com/provedcode/talent/TalentController.java +++ b/src/main/java/com/provedcode/talent/controller/TalentController.java @@ -1,4 +1,4 @@ -package com.provedcode.talent; +package com.provedcode.talent.controller; import com.provedcode.talent.model.dto.FullTalentDTO; import com.provedcode.talent.model.dto.ShortTalentDTO; @@ -18,8 +18,6 @@ @Slf4j @RestController @AllArgsConstructor -@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, - RequestMethod.DELETE}) @RequestMapping("/api") public class TalentController { TalentService talentService; From d6a62b5b1426584b01a7f30b9d898db307dda6c6 Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 22:02:42 +0300 Subject: [PATCH 12/30] Delete unused variables --- .../com/provedcode/talent/service/impl/TalentServiceImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java index 2d37e80..4187a81 100644 --- a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java +++ b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java @@ -6,7 +6,6 @@ import com.provedcode.talent.model.dto.ShortTalentDTO; import com.provedcode.talent.model.entity.*; import com.provedcode.talent.repo.TalentRepository; -import com.provedcode.talent.repo.TalentSkillRepository; import com.provedcode.talent.service.TalentService; import com.provedcode.user.model.dto.SessionInfoDTO; import com.provedcode.user.model.entity.UserInfo; @@ -32,10 +31,8 @@ public class TalentServiceImpl implements TalentService { TalentMapper talentMapper; TalentRepository talentRepository; - TalentSkillRepository talentSkillRepository; UserInfoRepository userInfoRepository; PageProperties pageProperties; - TalentRepository talentEntityRepository; @Override From 02a1de9ce916ca8969ce4388dda1cf6be83c16c5 Mon Sep 17 00:00:00 2001 From: Ren Date: Wed, 5 Apr 2023 22:06:32 +0300 Subject: [PATCH 13/30] Create ProofDTO, TalentProofController, TalentProofMapper, TalentProof entity, TalentProofService and TalentProofRepository --- .../controller/TalentProofController.java | 24 ++++++++++++++++ .../talent/mapper/TalentProofMapper.java | 15 ++++++++++ .../provedcode/talent/model/dto/ProofDTO.java | 10 +++++++ .../talent/model/entity/TalentProof.java | 28 +++++++++++++++++++ .../talent/repo/TalentProofRepository.java | 7 +++++ .../talent/service/TalentProofService.java | 18 ++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 src/main/java/com/provedcode/talent/controller/TalentProofController.java create mode 100644 src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java create mode 100644 src/main/java/com/provedcode/talent/model/dto/ProofDTO.java create mode 100644 src/main/java/com/provedcode/talent/model/entity/TalentProof.java create mode 100644 src/main/java/com/provedcode/talent/repo/TalentProofRepository.java create mode 100644 src/main/java/com/provedcode/talent/service/TalentProofService.java diff --git a/src/main/java/com/provedcode/talent/controller/TalentProofController.java b/src/main/java/com/provedcode/talent/controller/TalentProofController.java new file mode 100644 index 0000000..f91bd76 --- /dev/null +++ b/src/main/java/com/provedcode/talent/controller/TalentProofController.java @@ -0,0 +1,24 @@ +package com.provedcode.talent.controller; + +import com.provedcode.talent.mapper.TalentProofMapper; +import com.provedcode.talent.model.dto.ProofDTO; +import com.provedcode.talent.service.TalentProofService; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@AllArgsConstructor +@RequestMapping("/api/talents") +public class TalentProofController { + TalentProofService talentProofService; + TalentProofMapper talentProofMapper; + + @GetMapping("/proofs") + List getAllProofs() { + return talentProofService.getAllProofs().stream().map(talentProofMapper::toProofDTO).toList(); + } +} diff --git a/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java b/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java new file mode 100644 index 0000000..e605c10 --- /dev/null +++ b/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java @@ -0,0 +1,15 @@ +package com.provedcode.talent.mapper; + +import com.provedcode.talent.model.dto.ProofDTO; +import com.provedcode.talent.model.entity.TalentProof; +import org.springframework.stereotype.Component; + +@Component +public class TalentProofMapper { + public ProofDTO toProofDTO(TalentProof talentProof) { + return ProofDTO.builder() + .id(talentProof.getTalentId()) + .proof(talentProof.getProof()) + .build(); + } +} diff --git a/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java b/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java new file mode 100644 index 0000000..d002b79 --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java @@ -0,0 +1,10 @@ +package com.provedcode.talent.model.dto; + +import lombok.Builder; + +@Builder +public record ProofDTO( + long id, + String proof +) { +} diff --git a/src/main/java/com/provedcode/talent/model/entity/TalentProof.java b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java new file mode 100644 index 0000000..8d365d2 --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java @@ -0,0 +1,28 @@ +package com.provedcode.talent.model.entity; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Getter +@Setter +@Entity +@Table(name = "talent_proofs") +public class TalentProof { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; + @NotNull + @Column(name = "talent_id", nullable = false) + private Long talentId; + @Column(name = "proof", length = 100) + private String proof; + @NotNull + @ManyToOne + @JoinColumn(name = "talent_id", insertable = false, updatable = false) + private Talent talent; +} \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java b/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java new file mode 100644 index 0000000..c29606f --- /dev/null +++ b/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java @@ -0,0 +1,7 @@ +package com.provedcode.talent.repo; + +import com.provedcode.talent.model.entity.TalentProof; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TalentProofRepository extends JpaRepository { +} \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/service/TalentProofService.java b/src/main/java/com/provedcode/talent/service/TalentProofService.java new file mode 100644 index 0000000..b8cbddc --- /dev/null +++ b/src/main/java/com/provedcode/talent/service/TalentProofService.java @@ -0,0 +1,18 @@ +package com.provedcode.talent.service; + +import com.provedcode.talent.model.entity.TalentProof; +import com.provedcode.talent.repo.TalentProofRepository; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@AllArgsConstructor +public class TalentProofService { + TalentProofRepository talentProofRepository; + + public List getAllProofs() { + return talentProofRepository.findAll(); + } +} From 3b5d68684ed67963311bc483012399f4b7062f91 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:55:07 +0300 Subject: [PATCH 14/30] Add mapstruct dependencies --- pom.xml | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index e0a4257..3aa3cac 100644 --- a/pom.xml +++ b/pom.xml @@ -68,27 +68,45 @@ spring-security-test test - org.postgresql postgresql 42.6.0 + + org.mapstruct + mapstruct + 1.5.3.Final + - + - org.springframework.boot - spring-boot-maven-plugin + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 - - + 17 + 17 + + org.projectlombok lombok - - + 1.18.26 + + + org.mapstruct + mapstruct-processor + 1.5.3.Final + + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + + From 131568d6121fd27f53771022c59b42438854cdfd Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:55:42 +0300 Subject: [PATCH 15/30] Edit dev.pros - change logging level --- src/main/resources/application-dev.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 4d1fff1..52a6e52 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,6 +1,6 @@ spring.datasource.username=sa spring.datasource.url=jdbc:h2:mem:testdb;MODE=PostgreSQL -logging.level.web=DEBUG -logging.level.sql=DEBUG +#logging.level.web=DEBUG +#logging.level.sql=DEBUG spring.jpa.hibernate.ddl-auto=none spring.sql.init.mode=always \ No newline at end of file From 2d56d6a789b9b120d11cf089121f60964a72fe23 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:56:32 +0300 Subject: [PATCH 16/30] Edit schema.sql: edit Proof table --- src/main/resources/schema.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index ff6d62c..1c48e2e 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -69,7 +69,10 @@ alter table talent_attached_file add CONSTRAINT FK_TALENT_ATTACHED_FILE_ON_TALEN CREATE TABLE talent_proofs ( id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, talent_id BIGINT NOT NULL, - proof VARCHAR(100), + link VARCHAR(100), + text VARCHAR(255), + status VARCHAR(255), + created TIMESTAMP, CONSTRAINT pk_talent_proofs PRIMARY KEY (id) ); From dfb0cd947989606180741c6da030d29023647744 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:56:59 +0300 Subject: [PATCH 17/30] Edit ProofDTO: add new fields --- .../java/com/provedcode/talent/model/dto/ProofDTO.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java b/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java index d002b79..fa0b99a 100644 --- a/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java +++ b/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java @@ -2,9 +2,15 @@ import lombok.Builder; +import java.time.LocalDateTime; +import java.util.Date; + @Builder public record ProofDTO( long id, - String proof + String link, + String text, + String status, + String created ) { } From 08ab3bf8e435bb0639741ce9034df387b3e0f145 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:57:22 +0300 Subject: [PATCH 18/30] Comment mapper impl --- .../talent/mapper/impl/TalentMapperImpl.java | 84 +++++++++---------- .../mapper/impl/TalentProofMapperImpl.java | 15 ++++ 2 files changed, 57 insertions(+), 42 deletions(-) create mode 100644 src/main/java/com/provedcode/talent/mapper/impl/TalentProofMapperImpl.java diff --git a/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java b/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java index bfa97f4..6a404d4 100644 --- a/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java +++ b/src/main/java/com/provedcode/talent/mapper/impl/TalentMapperImpl.java @@ -1,42 +1,42 @@ -package com.provedcode.talent.mapper.impl; - -import com.provedcode.talent.mapper.TalentMapper; -import com.provedcode.talent.model.dto.FullTalentDTO; -import com.provedcode.talent.model.dto.ShortTalentDTO; -import com.provedcode.talent.model.entity.*; -import org.springframework.stereotype.Component; - -@Component -public class TalentMapperImpl implements TalentMapper { - @Override - public ShortTalentDTO talentToShortTalentDTO(Talent talent) { - return ShortTalentDTO.builder() - .id(talent.getId()) - .image(talent.getImage()) - .firstName(talent.getFirstName()) - .lastName(talent.getLastName()) - .specialization(talent.getSpecialization()) - .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) - .build(); - } - - @Override - public FullTalentDTO talentToFullTalentDTO(Talent talent) { - return FullTalentDTO.builder() - .id(talent.getId()) - .firstName(talent.getFirstName()) - .lastName(talent.getLastName()) - .bio(talent.getTalentDescription() != null ? talent.getTalentDescription().getBio() : null) - .additionalInfo(talent.getTalentDescription() != null ? talent.getTalentDescription() - .getAdditionalInfo() : null) - .image(talent.getImage()) - .specialization(talent.getSpecialization()) - .links(talent.getTalentLinks().stream().map(TalentLink::getLink).toList()) - .contacts(talent.getTalentContacts().stream().map(TalentContact::getContact).toList()) - .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) - .attachedFiles( - talent.getTalentAttachedFiles().stream().map(TalentAttachedFile::getAttachedFile) - .toList()) - .build(); - } -} +//package com.provedcode.talent.mapper.impl; +// +//import com.provedcode.talent.mapper.TalentMapper; +//import com.provedcode.talent.model.dto.FullTalentDTO; +//import com.provedcode.talent.model.dto.ShortTalentDTO; +//import com.provedcode.talent.model.entity.*; +//import org.springframework.stereotype.Component; +// +//@Component +//public class TalentMapperImpl implements TalentMapper { +// @Override +// public ShortTalentDTO talentToShortTalentDTO(Talent talent) { +// return ShortTalentDTO.builder() +// .id(talent.getId()) +// .image(talent.getImage()) +// .firstName(talent.getFirstName()) +// .lastName(talent.getLastName()) +// .specialization(talent.getSpecialization()) +// .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) +// .build(); +// } +// +// @Override +// public FullTalentDTO talentToFullTalentDTO(Talent talent) { +// return FullTalentDTO.builder() +// .id(talent.getId()) +// .firstName(talent.getFirstName()) +// .lastName(talent.getLastName()) +// .bio(talent.getTalentDescription() != null ? talent.getTalentDescription().getBio() : null) +// .additionalInfo(talent.getTalentDescription() != null ? talent.getTalentDescription() +// .getAdditionalInfo() : null) +// .image(talent.getImage()) +// .specialization(talent.getSpecialization()) +// .links(talent.getTalentLinks().stream().map(TalentLink::getLink).toList()) +// .contacts(talent.getTalentContacts().stream().map(TalentContact::getContact).toList()) +// .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) +// .attachedFiles( +// talent.getTalentAttachedFiles().stream().map(TalentAttachedFile::getAttachedFile) +// .toList()) +// .build(); +// } +//} diff --git a/src/main/java/com/provedcode/talent/mapper/impl/TalentProofMapperImpl.java b/src/main/java/com/provedcode/talent/mapper/impl/TalentProofMapperImpl.java new file mode 100644 index 0000000..aa1361d --- /dev/null +++ b/src/main/java/com/provedcode/talent/mapper/impl/TalentProofMapperImpl.java @@ -0,0 +1,15 @@ +//package com.provedcode.talent.mapper.impl; +// +//import com.provedcode.talent.model.dto.ProofDTO; +//import com.provedcode.talent.model.entity.TalentProof; +//import org.springframework.stereotype.Component; +// +//@Component +//public class TalentProofMapperImpl { +// public ProofDTO toProofDTO(TalentProof talentProof) { +// return ProofDTO.builder() +// .id(talentProof.getTalentId()) +// .proof(talentProof.getProof()) +// .build(); +// } +//} From 3737dbd3dcefa4603c3c34cebe3b6a9acd70a4d8 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:58:00 +0300 Subject: [PATCH 19/30] Create mappers for Talent and TalentProofs with mapstruct --- .../talent/mapper/TalentMapper.java | 8 +++++-- .../talent/mapper/TalentProofMapper.java | 23 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/provedcode/talent/mapper/TalentMapper.java b/src/main/java/com/provedcode/talent/mapper/TalentMapper.java index a3818a7..b8c29d0 100644 --- a/src/main/java/com/provedcode/talent/mapper/TalentMapper.java +++ b/src/main/java/com/provedcode/talent/mapper/TalentMapper.java @@ -2,11 +2,15 @@ import com.provedcode.talent.model.dto.FullTalentDTO; import com.provedcode.talent.model.dto.ShortTalentDTO; -import com.provedcode.talent.model.entity.*; +import com.provedcode.talent.model.entity.Talent; +import org.mapstruct.Mapper; +import org.mapstruct.MappingConstants; +import org.mapstruct.ReportingPolicy; +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING) public interface TalentMapper { - ShortTalentDTO talentToShortTalentDTO(Talent talent); + FullTalentDTO talentToFullTalentDTO(Talent talent); } diff --git a/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java b/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java index e605c10..89f636f 100644 --- a/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java +++ b/src/main/java/com/provedcode/talent/mapper/TalentProofMapper.java @@ -2,14 +2,19 @@ import com.provedcode.talent.model.dto.ProofDTO; import com.provedcode.talent.model.entity.TalentProof; -import org.springframework.stereotype.Component; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.MappingConstants; +import org.mapstruct.ReportingPolicy; -@Component -public class TalentProofMapper { - public ProofDTO toProofDTO(TalentProof talentProof) { - return ProofDTO.builder() - .id(talentProof.getTalentId()) - .proof(talentProof.getProof()) - .build(); - } +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING) +public interface TalentProofMapper { + @Mapping(source = "talentId", target = "id") + @Mapping(source = "created", target = "created", dateFormat = "dd-MM-yyyy HH:mm:ss") + ProofDTO toProofDTO(TalentProof talentProof); + + @Mapping(source = "id", target = "talentId") + @Mapping(target = "id", ignore = true) + @Mapping(source = "created", target = "created", dateFormat = "dd-MM-yyyy HH:mm:ss") + TalentProof toTalentProof(ProofDTO proofDTO); } From 18ab270d1ef2c2a1c5c5e08cdf6d6b19b2177be5 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:58:21 +0300 Subject: [PATCH 20/30] Create mapper for UserInfo with mapstruct --- .../provedcode/user/mapper/UserInfoMapper.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java b/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java index d7138b4..478c002 100644 --- a/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java +++ b/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java @@ -1,8 +1,22 @@ package com.provedcode.user.mapper; import com.provedcode.user.model.entity.UserInfo; +import org.mapstruct.Mapper; +import org.mapstruct.MappingConstants; +import org.mapstruct.ReportingPolicy; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING) public interface UserInfoMapper { - UserDetails toUserDetails(UserInfo user); + default UserDetails toUserDetails(UserInfo user) { + return User.withUsername(user.getLogin()) + .password(user.getPassword()) + .authorities(user.getAuthorities() + .stream() + .map(i -> new SimpleGrantedAuthority(i.getAuthority())) + .toList()) + .build(); + } } From e926ee50837ca3905eb475a93e4a873eaadca56a Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:58:52 +0300 Subject: [PATCH 21/30] Comment UserInfo mapper impl --- .../user/mapper/impl/UserInfoMapperImpl.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java b/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java index 8e451e5..e2b6bc4 100644 --- a/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java +++ b/src/main/java/com/provedcode/user/mapper/impl/UserInfoMapperImpl.java @@ -1,24 +1,24 @@ -package com.provedcode.user.mapper.impl; - -import com.provedcode.user.mapper.UserInfoMapper; -import com.provedcode.user.model.entity.UserInfo; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -public class UserInfoMapperImpl implements UserInfoMapper { - @Override - public UserDetails toUserDetails(UserInfo user) { - return User.withUsername(user.getLogin()) - .password(user.getPassword()) - .authorities(user.getAuthorities() - .stream() - .map(i -> new SimpleGrantedAuthority(i.getAuthority())) - .toList()) - .build(); - } -} +//package com.provedcode.user.mapper.impl; +// +//import com.provedcode.user.mapper.UserInfoMapper; +//import com.provedcode.user.model.entity.UserInfo; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.security.core.authority.SimpleGrantedAuthority; +//import org.springframework.security.core.userdetails.User; +//import org.springframework.security.core.userdetails.UserDetails; +//import org.springframework.stereotype.Component; +// +//@Component +//@Slf4j +//public class UserInfoMapperImpl implements UserInfoMapper { +// @Override +// public UserDetails toUserDetails(UserInfo user) { +// return User.withUsername(user.getLogin()) +// .password(user.getPassword()) +// .authorities(user.getAuthorities() +// .stream() +// .map(i -> new SimpleGrantedAuthority(i.getAuthority())) +// .toList()) +// .build(); +// } +//} From b5574fa9c70770404293e72e5ca60218d80cad1e Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 14:59:26 +0300 Subject: [PATCH 22/30] Remove unused method --- .../java/com/provedcode/talent/model/entity/Talent.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/provedcode/talent/model/entity/Talent.java b/src/main/java/com/provedcode/talent/model/entity/Talent.java index c5bb6a7..28cf24c 100644 --- a/src/main/java/com/provedcode/talent/model/entity/Talent.java +++ b/src/main/java/com/provedcode/talent/model/entity/Talent.java @@ -44,12 +44,4 @@ public class Talent { private List talentContacts = new ArrayList<>(); @OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) private List talentAttachedFiles = new ArrayList<>(); - - public void addTalentSkill(TalentTalents talentTalents) { - this.talentTalents.add(talentTalents); - } - - public void removeTalentSkill(TalentTalents talentTalents) { - this.talentTalents.remove(talentTalents); - } } \ No newline at end of file From d78c10219ac14047ef8d6425eb3d5760b30f7e25 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 15:00:16 +0300 Subject: [PATCH 23/30] Move mapping from service to controller for Talent --- .../talent/controller/TalentController.java | 8 ++- .../service/impl/TalentServiceImpl.java | 55 ++++++++++--------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/provedcode/talent/controller/TalentController.java b/src/main/java/com/provedcode/talent/controller/TalentController.java index ead1d1e..e009148 100644 --- a/src/main/java/com/provedcode/talent/controller/TalentController.java +++ b/src/main/java/com/provedcode/talent/controller/TalentController.java @@ -1,5 +1,6 @@ package com.provedcode.talent.controller; +import com.provedcode.talent.mapper.TalentMapper; import com.provedcode.talent.model.dto.FullTalentDTO; import com.provedcode.talent.model.dto.ShortTalentDTO; import com.provedcode.talent.service.TalentService; @@ -21,20 +22,21 @@ @RequestMapping("/api") public class TalentController { TalentService talentService; + TalentMapper talentMapper; @PreAuthorize("hasRole('TALENT')") @GetMapping("/talents/{id}") FullTalentDTO getTalent(@PathVariable("id") long id, Authentication authentication) { log.info("get-talent auth = {}", authentication); log.info("get-talent auth.name = {}", authentication.getAuthorities()); - return talentService.getTalentById(id); + return talentMapper.talentToFullTalentDTO(talentService.getTalentById(id)); } @GetMapping("/talents") @ResponseStatus(HttpStatus.OK) Page getTalents(@RequestParam(value = "page") Optional page, @RequestParam(value = "size") Optional size) { - return talentService.getTalentsPage(page, size); + return talentService.getTalentsPage(page, size).map(talentMapper::talentToShortTalentDTO); } @PreAuthorize("hasRole('TALENT')") @@ -42,7 +44,7 @@ Page getTalents(@RequestParam(value = "page") Optional FullTalentDTO editTalent(@PathVariable("talent-id") long id, @RequestBody @Valid FullTalentDTO fullTalent, Authentication authentication) { - return talentService.editTalent(id, fullTalent, authentication); + return talentMapper.talentToFullTalentDTO(talentService.editTalent(id, fullTalent, authentication)); } @PreAuthorize("hasRole('TALENT')") diff --git a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java index 4187a81..ae84632 100644 --- a/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java +++ b/src/main/java/com/provedcode/talent/service/impl/TalentServiceImpl.java @@ -29,7 +29,6 @@ @AllArgsConstructor @Transactional public class TalentServiceImpl implements TalentService { - TalentMapper talentMapper; TalentRepository talentRepository; UserInfoRepository userInfoRepository; PageProperties pageProperties; @@ -37,7 +36,7 @@ public class TalentServiceImpl implements TalentService { @Override @Transactional(readOnly = true) - public Page getTalentsPage(Optional page, Optional size) { + public Page getTalentsPage(Optional page, Optional size) { if (page.orElse(pageProperties.defaultPageNum()) < 0) { throw new ResponseStatusException(BAD_REQUEST, "'page' query parameter must be greater than or equal to 0"); } @@ -45,23 +44,22 @@ public Page getTalentsPage(Optional page, Optional talent = talentRepository.findById(id); if (talent.isEmpty()) { throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); } - return talentMapper.talentToFullTalentDTO(talent.get()); + return talent.get(); } @Override - public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authentication authentication) { + public Talent editTalent(long id, FullTalentDTO fullTalent, Authentication authentication) { Optional talent = talentRepository.findById(id); Optional userInfo = userInfoRepository.findByLogin(authentication.getName()); @@ -82,42 +80,49 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio .setBio(fullTalent.bio()); } else { oldTalentDescription = TalentDescription.builder() - .talentId(oldTalentId) - .additionalInfo(fullTalent.additionalInfo()) - .bio(fullTalent.bio()) - .talent(oldTalent).build(); + .talentId(oldTalentId) + .additionalInfo(fullTalent.additionalInfo()) + .bio(fullTalent.bio()) + .talent(oldTalent) + .build(); } oldTalentTalents.clear(); if (fullTalent.talents() != null) { oldTalentTalents.addAll(fullTalent.talents().stream().map(s -> TalentTalents.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .talentName(s).build()).toList()); + .talentId(oldTalentId) + .talent(oldTalent) + .talentName(s) + .build()).toList()); } oldTalentLinks.clear(); if (fullTalent.links() != null) { oldTalentLinks.addAll(fullTalent.links().stream().map(l -> TalentLink.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .link(l).build()).toList()); + .talentId(oldTalentId) + .talent(oldTalent) + .link(l) + .build()).toList()); } oldTalentContacts.clear(); if (fullTalent.contacts() != null) { oldTalentContacts.addAll(fullTalent.contacts().stream().map(s -> TalentContact.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .contact(s).build()).toList()); + .talentId(oldTalentId) + .talent(oldTalent) + .contact(s) + .build()).toList()); } oldTalentAttachedFile.clear(); if (fullTalent.attachedFiles() != null) { oldTalentAttachedFile.addAll(fullTalent.attachedFiles().stream().map(s -> TalentAttachedFile.builder() - .talentId(oldTalentId) - .talent(oldTalent) - .attachedFile(s).build()).toList()); + .talentId( + oldTalentId) + .talent(oldTalent) + .attachedFile(s) + .build()) + .toList()); } oldTalent.setFirstName(fullTalent.firstName()) @@ -132,7 +137,7 @@ public FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authenticatio talentRepository.save(oldTalent); - return talentMapper.talentToFullTalentDTO(oldTalent); + return oldTalent; } @Override @@ -147,7 +152,7 @@ public SessionInfoDTO deleteTalentById(long id, Authentication authentication) { return new SessionInfoDTO("deleted", "null"); } - public void userVerification(Optional talent, Optional userInfo, long id) { + private void userVerification(Optional talent, Optional userInfo, long id) { if (talent.isEmpty() || userInfo.isEmpty()) { throw new ResponseStatusException(NOT_FOUND, String.format("talent with id = %d not found", id)); } From 649805c63734baa95596becfb8f6b09e11807778 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 15:01:01 +0300 Subject: [PATCH 24/30] Change return type for Talent --- .../java/com/provedcode/talent/service/TalentService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/provedcode/talent/service/TalentService.java b/src/main/java/com/provedcode/talent/service/TalentService.java index 6e5ecb7..afc058b 100644 --- a/src/main/java/com/provedcode/talent/service/TalentService.java +++ b/src/main/java/com/provedcode/talent/service/TalentService.java @@ -1,6 +1,7 @@ package com.provedcode.talent.service; import com.provedcode.talent.model.dto.ShortTalentDTO; +import com.provedcode.talent.model.entity.Talent; import com.provedcode.user.model.dto.SessionInfoDTO; import org.springframework.security.core.Authentication; import org.springframework.data.domain.Page; @@ -10,11 +11,11 @@ public interface TalentService { - Page getTalentsPage(Optional page, Optional size); + Page getTalentsPage(Optional page, Optional size); - FullTalentDTO getTalentById(long id); + Talent getTalentById(long id); - FullTalentDTO editTalent(long id, FullTalentDTO fullTalent, Authentication authentication); + Talent editTalent(long id, FullTalentDTO fullTalent, Authentication authentication); SessionInfoDTO deleteTalentById(long id, Authentication authentication); } \ No newline at end of file From 5eb82e797a9a14541f99e02ac35a029981ae7230 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 15:02:10 +0300 Subject: [PATCH 25/30] Edit TalentProof: add new fields to Proof entity --- .../provedcode/talent/model/entity/TalentProof.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/provedcode/talent/model/entity/TalentProof.java b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java index 8d365d2..0e51df7 100644 --- a/src/main/java/com/provedcode/talent/model/entity/TalentProof.java +++ b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java @@ -1,8 +1,12 @@ package com.provedcode.talent.model.entity; import jakarta.persistence.*; +import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.*; +import org.hibernate.validator.constraints.URL; + +import java.time.LocalDateTime; @NoArgsConstructor @AllArgsConstructor @@ -19,8 +23,13 @@ public class TalentProof { @NotNull @Column(name = "talent_id", nullable = false) private Long talentId; - @Column(name = "proof", length = 100) - private String proof; + @NotEmpty + @URL + @Column(name = "link", length = 100) + private String link; + private String text; + private String status; + private LocalDateTime created; @NotNull @ManyToOne @JoinColumn(name = "talent_id", insertable = false, updatable = false) From d93a64c79af8620f3674182bdc28b751c78fe9c4 Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 15:02:38 +0300 Subject: [PATCH 26/30] Add pagination for Proofs --- .../controller/TalentProofController.java | 7 +++++-- .../talent/service/TalentProofService.java | 20 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/provedcode/talent/controller/TalentProofController.java b/src/main/java/com/provedcode/talent/controller/TalentProofController.java index f91bd76..304caed 100644 --- a/src/main/java/com/provedcode/talent/controller/TalentProofController.java +++ b/src/main/java/com/provedcode/talent/controller/TalentProofController.java @@ -6,9 +6,11 @@ import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Optional; @RestController @AllArgsConstructor @@ -18,7 +20,8 @@ public class TalentProofController { TalentProofMapper talentProofMapper; @GetMapping("/proofs") - List getAllProofs() { - return talentProofService.getAllProofs().stream().map(talentProofMapper::toProofDTO).toList(); + List getAllProofs(@RequestParam(value = "page") Optional page, + @RequestParam(value = "size") Optional size) { + return talentProofService.getAllProofsPage(page, size).stream().map(talentProofMapper::toProofDTO).toList(); } } diff --git a/src/main/java/com/provedcode/talent/service/TalentProofService.java b/src/main/java/com/provedcode/talent/service/TalentProofService.java index b8cbddc..bea8846 100644 --- a/src/main/java/com/provedcode/talent/service/TalentProofService.java +++ b/src/main/java/com/provedcode/talent/service/TalentProofService.java @@ -1,18 +1,32 @@ package com.provedcode.talent.service; +import com.provedcode.config.PageProperties; import com.provedcode.talent.model.entity.TalentProof; import com.provedcode.talent.repo.TalentProofRepository; import lombok.AllArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; +import org.springframework.web.server.ResponseStatusException; -import java.util.List; +import java.util.Optional; + +import static org.springframework.http.HttpStatus.BAD_REQUEST; @Service @AllArgsConstructor public class TalentProofService { TalentProofRepository talentProofRepository; + PageProperties pageProperties; - public List getAllProofs() { - return talentProofRepository.findAll(); + public Page getAllProofsPage(Optional page, Optional size) { + if (page.orElse(pageProperties.defaultPageNum()) < 0) { + throw new ResponseStatusException(BAD_REQUEST, "'page' query parameter must be greater than or equal to 0"); + } + if (size.orElse(pageProperties.defaultPageSize()) <= 0) { + throw new ResponseStatusException(BAD_REQUEST, "'size' query parameter must be greater than or equal to 1"); + } + return talentProofRepository.findAll(PageRequest.of(page.orElse(pageProperties.defaultPageNum()), + size.orElse(pageProperties.defaultPageSize()))); } } From 51a48cba7040f66bc56cb0f8523d0f5c1112ec7a Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 17:36:11 +0300 Subject: [PATCH 27/30] Edit pagination for Proofs: add custom method to Proof repository --- pom.xml | 206 +++++++++--------- .../talent/mapper/TalentMapper.java | 24 +- .../provedcode/talent/model/ProofStatus.java | 7 + .../provedcode/talent/model/dto/ProofDTO.java | 3 +- .../talent/model/entity/TalentProof.java | 6 +- .../talent/repo/TalentProofRepository.java | 4 + .../talent/service/TalentProofService.java | 8 +- .../service/impl/TalentServiceImpl.java | 6 +- src/main/resources/data.sql | 18 ++ src/main/resources/schema.sql | 2 +- 10 files changed, 168 insertions(+), 116 deletions(-) create mode 100644 src/main/java/com/provedcode/talent/model/ProofStatus.java diff --git a/pom.xml b/pom.xml index 3aa3cac..aa36141 100644 --- a/pom.xml +++ b/pom.xml @@ -1,78 +1,78 @@ - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.4 - - - com.provedcode - demo - 0.0.1-SNAPSHOT - ProvedCode - Demo project for Spring Boot - - 17 - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-oauth2-resource-server - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - com.h2database - h2 - runtime - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-test - test - - - org.postgresql - postgresql - 42.6.0 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.0.4 + + + com.provedcode + demo + 0.0.1-SNAPSHOT + ProvedCode + Demo project for Spring Boot + + 17 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + org.postgresql + postgresql + 42.6.0 + org.mapstruct mapstruct @@ -81,35 +81,35 @@ - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - 17 - 17 - - - org.projectlombok - lombok - 1.18.26 - - - org.mapstruct - mapstruct-processor - 1.5.3.Final - - - org.projectlombok - lombok-mapstruct-binding - 0.2.0 - - - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 17 + 17 + + + org.projectlombok + lombok + 1.18.26 + + + org.mapstruct + mapstruct-processor + 1.5.3.Final + + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + + + + + + diff --git a/src/main/java/com/provedcode/talent/mapper/TalentMapper.java b/src/main/java/com/provedcode/talent/mapper/TalentMapper.java index b8c29d0..b3d25e2 100644 --- a/src/main/java/com/provedcode/talent/mapper/TalentMapper.java +++ b/src/main/java/com/provedcode/talent/mapper/TalentMapper.java @@ -2,15 +2,31 @@ import com.provedcode.talent.model.dto.FullTalentDTO; import com.provedcode.talent.model.dto.ShortTalentDTO; -import com.provedcode.talent.model.entity.Talent; +import com.provedcode.talent.model.entity.*; import org.mapstruct.Mapper; import org.mapstruct.MappingConstants; import org.mapstruct.ReportingPolicy; @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING) public interface TalentMapper { - ShortTalentDTO talentToShortTalentDTO(Talent talent); - - FullTalentDTO talentToFullTalentDTO(Talent talent); + default FullTalentDTO talentToFullTalentDTO(Talent talent) { + return FullTalentDTO.builder() + .id(talent.getId()) + .firstName(talent.getFirstName()) + .lastName(talent.getLastName()) + .bio(talent.getTalentDescription() != null ? talent.getTalentDescription().getBio() : null) + .additionalInfo(talent.getTalentDescription() != null ? talent.getTalentDescription() + .getAdditionalInfo() : null) + .image(talent.getImage()) + .specialization(talent.getSpecialization()) + .links(talent.getTalentLinks().stream().map(TalentLink::getLink).toList()) + .contacts(talent.getTalentContacts().stream().map(TalentContact::getContact).toList()) + .talents(talent.getTalentTalents().stream().map(TalentTalents::getTalentName).toList()) + .attachedFiles( + talent.getTalentAttachedFiles().stream().map(TalentAttachedFile::getAttachedFile) + .toList()) + .build(); + } + ShortTalentDTO talentToShortTalentDTO(Talent talent); } diff --git a/src/main/java/com/provedcode/talent/model/ProofStatus.java b/src/main/java/com/provedcode/talent/model/ProofStatus.java new file mode 100644 index 0000000..d98204e --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/ProofStatus.java @@ -0,0 +1,7 @@ +package com.provedcode.talent.model; + +public enum ProofStatus { + DRAFT, + PUBLISHED, + HIDDEN +} diff --git a/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java b/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java index fa0b99a..b88739a 100644 --- a/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java +++ b/src/main/java/com/provedcode/talent/model/dto/ProofDTO.java @@ -1,5 +1,6 @@ package com.provedcode.talent.model.dto; +import com.provedcode.talent.model.ProofStatus; import lombok.Builder; import java.time.LocalDateTime; @@ -10,7 +11,7 @@ public record ProofDTO( long id, String link, String text, - String status, + ProofStatus status, String created ) { } diff --git a/src/main/java/com/provedcode/talent/model/entity/TalentProof.java b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java index 0e51df7..942e56a 100644 --- a/src/main/java/com/provedcode/talent/model/entity/TalentProof.java +++ b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java @@ -1,5 +1,6 @@ package com.provedcode.talent.model.entity; +import com.provedcode.talent.model.ProofStatus; import jakarta.persistence.*; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; @@ -28,7 +29,10 @@ public class TalentProof { @Column(name = "link", length = 100) private String link; private String text; - private String status; + @NotNull + @Enumerated(EnumType.STRING) + @Column(length = 20) + private ProofStatus status; private LocalDateTime created; @NotNull @ManyToOne diff --git a/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java b/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java index c29606f..8db70e6 100644 --- a/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java +++ b/src/main/java/com/provedcode/talent/repo/TalentProofRepository.java @@ -1,7 +1,11 @@ package com.provedcode.talent.repo; +import com.provedcode.talent.model.ProofStatus; import com.provedcode.talent.model.entity.TalentProof; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; public interface TalentProofRepository extends JpaRepository { + Page findByStatus(ProofStatus status, Pageable pageable); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/service/TalentProofService.java b/src/main/java/com/provedcode/talent/service/TalentProofService.java index bea8846..a4d817a 100644 --- a/src/main/java/com/provedcode/talent/service/TalentProofService.java +++ b/src/main/java/com/provedcode/talent/service/TalentProofService.java @@ -1,6 +1,7 @@ package com.provedcode.talent.service; import com.provedcode.config.PageProperties; +import com.provedcode.talent.model.ProofStatus; import com.provedcode.talent.model.entity.TalentProof; import com.provedcode.talent.repo.TalentProofRepository; import lombok.AllArgsConstructor; @@ -26,7 +27,10 @@ public Page getAllProofsPage(Optional page, Optional Date: Thu, 6 Apr 2023 17:59:18 +0300 Subject: [PATCH 28/30] Edit role: change String to Enum --- .../user/mapper/UserInfoMapper.java | 5 ++- .../java/com/provedcode/user/model/Role.java | 8 ++-- .../user/model/entity/Authority.java | 4 +- .../user/repo/AuthorityRepository.java | 3 +- .../impl/AuthenticationServiceImpl.java | 42 ++++++++++--------- src/main/resources/data.sql | 2 +- 6 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java b/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java index 478c002..7cbca7b 100644 --- a/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java +++ b/src/main/java/com/provedcode/user/mapper/UserInfoMapper.java @@ -1,10 +1,11 @@ package com.provedcode.user.mapper; +import com.provedcode.user.model.entity.Authority; import com.provedcode.user.model.entity.UserInfo; import org.mapstruct.Mapper; import org.mapstruct.MappingConstants; import org.mapstruct.ReportingPolicy; -import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; @@ -15,7 +16,7 @@ default UserDetails toUserDetails(UserInfo user) { .password(user.getPassword()) .authorities(user.getAuthorities() .stream() - .map(i -> new SimpleGrantedAuthority(i.getAuthority())) + .map(Authority::getAuthority) .toList()) .build(); } diff --git a/src/main/java/com/provedcode/user/model/Role.java b/src/main/java/com/provedcode/user/model/Role.java index d1f1e35..d63f679 100644 --- a/src/main/java/com/provedcode/user/model/Role.java +++ b/src/main/java/com/provedcode/user/model/Role.java @@ -1,6 +1,8 @@ package com.provedcode.user.model; -public enum Role { +import org.springframework.security.core.GrantedAuthority; + +public enum Role implements GrantedAuthority { TALENT("ROLE_TALENT"); private final String userRole; @@ -9,7 +11,7 @@ public enum Role { } @Override - public String toString() { + public String getAuthority() { return this.userRole; } -} +} \ No newline at end of file diff --git a/src/main/java/com/provedcode/user/model/entity/Authority.java b/src/main/java/com/provedcode/user/model/entity/Authority.java index b892634..36f2471 100644 --- a/src/main/java/com/provedcode/user/model/entity/Authority.java +++ b/src/main/java/com/provedcode/user/model/entity/Authority.java @@ -1,5 +1,6 @@ package com.provedcode.user.model.entity; +import com.provedcode.user.model.Role; import jakarta.persistence.*; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; @@ -18,10 +19,11 @@ public class Authority { @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) private Long id; + @Enumerated(EnumType.STRING) @NotEmpty @NotNull @Column(name = "authority", length = 20) - private String authority; + private Role authority; @ManyToMany(fetch = FetchType.EAGER, mappedBy = "authorities", cascade = {CascadeType.PERSIST, CascadeType.MERGE}) private Set userInfoes = new LinkedHashSet<>(); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/user/repo/AuthorityRepository.java b/src/main/java/com/provedcode/user/repo/AuthorityRepository.java index dbb713e..9ad9a0f 100644 --- a/src/main/java/com/provedcode/user/repo/AuthorityRepository.java +++ b/src/main/java/com/provedcode/user/repo/AuthorityRepository.java @@ -1,10 +1,11 @@ package com.provedcode.user.repo; +import com.provedcode.user.model.Role; import com.provedcode.user.model.entity.Authority; import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; public interface AuthorityRepository extends JpaRepository { - Optional findByAuthority(String authority); + Optional findByAuthority(Role authority); } \ No newline at end of file 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 3558cad..8911bb6 100644 --- a/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java +++ b/src/main/java/com/provedcode/user/service/impl/AuthenticationServiceImpl.java @@ -2,8 +2,10 @@ import com.provedcode.talent.model.entity.Talent; 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.entity.Authority; import com.provedcode.user.model.entity.UserInfo; import com.provedcode.user.repo.AuthorityRepository; import com.provedcode.user.repo.UserInfoRepository; @@ -12,7 +14,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.oauth2.jwt.JwtClaimsSet; import org.springframework.security.oauth2.jwt.JwtEncoder; @@ -47,30 +48,32 @@ public SessionInfoDTO login(String name, Collection public SessionInfoDTO 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(); - userInfo.setAuthorities(Set.of(authorityRepository.findByAuthority("ROLE_TALENT").orElseThrow())); + .talentId(talent.getId()) + .login(user.login()) + .password(passwordEncoder.encode(user.password())) + .build(); + userInfo.setAuthorities(Set.of(authorityRepository.findByAuthority(Role.TALENT).orElseThrow())); userInfoRepository.save(userInfo); String userLogin = userInfo.getLogin(); - Collection userAuthorities = userInfo.getAuthorities().stream().map(i -> new SimpleGrantedAuthority(i.getAuthority())).toList(); + Collection userAuthorities = userInfo.getAuthorities().stream().map( + Authority::getAuthority).toList(); 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 SessionInfoDTO("User: {%s} was registered".formatted(userLogin), + generateJWTToken(userLogin, userAuthorities)); } private String generateJWTToken(String name, Collection authorities) { @@ -78,12 +81,13 @@ private String generateJWTToken(String name, Collection Date: Thu, 6 Apr 2023 18:04:30 +0300 Subject: [PATCH 29/30] Edit TalentProofController --- .../provedcode/talent/controller/TalentProofController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/provedcode/talent/controller/TalentProofController.java b/src/main/java/com/provedcode/talent/controller/TalentProofController.java index 304caed..f9a2101 100644 --- a/src/main/java/com/provedcode/talent/controller/TalentProofController.java +++ b/src/main/java/com/provedcode/talent/controller/TalentProofController.java @@ -4,12 +4,12 @@ import com.provedcode.talent.model.dto.ProofDTO; import com.provedcode.talent.service.TalentProofService; import lombok.AllArgsConstructor; +import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; import java.util.Optional; @RestController @@ -20,8 +20,8 @@ public class TalentProofController { TalentProofMapper talentProofMapper; @GetMapping("/proofs") - List getAllProofs(@RequestParam(value = "page") Optional page, + Page getAllProofs(@RequestParam(value = "page") Optional page, @RequestParam(value = "size") Optional size) { - return talentProofService.getAllProofsPage(page, size).stream().map(talentProofMapper::toProofDTO).toList(); + return talentProofService.getAllProofsPage(page, size).map(talentProofMapper::toProofDTO); } } From 272d71b9e54ce4e12f09bb0a0cf86a3ab185df2d Mon Sep 17 00:00:00 2001 From: Ren Date: Thu, 6 Apr 2023 18:14:52 +0300 Subject: [PATCH 30/30] Change version in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa36141..64ee618 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.provedcode demo - 0.0.1-SNAPSHOT + 0.1.1-SNAPSHOT ProvedCode Demo project for Spring Boot