-
Notifications
You must be signed in to change notification settings - Fork 7
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
request service and endpoints #14
Open
agyen
wants to merge
21
commits into
master
Choose a base branch
from
request-service
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8265989
request service and endpoints
c465e75
getting specific colomn from requests table
c140556
getting specific columns
5cabb13
employee db extended with docker files
bill-n 515aae1
before adding request files
bill-n 2f320f8
added requestController
bill-n de71051
added email
bill-n c844e7f
added gmail service
bill-n 3ccd12b
added RequestTo
bill-n 2c771ca
added docker-compose.yml
bill-n 195724d
added files on dockerfile
bill-n 5eca1cc
added files into init.sh
bill-n 5f5091c
added holiday sql files
bill-n ec6fa0f
mofified
bill-n 8afdc29
Merge branch 'employeeUpdate' of https://github.com/Kwakyesamuelosei/…
bill-n b34ce9e
merged
bill-n 035ce69
modified api operation
bill-n e6d4a8b
modified file
bill-n 035447f
oidc
67a6643
requests services
97e1e35
gmail service for gsuite domain
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/main/java/io/turntabl/employementprofilingsystem/Controllers/RequestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.turntabl.employementprofilingsystem.Controllers; | ||
|
||
import io.swagger.annotations.ApiOperation; | ||
import io.turntabl.employementprofilingsystem.Models.RequestTO; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.web.bind.annotation.*; | ||
import java.io.IOException; | ||
import java.security.GeneralSecurityException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.List; | ||
|
||
@RestController | ||
public class RequestController { | ||
|
||
@Autowired | ||
JdbcTemplate jdbcTemplate; | ||
|
||
@CrossOrigin | ||
@ApiOperation("Make a request") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a what request? all of these services are requests... |
||
@PostMapping("/api/v1/request") | ||
public void makeARequest(@RequestBody RequestTO request) { | ||
jdbcTemplate.update("insert into requests(requester_id, request_start_date, request_report_date) values(?,?,?)", | ||
request.getRequester_id(), request.getRequest_start_date(), request.getRequest_report_date()); | ||
} | ||
|
||
@CrossOrigin | ||
@ApiOperation("Get all requests for requester") | ||
@GetMapping("/api/v1/request/requester/{id}") | ||
public List<RequestTO> getRequestByRequesterId(@PathVariable("id") Integer id) { | ||
return this.jdbcTemplate.query( | ||
"select select request_start_date, request_report_date, request_status.req_status from requests inner join request_status on " + | ||
"requests.request_status_id = request_status.request_status_id where requester_id = ?", | ||
new Object[]{id}, | ||
new BeanPropertyRowMapper<>(RequestTO.class) | ||
); | ||
} | ||
|
||
@CrossOrigin | ||
@ApiOperation("Get all requests") | ||
@GetMapping("/api/v1/requests") | ||
public List<RequestTO> getAllRequests() { | ||
return this.jdbcTemplate.query("select select request_start_date, request_report_date, request_status.req_status from requests inner join request_status on" + | ||
"requests.request_status_id = request_status.request_status_id", | ||
new BeanPropertyRowMapper<RequestTO>(RequestTO.class) | ||
); | ||
} | ||
|
||
@CrossOrigin | ||
@ApiOperation("Accept Request") | ||
@PutMapping("/api/v1/requests/approve/{id}") | ||
public void approveRequest(@PathVariable("id") Integer request_id) { | ||
this.jdbcTemplate.update("update requests set request_status_id = 3 where request_status_id = 1 and request_id = ?", request_id); | ||
} | ||
|
||
@CrossOrigin | ||
@ApiOperation("Decline Request") | ||
@PutMapping("/api/v1/requests/decline/{id}") | ||
public void declineRequest(@PathVariable("id") Integer request_id) { | ||
this.jdbcTemplate.update("update requests set request_status_id = 2 where request_status_id = 1 and request_id = ?", request_id); | ||
} | ||
} | ||
|
96 changes: 96 additions & 0 deletions
96
src/main/java/io/turntabl/employementprofilingsystem/Models/RequestTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package io.turntabl.employementprofilingsystem.Models; | ||
|
||
import java.util.Date; | ||
|
||
public class RequestTO { | ||
private int request_id; | ||
private int requester_id; | ||
private Date request_start_date; | ||
private Date request_report_date; | ||
private int request_status_id; | ||
private String from; | ||
private String requester_name; | ||
|
||
public RequestTO() { | ||
} | ||
|
||
public RequestTO(int request_id, int requester_id, Date request_start_date, Date request_report_date, int request_status_id, String from, String requester_name) { | ||
this.request_id = request_id; | ||
this.requester_id = requester_id; | ||
this.request_start_date = request_start_date; | ||
this.request_report_date = request_report_date; | ||
this.request_status_id = request_status_id; | ||
this.from = from; | ||
this.requester_name = requester_name; | ||
} | ||
|
||
public int getRequest_id() { | ||
return request_id; | ||
} | ||
|
||
public void setRequest_id(int request_id) { | ||
this.request_id = request_id; | ||
} | ||
|
||
public int getRequester_id() { | ||
return requester_id; | ||
} | ||
|
||
public void setRequester_id(int requester_id) { | ||
this.requester_id = requester_id; | ||
} | ||
|
||
public Date getRequest_start_date() { | ||
return request_start_date; | ||
} | ||
|
||
public void setRequest_start_date(Date request_start_date) { | ||
this.request_start_date = request_start_date; | ||
} | ||
|
||
public Date getRequest_report_date() { | ||
return request_report_date; | ||
} | ||
|
||
public void setRequest_report_date(Date request_report_date) { | ||
this.request_report_date = request_report_date; | ||
} | ||
|
||
public int getRequest_status_id() { | ||
return request_status_id; | ||
} | ||
|
||
public void setRequest_status_id(int request_status_id) { | ||
this.request_status_id = request_status_id; | ||
} | ||
|
||
public String getFrom() { | ||
return from; | ||
} | ||
|
||
public void setFrom(String from) { | ||
this.from = from; | ||
} | ||
|
||
public String getRequester_name() { | ||
return requester_name; | ||
} | ||
|
||
public void setRequester_name(String requester_name) { | ||
this.requester_name = requester_name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RequestTO{" + | ||
"request_id=" + request_id + | ||
", requester_id=" + requester_id + | ||
", request_start_date=" + request_start_date + | ||
", request_report_date=" + request_report_date + | ||
", request_status_id=" + request_status_id + | ||
", from='" + from + '\'' + | ||
", requester_name='" + requester_name + '\'' + | ||
'}'; | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you using a DAO for this? The controller uses the DAO, the DAO uses the JdbcTemplate.
This is fine if you're not using a DAO...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not using DAO