Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/com/provedcode/config/InitConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public void run(String... args) throws Exception {
// TODO: Method to change passwords for already created users from data.sql
userInfoRepository.saveAll(
userInfoRepository.findAll().stream()
.map(i -> {
i.setPassword(passwordEncoder.encode(i.getPassword()));
return i;
}).toList());
.map(i -> {
i.setPassword(passwordEncoder.encode(i.getPassword()));
return i;
}).toList());
}
}
}
8 changes: 1 addition & 7 deletions src/main/java/com/provedcode/config/PageProperties.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package com.provedcode.config;

import jakarta.annotation.PostConstruct;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

@Validated
Expand All @@ -23,4 +17,4 @@ public record PageProperties(
void print() {
log.info("page-props = {} ", this);
}
}
}
7 changes: 1 addition & 6 deletions src/main/java/com/provedcode/config/PropsConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
package com.provedcode.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;


public class PropsConfig {
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/provedcode/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ JwtEncoder jwtEncoder(KeyPair keyPair) {
var jwkSet = new ImmutableJWKSet<>(new JWKSet(jwk));
return new NimbusJwtEncoder(jwkSet);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public class TalentExceptionHandler {
private ResponseEntity<?> responseStatusExceptionHandler(ResponseStatusException exception) {
return ResponseEntity.status(exception.getStatusCode()).body(exception.getBody());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ FullTalentDTO editTalent(@PathVariable("talent-id") long id,
SessionInfoDTO deleteTalent(@PathVariable("id") long id, Authentication authentication) {
return talentService.deleteTalentById(id, authentication);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.provedcode.talent.model.dto.ProofDTO;
import com.provedcode.talent.service.TalentProofService;
import com.provedcode.user.model.dto.SessionInfoDTO;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
Expand All @@ -29,37 +30,47 @@ Page<ProofDTO> getAllProofs(@RequestParam(value = "page") Optional<Integer> page
return talentProofService.getAllProofsPage(page, size, orderBy).map(talentProofMapper::toProofDTO);
}

@GetMapping("/proofs/{proof-id}")
@PreAuthorize("hasRole('TALENT')")
@DeleteMapping("/{talent-id}/proofs/{proof-id}")
SessionInfoDTO deleteProof(@PathVariable(value = "talent-id") long talentId,
@PathVariable(value = "proof-id") long proofId,
Authentication authentication) {
return talentProofService.deleteProofById(talentId, proofId, authentication);
ProofDTO getTalentProof(@PathVariable(value = "proof-id") long proofId,
Authentication authentication) {
return talentProofMapper.toProofDTO(talentProofService.getTalentProof(proofId, authentication));
}

@GetMapping("/{talent-id}/proofs")
@PreAuthorize("hasRole('TALENT')")
FullProofDTO getTalentInformationWithProofs(Authentication authentication,
@PathVariable("talent-id") Long talentId,
@RequestParam(value = "page") Optional<Integer> page,
@RequestParam(value = "size") Optional<Integer> size,
@RequestParam(value = "order-by") Optional<String> orderBy,
@RequestParam(value = "sort-by", defaultValue = "created") String... sortBy) {
return talentProofService.getTalentProofs(talentId, page, size, orderBy, authentication, sortBy);
}

@PostMapping("/{talent-id}/proofs")
@PreAuthorize("hasRole('TALENT')")
ResponseEntity<?> addProof(@PathVariable(value = "talent-id") long talentId,
@RequestBody AddProofDTO addProofDTO,
Authentication authentication) {
return talentProofService.addProof(addProofDTO, talentId, authentication);
}

@GetMapping("/{talent-id}/proofs")
@PatchMapping("/{talent-id}/proofs/{proof-id}")
@PreAuthorize("hasRole('TALENT')")
FullProofDTO getTalentInformationWithProofs(Authentication authentication,
@PathVariable("talent-id") Long talentId,
@RequestParam(value = "page") Optional<Integer> page,
@RequestParam(value = "size") Optional<Integer> size,
@RequestParam(value = "direction") Optional<String> direction,
@RequestParam(value = "sort", defaultValue = "created") String... sort) {
return talentProofService.getTalentProofs(talentId, page, size, direction, authentication, sort);
ProofDTO editProof(Authentication authentication,
@PathVariable("talent-id") long talentId,
@PathVariable("proof-id") long proofId,
@RequestBody @Valid ProofDTO proof) {
return talentProofMapper.toProofDTO(
talentProofService.editTalentProof(talentId, proofId, proof, authentication));
}

@DeleteMapping("/{talent-id}/proofs/{proof-id}")
@PreAuthorize("hasRole('TALENT')")
@GetMapping("/proofs/{proof-id}")
ProofDTO getTalentProof(@PathVariable(value = "proof-id") long proofId,
Authentication authentication) {
return talentProofService.getTalentProof(proofId, authentication);
SessionInfoDTO deleteProof(@PathVariable(value = "talent-id") long talentId,
@PathVariable(value = "proof-id") long proofId,
Authentication authentication) {
return talentProofService.deleteProofById(talentId, proofId, authentication);
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/provedcode/talent/mapper/TalentMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.provedcode.talent.model.dto.ShortTalentDTO;
import com.provedcode.talent.model.entity.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingConstants;
import org.mapstruct.ReportingPolicy;

Expand All @@ -28,5 +29,6 @@ default FullTalentDTO talentToFullTalentDTO(Talent talent) {
.build();
}

@Mapping(target = "talents", expression = "java(talent.getTalentTalents().stream().map(t->t.getTalentName()).toList())")
ShortTalentDTO talentToShortTalentDTO(Talent talent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

@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);
Expand Down

This file was deleted.

This file was deleted.

5 changes: 5 additions & 0 deletions src/main/java/com/provedcode/talent/model/dto/ProofDTO.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.provedcode.talent.model.dto;

import com.provedcode.talent.model.ProofStatus;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;

import org.hibernate.validator.constraints.URL;

@Builder
public record ProofDTO(
long id,
@URL
String link,
String text,
@NotNull
ProofStatus status,
String created
) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/provedcode/talent/model/entity/Talent.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import org.hibernate.validator.constraints.URL;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

@Builder
@Accessors(chain = true)
Expand Down Expand Up @@ -44,4 +46,6 @@ public class Talent {
private List<TalentContact> talentContacts = new ArrayList<>();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TalentAttachedFile> talentAttachedFiles = new ArrayList<>();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "talent", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TalentProof> talentProofs = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.URL;

import java.time.LocalDateTime;

@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface TalentProofRepository extends JpaRepository<TalentProof, Long> {
Page<TalentProof> findByTalentIdAndStatus(Long talentId, ProofStatus status, Pageable pageable);
Page<TalentProof> findByTalentId(Long talentId, Pageable pageable);

List<TalentProof> deleteByTalentId(Long talentId);

Page<TalentProof> findByStatus(ProofStatus status, Pageable pageable);
}
Loading