Skip to content
Snippets Groups Projects
Commit 06d98e75 authored by Zain Munshi's avatar Zain Munshi
Browse files

link complaint added on front end

parent 09478cb0
No related branches found
No related tags found
No related merge requests found
......@@ -89,8 +89,14 @@ public class ComplaintController {
}
@PostMapping("/link")
public void addLink(){
public void addLink(@RequestParam("to_id")Integer to_id, @RequestParam("from_id") Integer from_id, Authentication userAuth){
System.out.println(from_id);
System.out.println(to_id);
complaintService.addLink(userAuth, from_id, to_id);
// return new ModelAndView("redirect:/staff/complaint/details/"+ from_id);
}
}
......@@ -223,13 +223,14 @@ public class ComplaintRepositoryImpl implements ComplaintRepository{
@Override
public void addLink(Authentication userAuth, int from_id, int to_id) {
System.out.println(from_id);
if (!userAuth.isAuthenticated()){
return;
}
Collection<? extends GrantedAuthority> userRoles = userAuth.getAuthorities();
if (userRoles.contains(new SimpleGrantedAuthority("STAFF")) || userRoles.contains(new SimpleGrantedAuthority("STAFF") )){
if (userRoles.contains(new SimpleGrantedAuthority("STAFF")) || userRoles.contains(new SimpleGrantedAuthority("ADMIN") )){
jdbcTemplate.update(
"INSERT INTO complaint (complaint_from,complaint_to) VALUES (?,?)", from_id, to_id
......
......@@ -14,4 +14,6 @@ public interface ComplaintService {
List<Complaint> getComplaint(Authentication userAuth, String policyNumber, String title);
boolean updateFCAType(Authentication userAuth, int id, FCAType newType);
boolean updateStatus(Authentication userAuth, int id, Boolean newStatus);
void addLink(Authentication userAuth, int from_id, int to_id);
}
......@@ -53,4 +53,9 @@ public class ComplaintServiceImpl implements ComplaintService{
public boolean updateStatus(Authentication userAuth, int id, Boolean newStatus) {
return complaintRepository.updateStatus(userAuth, id, newStatus);
}
@Override
public void addLink(Authentication userAuth, int from_id, int to_id) {
complaintRepository.addLink(userAuth, from_id, to_id);
}
}
......@@ -63,6 +63,15 @@
</div>
<div class="d-flex flex-column mt-3">
<form th:action = "@{/complaint/link}" method="post">
<input type="number" name = "to_id" id="to_id" placeholder="Link Complaint Id">
<input type="hidden" name = "from_id" th:value="${complaintObject.id}" id="from_id">
<button class="btn btn-primary" type="submit">Submit</button>
</form>
</div>
<div class="d-flex flex-column mt-3">
<h5 class="fw-bold">Complaint Details: </h5>
<span th:text="${complaintObject.textBox}"></span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment