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

added link functionality to complaint controllers

parent bcd1ea3a
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import com.project.cms.complaint.enums.FCAType;
import com.project.cms.complaint.enums.ComplaintMethod;
import java.sql.Timestamp;
import java.util.List;
@Data
@NoArgsConstructor
......
......@@ -88,4 +88,9 @@ public class ComplaintController {
return modelAndView;
}
@PostMapping("/link")
public void addLink(){
}
}
......@@ -15,4 +15,7 @@ public interface ComplaintRepository {
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 getLink(Authentication userAuth, int id);
void addLink(Authentication userAuth, int from_id, int to_id);
}
......@@ -216,6 +216,36 @@ public class ComplaintRepositoryImpl implements ComplaintRepository{
return false;
}
@Override
public void getLink(Authentication userAuth, int id) {
}
@Override
public void addLink(Authentication userAuth, int from_id, int to_id) {
if (!userAuth.isAuthenticated()){
return;
}
Collection<? extends GrantedAuthority> userRoles = userAuth.getAuthorities();
if (userRoles.contains(new SimpleGrantedAuthority("STAFF")) || userRoles.contains(new SimpleGrantedAuthority("STAFF") )){
jdbcTemplate.update(
"INSERT INTO complaint (complaint_from,complaint_to) VALUES (?,?)", from_id, to_id
);
jdbcTemplate.update(
"INSERT INTO complaint (complaint_from,complaint_to) VALUES (?,?)", to_id,from_id
);
}
}
}
......@@ -6,10 +6,7 @@ import com.project.cms.complaint.Complaint;
import com.project.cms.complaint.ComplaintService;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
......@@ -80,4 +77,6 @@ public class StaffController {
return modelAndView;
}
}
......@@ -8,10 +8,13 @@ drop table if exists complaint;
drop table if exists complaint_method;
drop table if exists fca_option;
drop table if exists comment;
drop table if exists linked_complaint;
SET FOREIGN_KEY_CHECKS=1;
drop view if exists authorities_from_user;
-- Account
create table if not exists users(
......@@ -57,6 +60,7 @@ create table if not exists complaint(
status boolean not null,
text_box varchar(8192),
PRIMARY KEY (id),
FOREIGN KEY (policy_number) REFERENCES users(username)
......@@ -89,4 +93,13 @@ create table if not exists comment(
FOREIGN KEY (user) REFERENCES users(username),
FOREIGN KEY (complaint_id) REFERENCES complaint(id)
)
\ No newline at end of file
);
create table if not exists linked_complaint(
from_complaint bigint not null,
to_complaint bigint not null,
FOREIGN KEY(from_complaint) REFERENCES complaint(id)
);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment