Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/BE-37 applicants job submission #47

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.addPathPrefix(env.getProperty("api-base-path"), HandlerTypePredicate.forAnnotation(RestController.class));
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*").allowedMethods("GET", "POST", "PUT", "DELETE").allowedHeaders("*");
}

@Bean
public JpaTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@RequestMapping(
value = "apply",
produces = { MediaType.APPLICATION_JSON_VALUE },
consumes = {MediaType.APPLICATION_JSON_VALUE }
consumes = { MediaType.APPLICATION_JSON_VALUE }
)
public class ApplyForMeController {

Expand All @@ -24,8 +24,8 @@ public ApplyForMeController(ApplyForMeService service) {
}

@GetMapping("/entries")
public List<ApplyForMe> findAll() {
return service.findAll();
public List<ApplyForMe> findAll(@RequestParam(required = false, defaultValue = "1" , name = "page") Integer pageNumber) {
return service.findAll(pageNumber);
}

@GetMapping("/detail/{id}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.hydraulic.applyforme.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hydraulic.applyforme.service.ApplyForMeService;
import com.hydraulic.applyforme.service.JobSubmissionService;

@RestController
@RequestMapping(
value = "apply",
produces = { MediaType.APPLICATION_JSON_VALUE },
consumes = { MediaType.APPLICATION_JSON_VALUE }
)
public class JobSubmissionController {

private JobSubmissionService service;

public JobSubmissionController(JobSubmissionService service) {
this.service = service;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,39 @@


import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.Date;


@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name ="apply_for_me")
public class ApplyForMe {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column
private String title;

@Column
private String version;

@CreationTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_on", updatable = false, nullable = false)
private Date createdOn;

@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_on", nullable = false)
private Date updatedOn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class MemberSecretCode {
@Column(name ="sign_up_verification_code")
private String signUpVerificationCode;

@OneToOne
@JoinColumn(name = "member_email_fk", referencedColumnName ="email_address")
private Member member;
@Column(name = "email_address")
private String emailAddress;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.hydraulic.applyforme.model.exception;

public class ApplyForMeDuplicateEntityException extends ApplyForMeException {
private static final long serialVersionUID = 1L;
public static final String ENTITY_NAME = "Apply For Me";

@Override
public String getMessage() {
return String.format("%s entry already exists in record.", ENTITY_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface ApplyForMeRepository {

List<ApplyForMe> getAll();
List<ApplyForMe> getAll(Integer pageOffset);

ApplyForMe getOne(Long id);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.hydraulic.applyforme.repository;

import java.util.List;

import com.hydraulic.applyforme.model.domain.Submission;

public interface JobSubmissionRepository {

List<Submission> getAll(Integer pageOffset);
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,61 @@
package com.hydraulic.applyforme.repository.impl;

import com.hydraulic.applyforme.model.domain.ApplyForMe;
import com.hydraulic.applyforme.model.exception.ApplyForMeDuplicateEntityException;
import com.hydraulic.applyforme.repository.ApplyForMeRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import javax.persistence.*;
import java.util.List;
@Slf4j
@Repository
public class ApplyForMeRepositoryImpl implements ApplyForMeRepository {

private static final int DEFAULT_PAGE_SIZE = 11;
@PersistenceContext
private EntityManager entityManager;

@Override
public List<ApplyForMe> getAll() {
return null;
public List<ApplyForMe> getAll(Integer pageOffset) {
String queryText = "select afm from ApplyForMe afm order by afm.updatedOn desc";
TypedQuery<ApplyForMe> applyForMeQuery = entityManager.createQuery(queryText, ApplyForMe.class);

applyForMeQuery.setFirstResult((pageOffset - 1) * DEFAULT_PAGE_SIZE);
applyForMeQuery.setMaxResults(DEFAULT_PAGE_SIZE);
return applyForMeQuery.getResultList();
}

@Override
public ApplyForMe getOne(Long id) {
return null;
return entityManager.find(ApplyForMe.class, id);
}

@Override
public ApplyForMe saveOne(ApplyForMe body) {
return null;
try {
entityManager.persist(body);
return body;
}
catch (EntityExistsException ex) {
throw new ApplyForMeDuplicateEntityException();
}
}

@Override
public ApplyForMe updateOne(ApplyForMe body) {
return null;
return entityManager.merge(body);
}

@Override
public boolean deleteOne(ApplyForMe body) {
return false;
try {
ApplyForMe applyForMe = entityManager.getReference(ApplyForMe.class, body.getId());
entityManager.remove(applyForMe);
return true;
}
catch (EntityNotFoundException ex) {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hydraulic.applyforme.repository.impl;

import java.util.List;

import com.hydraulic.applyforme.model.domain.Submission;
import com.hydraulic.applyforme.repository.JobSubmissionRepository;

public class JobSubmissionRepositoryImpl implements JobSubmissionRepository {


@Override
public List<Submission> getAll(Integer pageOffset) {

return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.hydraulic.applyforme.repository.jpa;

import com.hydraulic.applyforme.model.domain.Member;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MemberJaRepository extends JpaRepository<Member, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public interface ApplyForMeService {

List<ApplyForMe> findAll();
List<ApplyForMe> findAll(Integer pageOffset);

ApplyForMe findOne(Long id);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.hydraulic.applyforme.service;

import java.util.List;

import com.hydraulic.applyforme.model.domain.Submission;

public interface JobSubmissionService {

List<Submission> getAllSubmissions(Integer pageOffset);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public ApplyForMeServiceImpl(ApplyForMeRepository repository) {
}

@Override
public List<ApplyForMe> findAll() {
return repository.getAll();
public List<ApplyForMe> findAll(Integer pageOffset) {
return repository.getAll(pageOffset);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.hydraulic.applyforme.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.hydraulic.applyforme.model.domain.Submission;
import com.hydraulic.applyforme.repository.JobSubmissionRepository;
import com.hydraulic.applyforme.service.JobSubmissionService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class JobSubmissionServiceImpl implements JobSubmissionService{

private final JobSubmissionRepository jobSubmissionRepository;
public JobSubmissionServiceImpl(JobSubmissionRepository jobSubmissionRepository) {
this.jobSubmissionRepository = jobSubmissionRepository;
}

@Override
public List<Submission> getAllSubmissions(Integer pageOffset) {

return null;
}












}
11 changes: 8 additions & 3 deletions Apply-For-Me-Api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ spring.main.allow-bean-definition-overriding: true


## DataSource properties
#spring.datasource.url=jdbc:mysql://localhost:3306/applyforme
#spring.datasource.username=alamu
#spring.datasource.password=78789898
#spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

## DataSource properties (local)
spring.datasource.url=jdbc:mysql://localhost:3306/applyforme
spring.datasource.username=alamu
spring.datasource.password=78789898
spring.datasource.username=root
spring.datasource.password=1234
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect


## HikariCP configuration
spring.datasource.hikari.minimumIdle=0
spring.datasource.hikari.maximum-pool-size=40
Expand Down