diff --git a/src/main/java/com/provedcode/aws/scheduler/UpdateScheduler.java b/src/main/java/com/provedcode/aws/scheduler/UpdateScheduler.java index c9988dc..acb5b40 100644 --- a/src/main/java/com/provedcode/aws/scheduler/UpdateScheduler.java +++ b/src/main/java/com/provedcode/aws/scheduler/UpdateScheduler.java @@ -11,7 +11,6 @@ @Transactional @AllArgsConstructor public class UpdateScheduler { - FileService fileService; TalentRepository talentRepository; diff --git a/src/main/java/com/provedcode/aws/service/S3Service.java b/src/main/java/com/provedcode/aws/service/S3Service.java index e961c20..a7a4dc9 100644 --- a/src/main/java/com/provedcode/aws/service/S3Service.java +++ b/src/main/java/com/provedcode/aws/service/S3Service.java @@ -126,7 +126,7 @@ private String getFullPath(String fileType, String userLogin) { private String getFileType(MultipartFile file) { String fileName = file.getOriginalFilename(); - return fileName.substring(fileName.lastIndexOf('.') + 1); + return fileName != null ? fileName.substring(fileName.lastIndexOf('.') + 1) : null; } private File convertMultiPartToFile(MultipartFile file) diff --git a/src/main/java/com/provedcode/config/SecurityConfig.java b/src/main/java/com/provedcode/config/SecurityConfig.java index 1997071..dff7a62 100644 --- a/src/main/java/com/provedcode/config/SecurityConfig.java +++ b/src/main/java/com/provedcode/config/SecurityConfig.java @@ -53,6 +53,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .requestMatchers(antMatcher("/api/*/talents/**")).permitAll() .requestMatchers(antMatcher("/api/*/sponsors/**")).permitAll() .requestMatchers(antMatcher("/api/*/login")).permitAll() + .requestMatchers(antMatcher("/api/*/skills")).permitAll() .requestMatchers(antMatcher("/error")).permitAll() .requestMatchers(antMatcher("/v3/api-docs/**")).permitAll() // for openAPI .requestMatchers(antMatcher("/swagger-ui/**")).permitAll() // for openAPI diff --git a/src/main/java/com/provedcode/talent/controller/SkillController.java b/src/main/java/com/provedcode/talent/controller/SkillController.java new file mode 100644 index 0000000..91297db --- /dev/null +++ b/src/main/java/com/provedcode/talent/controller/SkillController.java @@ -0,0 +1,28 @@ +package com.provedcode.talent.controller; + +import com.provedcode.talent.model.dto.SkillDTO; +import com.provedcode.talent.service.SkillsService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +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; + +@Slf4j +@Validated +@AllArgsConstructor + +@RestController +@RequestMapping("/api/v4") +public class SkillController { + SkillsService skillsService; + + @GetMapping("/skills") + List getFilteredSkills(@RequestParam(value = "filter-by", required = false, defaultValue = "") String filterBy) { + return skillsService.getFilteredSkills(filterBy); + } +} diff --git a/src/main/java/com/provedcode/talent/controller/TalentProofController.java b/src/main/java/com/provedcode/talent/controller/TalentProofController.java index 2b5e769..25492f0 100644 --- a/src/main/java/com/provedcode/talent/controller/TalentProofController.java +++ b/src/main/java/com/provedcode/talent/controller/TalentProofController.java @@ -51,7 +51,7 @@ ProofDTO getTalentProof(@PathVariable(value = "proof-id") long proofId, @GetTalentInformationWithProofsApiDoc @GetMapping("/{talent-id}/proofs") - @PreAuthorize("hasRole('TALENT')") + @PreAuthorize("hasAnyRole('TALENT','SPONSOR')") FullProofDTO getTalentInformationWithProofs(Authentication authentication, @PathVariable("talent-id") Long talentId, @RequestParam(value = "page", defaultValue = "0") @PositiveOrZero Integer page, diff --git a/src/main/java/com/provedcode/talent/controller/TalentSkillsController.java b/src/main/java/com/provedcode/talent/controller/TalentSkillsController.java new file mode 100644 index 0000000..bc0a57e --- /dev/null +++ b/src/main/java/com/provedcode/talent/controller/TalentSkillsController.java @@ -0,0 +1,45 @@ +package com.provedcode.talent.controller; + +import com.provedcode.talent.model.dto.ProofSkillsDTO; +import com.provedcode.talent.model.dto.SkillsOnProofDTO; +import com.provedcode.talent.service.TalentSkillsService; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@Slf4j +@Validated +@AllArgsConstructor + +@RestController +@RequestMapping("/api/v4/talents") +public class TalentSkillsController { + TalentSkillsService talentSkillsService; + + @PostMapping("/{talent-id}/proofs/{proof-id}/skills") + void addSkillOnProof(@PathVariable("talent-id") long talentId, + @PathVariable("proof-id") long proofId, + @RequestBody @Valid ProofSkillsDTO skills, + Authentication authentication) { + talentSkillsService.addSkillsOnProof(talentId, proofId, skills, authentication); + } + + @GetMapping("/{talent-id}/proofs/{proof-id}/skills") + SkillsOnProofDTO getAllSkillsOnProof(@PathVariable("talent-id") long talentId, + @PathVariable("proof-id") long proofId, + Authentication authentication) { + return talentSkillsService.getAllSkillsOnProof(talentId, proofId, authentication); + } + @PreAuthorize("hasRole('TALENT')") + @DeleteMapping("/{talent-id}/proofs/{proof-id}/skills/{skill-id}") + void deleteSkillOnProof(@PathVariable("talent-id") long talentId, + @PathVariable("proof-id") long proofId, + @PathVariable("skill-id") long skillId, + Authentication authentication) { + talentSkillsService.deleteSkillOnProof(talentId, proofId, skillId, authentication); + } +} diff --git a/src/main/java/com/provedcode/talent/mapper/SkillMapper.java b/src/main/java/com/provedcode/talent/mapper/SkillMapper.java new file mode 100644 index 0000000..74c30b6 --- /dev/null +++ b/src/main/java/com/provedcode/talent/mapper/SkillMapper.java @@ -0,0 +1,12 @@ +package com.provedcode.talent.mapper; + +import com.provedcode.talent.model.dto.SkillDTO; +import com.provedcode.talent.model.entity.Skills; +import org.mapstruct.Mapper; +import org.mapstruct.MappingConstants; +import org.mapstruct.ReportingPolicy; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING) +public interface SkillMapper { + SkillDTO skillToSkillDTO(Skills skills); +} diff --git a/src/main/java/com/provedcode/talent/mapper/TalentMapper.java b/src/main/java/com/provedcode/talent/mapper/TalentMapper.java index 795ac61..336714e 100644 --- a/src/main/java/com/provedcode/talent/mapper/TalentMapper.java +++ b/src/main/java/com/provedcode/talent/mapper/TalentMapper.java @@ -14,10 +14,10 @@ public interface TalentMapper { @Mapping(target = "additionalInfo", expression = "java(talent.getTalentDescription() != null ? talent.getTalentDescription().getAdditionalInfo() : null)") @Mapping(target = "links", expression = "java(talent.getTalentLinks().stream().map(l -> l.getLink()).toList())") @Mapping(target = "contacts", expression = "java(talent.getTalentContacts().stream().map(c -> c.getContact()).toList())") - @Mapping(target = "talents", expression = "java(talent.getTalentTalents().stream().map(t -> t.getTalentName()).toList())") +// @Mapping(target = "talents", expression = "java(talent.getTalentTalents().stream().map(t -> t.getTalentName()).toList())") @Mapping(target = "attachedFiles", expression = "java(talent.getTalentAttachedFiles().stream().map(a -> a.getAttachedFile()).toList())") FullTalentDTO talentToFullTalentDTO(Talent talent); - @Mapping(target = "talents", expression = "java(talent.getTalentTalents().stream().map(t -> t.getTalentName()).toList())") +// @Mapping(target = "talents", expression = "java(talent.getTalentTalents().stream().map(t -> t.getTalentName()).toList())") ShortTalentDTO talentToShortTalentDTO(Talent talent); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/model/dto/ProofSkillsDTO.java b/src/main/java/com/provedcode/talent/model/dto/ProofSkillsDTO.java new file mode 100644 index 0000000..d65e05e --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/dto/ProofSkillsDTO.java @@ -0,0 +1,13 @@ +package com.provedcode.talent.model.dto; + +import jakarta.validation.constraints.NotEmpty; +import lombok.Builder; + +import java.util.List; + +@Builder +public record ProofSkillsDTO( + @NotEmpty + List skills +) { +} diff --git a/src/main/java/com/provedcode/talent/model/dto/SkillDTO.java b/src/main/java/com/provedcode/talent/model/dto/SkillDTO.java new file mode 100644 index 0000000..f93fe25 --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/dto/SkillDTO.java @@ -0,0 +1,7 @@ +package com.provedcode.talent.model.dto; + +public record SkillDTO( + Long id, + String skill +) { +} diff --git a/src/main/java/com/provedcode/talent/model/dto/SkillsOnProofDTO.java b/src/main/java/com/provedcode/talent/model/dto/SkillsOnProofDTO.java new file mode 100644 index 0000000..f70ff5e --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/dto/SkillsOnProofDTO.java @@ -0,0 +1,12 @@ +package com.provedcode.talent.model.dto; + +import com.provedcode.talent.model.entity.Skills; +import lombok.Builder; + +import java.util.Set; + +@Builder +public record SkillsOnProofDTO( + Set skills +) { +} diff --git a/src/main/java/com/provedcode/talent/model/entity/Skills.java b/src/main/java/com/provedcode/talent/model/entity/Skills.java new file mode 100644 index 0000000..2bc6d0f --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/entity/Skills.java @@ -0,0 +1,34 @@ +package com.provedcode.talent.model.entity; + +import jakarta.persistence.*; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.Hibernate; + +import java.util.Objects; + +@Getter +@Setter +@Entity +@Table(name = "skill") +public class Skills { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; + @Column(name = "skill", length = 30) + private String skill; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; + Skills skills = (Skills) o; + return getId() != null && Objects.equals(getId(), skills.getId()); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } +} \ No newline at end of file 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 7e06810..46ca5db 100644 --- a/src/main/java/com/provedcode/talent/model/entity/Talent.java +++ b/src/main/java/com/provedcode/talent/model/entity/Talent.java @@ -41,8 +41,8 @@ public class Talent { private TalentDescription talentDescription; @OneToMany(mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) private List talentLinks = new ArrayList<>(); - @OneToMany(mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) - private List talentTalents = new ArrayList<>(); +// @OneToMany(mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) +// private List talentTalents = new ArrayList<>(); @OneToMany(mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) private List talentContacts = new ArrayList<>(); @OneToMany(mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true) 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 0650310..549dbea 100644 --- a/src/main/java/com/provedcode/talent/model/entity/TalentProof.java +++ b/src/main/java/com/provedcode/talent/model/entity/TalentProof.java @@ -10,7 +10,9 @@ import org.hibernate.validator.constraints.URL; import java.time.LocalDateTime; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; @Accessors(chain = true) @NoArgsConstructor @@ -41,4 +43,9 @@ public class TalentProof { private LocalDateTime created; @OneToMany(fetch = FetchType.EAGER, mappedBy = "proof", cascade = CascadeType.ALL, orphanRemoval = true) private List kudos; + @ManyToMany + @JoinTable(name = "talent_skill", + joinColumns = @JoinColumn(name = "proof_id"), + inverseJoinColumns = @JoinColumn(name = "skill_id")) + private Set skills = new LinkedHashSet<>(); } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/model/entity/TalentSkills.java b/src/main/java/com/provedcode/talent/model/entity/TalentSkills.java new file mode 100644 index 0000000..f6a10cc --- /dev/null +++ b/src/main/java/com/provedcode/talent/model/entity/TalentSkills.java @@ -0,0 +1,25 @@ +//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_talents") +//public class TalentSkills { +// @Id +// @GeneratedValue(strategy = GenerationType.IDENTITY) +// @Column(name = "id", nullable = false) +// private Long id; +// @NotNull +// @ManyToOne +// @JoinColumn(name = "talent_id", updatable = false) +// private Talent talent; +// @Column(name = "talent_name") +// private String talentName; +//} \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/model/entity/TalentTalents.java b/src/main/java/com/provedcode/talent/model/entity/TalentTalents.java deleted file mode 100644 index 2c087b0..0000000 --- a/src/main/java/com/provedcode/talent/model/entity/TalentTalents.java +++ /dev/null @@ -1,25 +0,0 @@ -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_talents") -public class TalentTalents { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; - @NotNull - @ManyToOne - @JoinColumn(name = "talent_id", updatable = false) - private Talent talent; - @Column(name = "talent_name") - private String talentName; -} \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/model/request/EditTalent.java b/src/main/java/com/provedcode/talent/model/request/EditTalent.java index cc3dbc1..d8fac72 100644 --- a/src/main/java/com/provedcode/talent/model/request/EditTalent.java +++ b/src/main/java/com/provedcode/talent/model/request/EditTalent.java @@ -17,7 +17,7 @@ public record EditTalent( @JsonProperty("additional_info") String additionalInfo, String bio, - List talents, +// List talents, @UrlList List links, List contacts, diff --git a/src/main/java/com/provedcode/talent/repo/SkillsRepository.java b/src/main/java/com/provedcode/talent/repo/SkillsRepository.java new file mode 100644 index 0000000..384d489 --- /dev/null +++ b/src/main/java/com/provedcode/talent/repo/SkillsRepository.java @@ -0,0 +1,12 @@ +package com.provedcode.talent.repo; + +import com.provedcode.talent.model.entity.Skills; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface SkillsRepository extends JpaRepository { + @Query("select s from Skills s where upper(s.skill) like upper(concat('%', ?1, '%'))") + List findBySkillContainsIgnoreCase(String skill); +} \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/repo/TalentRepository.java b/src/main/java/com/provedcode/talent/repo/TalentRepository.java index e0359c3..b2bac22 100644 --- a/src/main/java/com/provedcode/talent/repo/TalentRepository.java +++ b/src/main/java/com/provedcode/talent/repo/TalentRepository.java @@ -1,11 +1,7 @@ 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 org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.transaction.annotation.Transactional; public interface TalentRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/service/SkillsService.java b/src/main/java/com/provedcode/talent/service/SkillsService.java new file mode 100644 index 0000000..9ae77c4 --- /dev/null +++ b/src/main/java/com/provedcode/talent/service/SkillsService.java @@ -0,0 +1,25 @@ +package com.provedcode.talent.service; + +import com.provedcode.talent.mapper.SkillMapper; +import com.provedcode.talent.model.dto.SkillDTO; +import com.provedcode.talent.repo.SkillsRepository; +import com.provedcode.talent.repo.TalentRepository; +import com.provedcode.user.repo.UserInfoRepository; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@AllArgsConstructor +public class SkillsService { + SkillsRepository skillsRepository; + TalentRepository talentRepository; + UserInfoRepository userInfoRepository; + SkillMapper skillMapper; + + public List getFilteredSkills(String filterBy) { + return skillsRepository.findBySkillContainsIgnoreCase(filterBy).stream() + .map(skillMapper::skillToSkillDTO).toList(); + } +} diff --git a/src/main/java/com/provedcode/talent/service/TalentProofService.java b/src/main/java/com/provedcode/talent/service/TalentProofService.java index 3880350..9c92069 100644 --- a/src/main/java/com/provedcode/talent/service/TalentProofService.java +++ b/src/main/java/com/provedcode/talent/service/TalentProofService.java @@ -11,6 +11,7 @@ import com.provedcode.talent.repo.TalentProofRepository; import com.provedcode.talent.repo.TalentRepository; import com.provedcode.talent.utill.ValidateTalentForCompliance; +import com.provedcode.user.model.Role; import com.provedcode.user.model.entity.UserInfo; import com.provedcode.user.repo.UserInfoRepository; import lombok.AllArgsConstructor; @@ -29,6 +30,7 @@ import java.net.URI; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Objects; import java.util.Optional; import static org.springframework.http.HttpStatus.FORBIDDEN; @@ -81,14 +83,15 @@ public FullProofDTO getTalentProofs(Long talentId, Integer page, Integer size, S talentId))); UserInfo userInfo = userInfoRepository.findByLogin(authentication.getName()) .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND)); - Page proofs; PageRequest pageRequest = PageRequest.of(page, size, Sort.Direction.valueOf(direction.toUpperCase()), sortProperties ); - if (!userInfo.getTalent().getId().equals(talentId)) { + Page proofs = talentProofRepository.findByTalentId(talentId, pageRequest); + if (authentication.getAuthorities().contains(Role.SPONSOR)) { + proofs = talentProofRepository.findByTalentIdAndStatus(talentId, ProofStatus.PUBLISHED, pageRequest); + } + if (userInfo.getTalent() != null && !userInfo.getTalent().getId().equals(talentId)) { proofs = talentProofRepository.findByTalentIdAndStatus(talentId, ProofStatus.PUBLISHED, pageRequest); - } else { - proofs = talentProofRepository.findByTalentId(talentId, pageRequest); } return FullProofDTO.builder() .id(talent.getId()) diff --git a/src/main/java/com/provedcode/talent/service/TalentService.java b/src/main/java/com/provedcode/talent/service/TalentService.java index 48a854d..fb35aa9 100644 --- a/src/main/java/com/provedcode/talent/service/TalentService.java +++ b/src/main/java/com/provedcode/talent/service/TalentService.java @@ -56,7 +56,7 @@ public Talent editTalent(long id, EditTalent editTalent, Authentication authenti Talent editableTalent = talent.get(); TalentDescription editableTalentDescription = editableTalent.getTalentDescription(); - List editableTalentTalents = editableTalent.getTalentTalents(); +// List editableTalentTalents = editableTalent.getTalentTalents(); List editableTalentLinks = editableTalent.getTalentLinks(); List editableTalentContacts = editableTalent.getTalentContacts(); List editableTalentAttachedFiles = editableTalent.getTalentAttachedFiles(); @@ -88,14 +88,14 @@ public Talent editTalent(long id, EditTalent editTalent, Authentication authenti } editableTalent.setTalentDescription(editableTalentDescription); } - if (editTalent.talents() != null) { - editableTalentTalents.clear(); - editableTalentTalents.addAll(editTalent.talents().stream().map(s -> TalentTalents.builder() - .talent(editableTalent) - .talentName(s) - .build()).toList()); - editableTalent.setTalentTalents(editableTalentTalents); - } +// if (editTalent.talents() != null) { +// editableTalentTalents.clear(); +// editableTalentTalents.addAll(editTalent.talents().stream().map(s -> TalentSkills.builder() +// .talent(editableTalent) +// .talentName(s) +// .build()).toList()); +// editableTalent.setTalentTalents(editableTalentTalents); +// } if (editTalent.links() != null) { editableTalentLinks.clear(); editableTalentLinks.addAll(editTalent.links().stream().map(s -> TalentLink.builder() @@ -144,8 +144,7 @@ public SessionInfoDTO deleteTalentById(long id, Authentication authentication) { private void checkEditTalentNull(EditTalent editTalent) { if (editTalent.firstName() == null && editTalent.lastName() == null && editTalent.image() == null && editTalent.specialization() == null && editTalent.additionalInfo() == null && editTalent.bio() == null && - editTalent.talents() == null && editTalent.links() == null && editTalent.contacts() == null && - editTalent.attachedFiles() == null) + editTalent.links() == null && editTalent.contacts() == null && editTalent.attachedFiles() == null) throw new ResponseStatusException(BAD_REQUEST, "you did not provide information to make changes"); } } \ No newline at end of file diff --git a/src/main/java/com/provedcode/talent/service/TalentSkillsService.java b/src/main/java/com/provedcode/talent/service/TalentSkillsService.java new file mode 100644 index 0000000..81841b0 --- /dev/null +++ b/src/main/java/com/provedcode/talent/service/TalentSkillsService.java @@ -0,0 +1,123 @@ +package com.provedcode.talent.service; + +import com.provedcode.talent.model.ProofStatus; +import com.provedcode.talent.model.dto.ProofSkillsDTO; +import com.provedcode.talent.model.dto.SkillsOnProofDTO; +import com.provedcode.talent.model.entity.Skills; +import com.provedcode.talent.model.entity.Talent; +import com.provedcode.talent.model.entity.TalentProof; +import com.provedcode.talent.repo.SkillsRepository; +import com.provedcode.talent.repo.TalentProofRepository; +import com.provedcode.talent.repo.TalentRepository; +import com.provedcode.user.model.entity.UserInfo; +import com.provedcode.user.repo.UserInfoRepository; +import lombok.AllArgsConstructor; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.server.ResponseStatusException; + +import java.util.HashSet; +import java.util.Set; +import java.util.function.BiConsumer; + +import static org.springframework.http.HttpStatus.*; + +@Transactional +@Service +@AllArgsConstructor +public class TalentSkillsService { + SkillsRepository skillsRepository; + TalentRepository talentRepository; + UserInfoRepository userInfoRepository; + TalentProofRepository talentProofRepository; + + static BiConsumer isValidUserEditTalent = (talentId, userInfo) -> { + if (!userInfo.getTalent().getId().equals(talentId)) { + throw new ResponseStatusException(CONFLICT, "you can`t change another talent"); + } + }; + + public void addSkillsOnProof(long talentId, long proofId, ProofSkillsDTO skills, Authentication authentication) { + if (!talentRepository.existsById(talentId)) { + throw new ResponseStatusException(NOT_FOUND, "talent with id = %s not found".formatted(talentId)); + } + UserInfo userInfo = userInfoRepository.findByLogin(authentication.getName()) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND)); + TalentProof talentProof = talentProofRepository.findById(proofId) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND, "proof with id = %s not found".formatted(proofId))); + if (!talentProof.getStatus().equals(ProofStatus.DRAFT)) { + throw new ResponseStatusException(CONFLICT, "proof status must be DRAFT"); + } + + isValidUserEditTalent.accept(talentId, userInfo); + skills.skills().forEach(skillId -> { + if (!skillsRepository.existsById(skillId)) + throw new ResponseStatusException(NOT_FOUND, "no such skill with id = " + skillId); + }); + + Set skillsSet = new HashSet<>(skillsRepository.findAllById(skills.skills())); + talentProof.getSkills().forEach(skill -> { + if (skillsSet.contains(skill)) + throw new ResponseStatusException(CONFLICT, + "skill with id = %s already on skill".formatted(skill.getId())); + }); + + talentProof.getSkills().addAll(skillsSet); + talentProofRepository.save(talentProof); + } + + @Transactional(readOnly = true) + public SkillsOnProofDTO getAllSkillsOnProof(long talentId, long proofId, Authentication authentication) { + TalentProof talentProof = talentProofRepository.findById(proofId) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND, + "proof with id = %s not found".formatted(proofId))); + Talent talent = talentRepository.findById(talentId) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND, + "talent with id = %s not found".formatted(talentId))); + if (!talent.getId().equals(talentProof.getTalent().getId())) { + throw new ResponseStatusException(BAD_REQUEST, + "talentId with id = %s and proofId with id = %s do not match".formatted(talentId, proofId)); + } + + if (talentProof.getStatus().equals(ProofStatus.PUBLISHED)) { + return SkillsOnProofDTO.builder().skills(talentProof.getSkills()).build(); + } else if (authentication != null) { + UserInfo userInfo = userInfoRepository.findByLogin(authentication.getName()) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND)); + if (userInfo.getTalent().getId().equals(talentProof.getTalent().getId())) { + return SkillsOnProofDTO.builder().skills(talentProof.getSkills()).build(); + } else { + throw new ResponseStatusException(FORBIDDEN, "you can't see proofs in DRAFT and HIDDEN status"); + } + } else { + throw new ResponseStatusException(FORBIDDEN, "you can't see proofs in DRAFT and HIDDEN status"); + } + } + + public void deleteSkillOnProof(long talentId, long proofId, long skillId, Authentication authentication) { + Talent talent = talentRepository.findById(talentId) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND, + "talent with id = %s not found".formatted(talentId))); + UserInfo userInfo = userInfoRepository.findByLogin(authentication.getName()) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND)); + TalentProof talentProof = talentProofRepository.findById(proofId) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND, "proof with id = %s not found".formatted(proofId))); + if (!talentProof.getStatus().equals(ProofStatus.DRAFT)) { + throw new ResponseStatusException(CONFLICT, "proof status must be DRAFT"); + } + if (!talent.getId().equals(talentProof.getTalent().getId())) { + throw new ResponseStatusException(BAD_REQUEST, + "talentId with id = %s and proofId with id = %s do not match".formatted(talentId, proofId)); + } + isValidUserEditTalent.accept(talentId, userInfo); + Skills skills = skillsRepository.findById(skillId) + .orElseThrow(() -> new ResponseStatusException(NOT_FOUND, + "skill with id = %s not found".formatted(skillId))); + if (!talentProof.getSkills().contains(skills)) { + throw new ResponseStatusException(NOT_FOUND, + "you dont have skill with id = %s on proof with id = %s".formatted(skillId, proofId)); + } + talentProof.getSkills().remove(skills); + } +} diff --git a/src/main/resources/db/changelog/changeset/V4/data-V4.1.sql b/src/main/resources/db/changelog/changeset/V4/data-V4.1.sql new file mode 100644 index 0000000..9261f0d --- /dev/null +++ b/src/main/resources/db/changelog/changeset/V4/data-V4.1.sql @@ -0,0 +1,19 @@ +--liquibase formatted sql +--changeset dennis:3 +-- Skill +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (1, 1); +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (1, 2); +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (1, 3); +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (1, 4); +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (4, 1); +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (5, 2); +INSERT INTO talent_skill (proof_id, skill_id) +VALUES (6, 3); + + diff --git a/src/main/resources/db/changelog/changeset/V4/data-V4.sql b/src/main/resources/db/changelog/changeset/V4/data-V4.sql new file mode 100644 index 0000000..4f08749 --- /dev/null +++ b/src/main/resources/db/changelog/changeset/V4/data-V4.sql @@ -0,0 +1,2076 @@ +--liquibase formatted sql +--changeset Ren:0 +-- Authority +insert into authority (id, authority) +values (1, 'TALENT'); +insert into authority (id, authority) +values (2, 'SPONSOR'); +-- Skill +insert into skill (id, skill) +values (1, 'Java Core'); +insert into skill (id, skill) +values (2, 'Spring Core'); +insert into skill (id, skill) +values (3, 'Spring boot'); +insert into skill (id, skill) +values (4, 'H2 Database'); +insert into skill (id, skill) +values (5, 'Spring Security'); +insert into skill (id, skill) +values (6, 'REST API'); +insert into skill (id, skill) +values (7, 'Git'); +insert into skill (id, skill) +values (8, 'Docker'); +insert into skill (id, skill) +values (9, 'Jira'); +insert into skill (id, skill) +values (10, 'JavaScript Core'); +insert into skill (id, skill) +values (11, 'React'); +insert into skill (id, skill) +values (12, 'Node.js'); +insert into skill (id, skill) +values (13, 'Angular'); +-- Talent +-- Serhii Soloviov +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) +values( + ( + select id + from talent + order by id desc + limit 1 + ), 'Hello! I was born in Ukraine. My profession is Java Back-end developer. Now I`m developing a Java backend using Spring Boot.', 'My cat`s name is Igor' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_contact (talent_id, contact) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'first_contact' + ); +insert into talent_contact (talent_id, contact) +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Here I wrote a program that transforms the written code into music', 'PUBLISHED', '2022-01-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-03-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'HIDDEN', '2021-06-08 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'SerhiiSoloviov@gmail.com', '$2a$10$EzYxG1DEUek/veK.HzP7B.ynSKE42VbLb4pvFd/v4OwGPNol6buEC' + ); +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 + ) + ); +-- Mykhailo Ordyntsev +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 + ), 'Hello! I was born in Ukraine. My profession is Java Back-end developer. Now I`m developing a Java backend using Spring Boot.', 'I very like anime' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'DRAFT', '2022-08-07 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'HIDDEN', '2022-04-08 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2022-09-02 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'MykhailoOrdyntsev@gmail.com', '$2a$10$XD60M86n1MDf3AMIixgnnOQq9JVYnnX/umlNFcre0GoC2XgSN/Cfq' + ); +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 + ) + ); +-- Denis Boyko +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 + ), 'Hello! I was born in Ukraine. My profession is Java Back-end developer. Now I`m developing a Java backend using Spring Boot.', 'I`m a student ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'DRAFT', '2022-02-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2021-09-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-04-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'DenisBoyko@gmail.com', '$2a$10$tLm27FGH8Sabz57eNkTwm.bSnhmJHINcqt7dNfZI0NfOwD2o/Drse' + ); +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 + ) + ); +-- Ihor Schurenko +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 + ), 'Hello! I was born in Ukraine. My profession is Java Back-end developer. Now I`m developing a Java backend using Spring Boot.', 'I will get married soon' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Here I describe my rest api project in java', 'PUBLISHED', '2021-08-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2022-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-05-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'IhorShchurenko@gmail.com', '$2a$10$X.d4hR.yRf3cK0Go20aTTukOI9u/Zu2cj5WU0iTcDihyhJ5vUHXkq' + ); +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 + ) + ); +-- Dmytro Uzun +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 + ), 'I am instructing a team that is currently writing my own biography for me.', 'He-he-he, hello everyone!' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://github.com/ProvedCode', 'My project where I am a team mentor', 'PUBLISHED', '2023-02-08 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2021-03-03 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-09-05 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'DmytroUzun@gmail.com', '$2a$10$J2Yuh10BWHy8XYk.T5rd2uOwk/h5EYG1eVXTAOkTkTdQcc5Qzd9.y' + ); +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 + ) + ); +-- Viktor Voloshko +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is dev-ops.', 'I like videogames!' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'HIDDEN', '2022-02-09 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2020-04-02 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-08-06 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'ViktorVoloshko@gmail.com', '$2a$10$eZX3hBvllxkmH.juZzN72uvFYtphkrxsj14K5BnHHKy4coRV9FMvq' + ); +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 + ) + ); +-- Olha Moiseienko +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is QA.', 'Glory to Ukraine' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to first proof', 'HIDDEN', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'My QA Jira project', 'PUBLISHED', '2022-09-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2021-01-09 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'OlhaMoiseienko@gmail.com', '$2a$10$lvvX7DZOwCS/Q7zSo.k.oeayTcKHh8rO1yBBkgIbU4VAC7abPfIa2' + ); +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 + ) + ); +-- Maxim Kiyashko +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is QA.', 'Glory to Ukraine' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'My custom Arduino OS', 'PUBLISHED', '2023-08-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-01-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'PUBLISHED', '2023-02-09 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'MaximKiyashko@gmail.com', '$2a$10$y.g9qHYUOPEkIL8xDc2h1.EdVAG5DYh6OKxf9CRb6s16oHHbr8Bny' + ); +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 + ) + ); +-- Nikolaiev Oleksii +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is QA.', 'Glory to Ukraine' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Link to my magnum opus:', 'PUBLISHED', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'HIDDEN', '2023-06-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'NikolaievOleksiio@gmail.com', '$2a$10$nDObO3nDlhWev29qCnzNuOszdg/.ANaMlTirDVWVyLMapYmtSSqza' + ); +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 + ) + ); +-- Artem Lytvynenko +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is QA.', 'Glory to Ukraine' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Here I wrote tasks for the project', 'PUBLISHED', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'HIDDEN', '2023-06-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'ArtemLytvynenko@gmail.com', '$2a$10$.M2fHh9NXbkbnrVHeT.lYeInA8K2khuMUL08iG4NuXs18KIeFBmwG' + ); +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 + ) + ); +-- Daniil Yevtukhov +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is JavaScript developer.', 'I have my own Instagram' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'My main project where I am making REACT application', 'PUBLISHED', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'HIDDEN', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'DaniilYevtukhov@gmail.com', '$2a$10$cDxp6U/YcObKMwZNgtEB5eZFLWXuwFU0lIUSPIkfPdvq9l8JUqGea' + ); +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 + ) + ); +-- Ruslan Morozov +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is JavaScript developer.', 'Glory to Ukraine' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Here my container for styles', 'PUBLISHED', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to second proof', 'DRAFT', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'RuslanMorozov@gmail.com', '$2a$10$Hfzp4b6r825g1ZqGzxmal..VNKvo7F4v4YFpBZZ036hmO.7UIWlaK' + ); +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 + ) + ); +-- Ihor Kopieichykov +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 + ), 'Hi all! I was born in Ukraine. I am a student. My profession is JavaScript developer.', 'Glory to Ukraine' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_link (talent_id, link) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +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 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_attached_file (talent_id, attached_file) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Here is my JavaScript library', 'PUBLISHED', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'Here is my main project in Angular', 'PUBLISHED', '2023-06-04 16:00:19' + ); +insert into talent_proofs (talent_id, link, text, status, created) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'text to third proof', 'DRAFT', '2023-06-04 16:00:19' + ); +insert into user_info (talent_id, login, password) +values ( + ( + select id + from talent + order by id desc + limit 1 + ), 'IhorKopieichykov@gmail.com', '$2a$10$D4KM50WemOahkFv1fkrPX.MvVESsE0TYWlkh5TypTE/q4nlv8ooyS' + ); +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 + ) + ); +-- Sponsor +-- Maksym Khudoliy +insert into sponsor (amount_kudos, first_name, last_name, image) +values ( + 888, + 'Maksym', + 'Khudoliy', + 'https://i.pinimg.com/564x/e1/08/49/e10849923a8b2e85a7adf494ebd063e6.jpg' + ); +insert into user_info (sponsor_id, login, password) +values ( + ( + select id + from sponsor + order by id desc + limit 1 + ), 'MaksymKhudoliy@gmail.com', '$2a$10$pDrAuawhi3ADZpVDDr7C6eAcaQwDr5oQ9GdZUUZHSsqyM/vVkpruy' + ); +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 = 2 + ) + ); +-- Oleksandr Butrym +insert into sponsor (amount_kudos, first_name, last_name, image) +values ( + 888, + 'Oleksandr', + 'Butrym', + 'https://i.pinimg.com/564x/c2/41/31/c24131fe00218467721ba5bacdf0a256.jpg' + ); +insert into user_info (sponsor_id, login, password) +values ( + ( + select id + from sponsor + order by id desc + limit 1 + ), 'OleksandrButrym@gmail.com', '$2a$10$R0o8os0t86qyBvg0bO/a6ukuy9VesLapxIkZFLjNupWjvr5Hdjyge' + ); +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 = 2 + ) + ); +-- Olha Shutylieva +insert into sponsor (amount_kudos, first_name, last_name, image) +values ( + 888, + 'Olha', + 'Shutylieva', + 'https://i.pinimg.com/564x/2a/0c/08/2a0c08c421e253ca895c3fdc8c9e08d9.jpg' + ); +insert into user_info (sponsor_id, login, password) +values ( + ( + select id + from sponsor + order by id desc + limit 1 + ), 'OlhaShutylieva@gmail.com', '$2a$10$UzwVTVR7E2BW.5hA4XWgy.g0XcM.UbIMBoY1cDnYNPQDhCXEa7eGm' + ); +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 = 2 + ) + ); +-- Vladyslav Khrychov +insert into sponsor (amount_kudos, first_name, last_name, image) +values ( + 888, + 'Vladyslav', + 'Khrychov', + 'https://i.pinimg.com/564x/e1/11/2f/e1112f0b7b63644dc3e313084936dedb.jpg' + ); +insert into user_info (sponsor_id, login, password) +values ( + ( + select id + from sponsor + order by id desc + limit 1 + ), 'VladyslavKhrychov@gmail.com', '$2a$10$o2va23ZPVVSptyCaSBO/oubpML4xEPZo9Ie0ASt154zNVSKdFrN02' + ); +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 = 2 + ) + ); +-- Kudos +insert into kudos (amount, sponsor_id, proof_id) +values (100, 1, 1); +insert into kudos (amount, sponsor_id, proof_id) +values (200, 2, 1); +insert into kudos (amount, sponsor_id, proof_id) +values (200, 3, 1); +insert into kudos (amount, sponsor_id, proof_id) +values (300, 4, 1); \ No newline at end of file diff --git a/src/main/resources/db/changelog/changeset/V4/drop-V4.sql b/src/main/resources/db/changelog/changeset/V4/drop-V4.sql new file mode 100644 index 0000000..091f48d --- /dev/null +++ b/src/main/resources/db/changelog/changeset/V4/drop-V4.sql @@ -0,0 +1,18 @@ +--liquibase formatted sql +--changeset Ren:0 +-- Talent +drop table if exists talent cascade; +drop table if exists talent_attached_file cascade; +drop table if exists talent_contact cascade; +drop table if exists talent_description cascade; +drop table if exists talent_link cascade; +drop table if exists talent_proofs cascade; +drop table if exists talent_skill cascade; +drop table if exists skill cascade; +-- User +drop table if exists authority cascade; +drop table if exists user_authorities cascade; +drop table if exists user_info cascade; +-- Sponsor +drop table if exists sponsor cascade; +drop table if exists kudos cascade; \ No newline at end of file diff --git a/src/main/resources/db/changelog/changeset/V4/schema-V4.sql b/src/main/resources/db/changelog/changeset/V4/schema-V4.sql new file mode 100644 index 0000000..b49be00 --- /dev/null +++ b/src/main/resources/db/changelog/changeset/V4/schema-V4.sql @@ -0,0 +1,120 @@ +-- liquibase formatted sql +-- changeset Ren:0 +-- tables for sprint 4.1 +-- Talent +CREATE TABLE talent ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + first_name VARCHAR(20), + last_name VARCHAR(20), + specialization VARCHAR(30), + image VARCHAR(1000), + image_name VARCHAR(100), + CONSTRAINT pk_talent PRIMARY KEY (id) +); +CREATE TABLE talent_attached_file ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + attached_file VARCHAR(100), + CONSTRAINT pk_talent_attached_file PRIMARY KEY (id) +); +CREATE TABLE talent_contact ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + contact VARCHAR(255), + CONSTRAINT pk_talent_contact PRIMARY KEY (id) +); +CREATE TABLE talent_description ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + bio VARCHAR(2000), + addition_info VARCHAR(500), + CONSTRAINT pk_talent_description PRIMARY KEY (id) +); +CREATE TABLE talent_link ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + link VARCHAR(500), + CONSTRAINT pk_talent_link PRIMARY KEY (id) +); +CREATE TABLE talent_proofs ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT NOT NULL, + link VARCHAR(100), + text VARCHAR(1000), + status VARCHAR(20) NOT NULL, + created TIMESTAMP, + CONSTRAINT pk_talent_proofs PRIMARY KEY (id) +); +CREATE TABLE talent_skill ( + proof_id BIGINT NOT NULL, + skill_id BIGINT NOT NULL, + CONSTRAINT pk_talent_skill PRIMARY KEY (proof_id, skill_id) +); +CREATE TABLE skill ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + skill VARCHAR(30), + CONSTRAINT pk_skill PRIMARY KEY (id) +); +-- User +CREATE TABLE user_info ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + talent_id BIGINT, + sponsor_id BIGINT, + 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) +); +CREATE TABLE user_authorities ( + authority_id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + user_id BIGINT NOT NULL, + CONSTRAINT pk_user_authorities PRIMARY KEY (authority_id, user_id) +); +-- Sponsor +CREATE TABLE sponsor ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + first_name VARCHAR(20), + last_name VARCHAR(20), + image VARCHAR(1000), + image_name VARCHAR(100), + amount_kudos BIGINT, + CONSTRAINT pk_sponsor PRIMARY KEY (id) +); +CREATE TABLE kudos ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + sponsor_id BIGINT, + proof_id BIGINT, + amount BIGINT, + CONSTRAINT pk_kudos PRIMARY KEY (id) +); +-- Foreign keys +ALTER TABLE talent_attached_file +ADD CONSTRAINT FK_TALENT_ATTACHED_FILE_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE talent_contact +ADD CONSTRAINT FK_TALENT_CONTACT_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE talent_description +ADD CONSTRAINT FK_TALENT_DESCRIPTION_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE talent_link +ADD CONSTRAINT FK_TALENT_LINK_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE talent_proofs +ADD CONSTRAINT FK_TALENT_PROOFS_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); +ALTER TABLE user_info +ADD CONSTRAINT FK_USER_INFO_ON_TALENT 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_authorities +ADD CONSTRAINT FK_useaut_on_user_info FOREIGN KEY (user_id) REFERENCES user_info (id); +ALTER TABLE kudos +ADD CONSTRAINT FK_KUDOS_ON_PROOF FOREIGN KEY (proof_id) REFERENCES talent_proofs (id); +ALTER TABLE kudos +ADD CONSTRAINT FK_KUDOS_ON_SPONSOR FOREIGN KEY (sponsor_id) REFERENCES sponsor (id); +ALTER TABLE talent_skill +ADD CONSTRAINT FK_TALENT_SKILL_ON_TALENT_PROOF FOREIGN KEY (proof_id) REFERENCES talent_proofs (id); +ALTER TABLE talent_skill +ADD CONSTRAINT FK_TALENT_SKILL_ON_SKILL FOREIGN KEY (skill_id) REFERENCES skill (id); +-- Indexes +CREATE UNIQUE INDEX idx_login ON user_info (login) \ No newline at end of file diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index 4a6438c..102ca3c 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -1,9 +1,13 @@ databaseChangeLog: - - include: - file: db/changelog/changeset/V1/drop-V1.sql - - include: - file: db/changelog/changeset/V2/drop-V2.sql - - include: - file: db/changelog/changeset/V2/schema-V2.sql - - include: - file: db/changelog/changeset/V2/data-V2.sql \ No newline at end of file + - include: + file: db/changelog/changeset/V1/drop-V1.sql + - include: + file: db/changelog/changeset/V2/drop-V2.sql + - include: + file: db/changelog/changeset/V4/drop-V4.sql + - include: + file: db/changelog/changeset/V4/schema-V4.sql + - include: + file: db/changelog/changeset/V4/data-V4.sql + - include: + file: db/changelog/changeset/V4/data-V4.1.sql