diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ProfessionalProfileController.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ProfessionalProfileController.java new file mode 100644 index 00000000..4ab71916 --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ProfessionalProfileController.java @@ -0,0 +1,35 @@ +package com.hydraulic.applyforme.controller; + +import com.hydraulic.applyforme.model.domain.ProfessionalProfile; +import com.hydraulic.applyforme.model.dto.professionalProfile.ProfessionalProfileDto; + +import com.hydraulic.applyforme.service.ProfessionalProfileService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping( + value = "profile", + produces = {MediaType.APPLICATION_JSON_VALUE}, + consumes = {MediaType.APPLICATION_JSON_VALUE} +) + +public class ProfessionalProfileController { + + private final ProfessionalProfileService service; + + public ProfessionalProfileController(ProfessionalProfileService service){ + this.service = service; + } + + @PostMapping("/add-professional-profile") + public ProfessionalProfile saveProfile(@Validated @RequestBody ProfessionalProfileDto professionalProfileDto){ + return service.createProfessionalProfile(professionalProfileDto); + } +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/country/CountryDto.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/country/CountryDto.java index 20acf011..3eb534c3 100644 --- a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/country/CountryDto.java +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/country/CountryDto.java @@ -17,4 +17,6 @@ public class CountryDto { @NotNull(message = "{country.abbreviation.notNull}") @Size(min = 3, max = 10, message = "{country.abbreviation.size}") private String abbreviation; + + //abbreviationName } diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/professionalProfile/ProfessionalProfileDto.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/professionalProfile/ProfessionalProfileDto.java new file mode 100644 index 00000000..5c781606 --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/dto/professionalProfile/ProfessionalProfileDto.java @@ -0,0 +1,49 @@ +package com.hydraulic.applyforme.model.dto.professionalProfile; + +import com.hydraulic.applyforme.model.enums.EmploymentType; +import com.hydraulic.applyforme.model.enums.JobLocationType; +import com.hydraulic.applyforme.model.enums.JobSeniority; +import lombok.*; + +import javax.validation.constraints.NotNull; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class ProfessionalProfileDto { + + @NotNull(message = "Profile title cannot be null") + private String profileTitle; + + @NotNull(message = "Main profile title cannot be null") + private Boolean mainProfile; + + private String passportLink; + + private String resumeLink; + + private String cover_letter; + + private String salaryRange; + + private EmploymentType employmentType; + + private String jobLocation; + + private JobLocationType preferredJobLocationType; + + private JobSeniority jobSeniority; + + private String desiredJobTitle; + + private String industry; + + private Integer yearsOfExperience; + + private String otherSkills; + + private String otherComment; + + private String includedKeywords; +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/exception/InvalidOldPasswordException.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/exception/InvalidOldPasswordException.java new file mode 100644 index 00000000..2817ed8f --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/model/exception/InvalidOldPasswordException.java @@ -0,0 +1,21 @@ +package com.hydraulic.applyforme.model.exception; + +public class InvalidOldPasswordException extends RuntimeException{ + private static final long serialVersionUID = 5861310537366287163L; + + public InvalidOldPasswordException() { + super(); + } + + public InvalidOldPasswordException(final String message, final Throwable cause) { + super(message, cause); + } + + public InvalidOldPasswordException(final String message) { + super(message); + } + + public InvalidOldPasswordException(final Throwable cause) { + super(cause); + } +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/ProfessionalRepository.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/ProfessionalRepository.java new file mode 100644 index 00000000..cbe64523 --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/ProfessionalRepository.java @@ -0,0 +1,7 @@ +package com.hydraulic.applyforme.repository; + +import com.hydraulic.applyforme.model.domain.Professional; + +public interface ProfessionalRepository { + Professional getProfessionalByMemberId(Long id); +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/impl/ProfessionalRepositoryImpl.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/impl/ProfessionalRepositoryImpl.java new file mode 100644 index 00000000..8aa89260 --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/impl/ProfessionalRepositoryImpl.java @@ -0,0 +1,21 @@ +package com.hydraulic.applyforme.repository.impl; + +import com.hydraulic.applyforme.model.domain.Professional; +import com.hydraulic.applyforme.repository.ProfessionalRepository; +import org.springframework.stereotype.Repository; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +@Repository +public class ProfessionalRepositoryImpl implements ProfessionalRepository { + + @PersistenceContext + private EntityManager entityManager; + + + @Override + public Professional getProfessionalByMemberId(Long id) { + return entityManager.find(Professional.class, id); + } +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/ProfessionalProfileJpaRepository.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/ProfessionalProfileJpaRepository.java new file mode 100644 index 00000000..ba9a1b50 --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/ProfessionalProfileJpaRepository.java @@ -0,0 +1,8 @@ +package com.hydraulic.applyforme.repository.jpa; + +import com.hydraulic.applyforme.model.domain.ProfessionalProfile; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ProfessionalProfileJpaRepository extends JpaRepository { + +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/RoleJpaRepository.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/RoleJpaRepository.java index bb8abdb6..cace7745 100644 --- a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/RoleJpaRepository.java +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/repository/jpa/RoleJpaRepository.java @@ -10,4 +10,4 @@ public interface RoleJpaRepository extends JpaRepository { Optional findByTitleAndCode(String title, String code); Optional findByCode(String code); -} +} \ No newline at end of file diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ProfessionalProfileService.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ProfessionalProfileService.java new file mode 100644 index 00000000..89b05662 --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ProfessionalProfileService.java @@ -0,0 +1,9 @@ +package com.hydraulic.applyforme.service; + +import com.hydraulic.applyforme.model.domain.ProfessionalProfile; +import com.hydraulic.applyforme.model.dto.professionalProfile.ProfessionalProfileDto; + +public interface ProfessionalProfileService { + + ProfessionalProfile createProfessionalProfile(ProfessionalProfileDto body); +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ProfessionalService.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ProfessionalService.java new file mode 100644 index 00000000..8f2aa34d --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ProfessionalService.java @@ -0,0 +1,8 @@ +package com.hydraulic.applyforme.service; + +import com.hydraulic.applyforme.model.domain.Professional; + +public interface ProfessionalService { + + Professional findProfessionalByMemberId(Long id); +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ProfessionalProfileServiceImpl.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ProfessionalProfileServiceImpl.java new file mode 100644 index 00000000..c63b06ce --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ProfessionalProfileServiceImpl.java @@ -0,0 +1,44 @@ +package com.hydraulic.applyforme.service.impl; + +import com.hydraulic.applyforme.model.domain.Professional; +import com.hydraulic.applyforme.model.domain.ProfessionalProfile; +import com.hydraulic.applyforme.model.dto.professionalProfile.ProfessionalProfileDto; +import com.hydraulic.applyforme.model.enums.EmploymentType; +import com.hydraulic.applyforme.repository.ProfessionalRepository; +import com.hydraulic.applyforme.repository.jpa.MemberJpaRepository; +import com.hydraulic.applyforme.repository.jpa.ProfessionalProfileJpaRepository; +import com.hydraulic.applyforme.service.ProfessionalProfileService; +import lombok.extern.slf4j.Slf4j; +import org.modelmapper.ModelMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; + +@Slf4j +@Service +public class ProfessionalProfileServiceImpl implements ProfessionalProfileService { + + MemberJpaRepository memberJpaRepository; + + @Autowired + private ModelMapper modelMapper; + + @Autowired + private ProfessionalRepository professionalRepository; + + ProfessionalProfile professionalProfile; + ProfessionalProfileJpaRepository professionalProfileJpaRepository; + + + @Override + @Transactional + public ProfessionalProfile createProfessionalProfile(ProfessionalProfileDto body) { + + professionalProfile = modelMapper.map(body, ProfessionalProfile.class); //model maps everything to entity except id + //need to find a way to map professional_id in Professional entity to ProfessionalProfile professional_id + + return professionalProfileJpaRepository.save(professionalProfile); + + } +} diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ProfessionalServiceImpl.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ProfessionalServiceImpl.java new file mode 100644 index 00000000..8864588f --- /dev/null +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ProfessionalServiceImpl.java @@ -0,0 +1,26 @@ +package com.hydraulic.applyforme.service.impl; + +import com.hydraulic.applyforme.model.domain.Professional; +import com.hydraulic.applyforme.repository.ProfessionalRepository; +import com.hydraulic.applyforme.service.ProfessionalService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class ProfessionalServiceImpl implements ProfessionalService { + + private final ProfessionalRepository repository; + + + public ProfessionalServiceImpl(ProfessionalRepository repository) { + this.repository = repository; + } + + @Override + //use Professional returned from repo to set professional + public Professional findProfessionalByMemberId(Long id) { + Professional professional = repository.getProfessionalByMemberId(id); + return professional; + } +} diff --git a/Apply-For-Me-Api/src/main/resources/ddm/queries.sql b/Apply-For-Me-Api/src/main/resources/ddm/queries.sql index 746db38a..cb867311 100644 --- a/Apply-For-Me-Api/src/main/resources/ddm/queries.sql +++ b/Apply-For-Me-Api/src/main/resources/ddm/queries.sql @@ -1,4 +1,4 @@ -INSERT INTO `professional` (linkedin_link, facebook_link, twitter_link, instagram_link, other_link_1, other_link_2, other_link_3, hobbies); +# INSERT INTO `professional` (linkedin_link, facebook_link, twitter_link, instagram_link, other_link_1, other_link_2, other_link_3, hobbies); INSERT INTO `professional_profile` (profile_title, passport_link, resume_link, cover_letter, employment_type, salary_range, job_location, preferred_job_location_type,