Skip to content

Commit

Permalink
Merge pull request #30 from hariclerry/feat/UI-feedback
Browse files Browse the repository at this point in the history
Merge INTO develop: Updated the link and added NavBar to all pages
  • Loading branch information
hariclerry authored Jul 18, 2024
2 parents cba97f6 + 517579c commit 09a386d
Show file tree
Hide file tree
Showing 80 changed files with 2,254 additions and 306 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class FeedbackHandlerAspect {

@Before("execution(* com.waa.project.controller.feedback.FeedbackController.*(..))")
public void beforeMe(JoinPoint joinPoint) {
System.out.println("Execution Before JoingPoint == " + joinPoint.getSignature().getName());
//System.out.println("Execution Before JoingPoint == " + joinPoint.getSignature().getName());
}

@After("execution(* com.waa.project.controller.feedback.FeedbackController.*(..))")
public void afterMe(JoinPoint joinPoint) {
System.out.println("Execution After JoingPoint == " + joinPoint.getSignature().getName());
// System.out.println("Execution After JoingPoint == " + joinPoint.getSignature().getName());
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.waa.project.controller.academic;

import com.waa.project.dto.AcademicResourceDto;
import com.waa.project.dto.AcademicResourceRequest;
import com.waa.project.dto.requests.AcademicResourceRequest;
import com.waa.project.dto.responses.AcademicResourceResponse;
import com.waa.project.service.AcademicResService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -20,38 +24,42 @@ public class AcademicController {
@Autowired
private AcademicResService academicResService;

@GetMapping({"/admins/academic", "/students/academic"})
public List<AcademicResourceDto> getAllResources() {
@Autowired
private ModelMapper modelMapper;


@GetMapping({"/academic"})//, "/students/academic"})
public List<AcademicResourceResponse> getAllResources() {
return academicResService.getAllAcademicRes();
}

@GetMapping({"/admins/academic/{Id}", "/students/academic/{Id}"})
public AcademicResourceDto getResource(@PathVariable Long Id) {
@GetMapping({"/academic/{Id}"})//, "/students/academic/{Id}"})
public AcademicResourceResponse getResource(@PathVariable Long Id) {

return academicResService.getAcademicResource(Id);
}

@PutMapping({"/admins/academic/{Id}", "/students/academic/{Id}"})
public String update(
@RequestBody AcademicResourceDto dto, @PathVariable Long Id
) {
return academicResService.update(dto, Id);
@PutMapping({"/academic/{Id}"})//, "/students/academic/{Id}"})
public ResponseEntity<AcademicResourceResponse> update(
@Valid @RequestPart(value = "formdata") AcademicResourceRequest dto,
@PathVariable Long Id,
@RequestPart(value = "file", required = false) MultipartFile file) {
return new ResponseEntity<>(academicResService.update(dto, Id, file), HttpStatus.CREATED);
}

@PostMapping(value = {"/admins/academic", "/students/academic"}, consumes = "multipart/form-data")
public String save(@RequestPart(value = "formdata") AcademicResourceRequest request,
@RequestPart(value = "file", required = false) MultipartFile file) {
return academicResService.save(request, file);
@PostMapping(value = {"/academic"})//, "/students/academic"}, consumes = "multipart/form-data")
public ResponseEntity<AcademicResourceResponse> save(@Valid @RequestPart(value = "formdata") AcademicResourceRequest request,
@RequestPart(value = "file", required = false) MultipartFile file) {
return new ResponseEntity<>(academicResService.save(request, file), HttpStatus.CREATED);
}

@GetMapping({"/admins/academic/search", "/students/academic/search"})
public List<AcademicResourceDto> search(@RequestParam String search) {
public List<AcademicResourceResponse> search(@RequestParam String search) {
return academicResService.searchByResourceName(search);
}

@DeleteMapping({"/admins/academic/{Id}", "/students/academic/{Id}"})
public String delete(@PathVariable Long Id) {
@DeleteMapping({"/academic/{Id}"})//, "/students/academic/{Id}"})
public List<AcademicResourceResponse> delete(@PathVariable Long Id) {

return academicResService.delete(Id);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.waa.project.controller.academic;

import com.waa.project.dto.AcademicResourceTypeDto;
import com.waa.project.dto.requests.AcademicResourceTypeRequest;
import com.waa.project.dto.responses.AcademicResourceTypeResponse;
import com.waa.project.entity.AcademicResourceType;
import com.waa.project.service.AcademicResourceTypeService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand All @@ -18,31 +24,32 @@ public class AcademicResourceTypeController {
@Autowired
private AcademicResourceTypeService academicResourceTypeService;

@GetMapping({"/admins/academicresources", "/students/academicresources"})
@GetMapping({"/academicresources"})//, "/students/academicresources"})
public List<AcademicResourceTypeDto> getAllResourcesTypes() {
return academicResourceTypeService.getAllCategories();
}

@GetMapping({"/admins/academicresources/{catId}", "/students/academicresources/{catId}"})
@GetMapping({"/academicresources/{catId}"})//, "/students/academicresources/{catId}"})
public AcademicResourceTypeDto getResourceType(@PathVariable Long catId) {
return academicResourceTypeService.getAcademicResourceType(catId);
}

@PutMapping({"/admins/academicresources/{catId}", "/students/academicresources/{catId}"})
public String update(
@RequestBody AcademicResourceTypeDto dto,
@PutMapping({"/academicresources/{catId}"})//, "/students/academicresources/{catId}"})
public ResponseEntity<AcademicResourceTypeResponse> update(
@Valid @RequestBody AcademicResourceTypeRequest request,
@PathVariable Long catId
) {
return academicResourceTypeService.update(dto, catId);
) {
return new ResponseEntity<>(academicResourceTypeService.update(request, catId), HttpStatus.CREATED);
}

@PostMapping({"/admins/academicresources", "/students/academicresources"})
public String save(@RequestBody AcademicResourceTypeDto dto) {
return academicResourceTypeService.save(dto);
@PostMapping({"/academicresources"})//, "/students/academicresources"})
public ResponseEntity<AcademicResourceTypeResponse> save(
@Valid @RequestBody AcademicResourceTypeRequest request) {
return new ResponseEntity<>(academicResourceTypeService.save(request), HttpStatus.CREATED);
}

@DeleteMapping({"/admins/academicresources/{catId}", "/students/academicresources/{catId}"})
public String delete(@PathVariable Long catId) {
@DeleteMapping({"/academicresources/{catId}"})//, "/students/academicresources/{catId}"})
public List<AcademicResourceType> delete(@PathVariable Long catId) {
return academicResourceTypeService.delete(catId);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.waa.project.controller.feedback;

import com.waa.project.dto.FeedbackCategoryDto;
import com.waa.project.dto.requests.FeedbackCategoryRequest;
import com.waa.project.dto.responses.FeedbackCategoryResponse;
import com.waa.project.entity.FeedbackCategory;
import com.waa.project.service.FeedbackCategoryService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand All @@ -29,20 +35,21 @@ public FeedbackCategoryDto getAllFeedCategory(@PathVariable Long catId) {
}

@PutMapping("/admins/feedbackcategories/{catId}")
public String getAllFeedCategory(
@RequestBody FeedbackCategoryDto feedbackCategoryDto,
public String update(
@Valid @RequestBody FeedbackCategoryDto feedbackCategoryDto,
@PathVariable Long catId
) {
) {
return feedbackCategoryService.update(feedbackCategoryDto, catId);
}

@PostMapping("/admins/feedbackcategories")
public String getAllFeedCategory(@RequestBody FeedbackCategoryDto feedbackCategoryDto) {
return feedbackCategoryService.save(feedbackCategoryDto);
public ResponseEntity<FeedbackCategoryResponse> saveFeedbackCategory(
@Valid @RequestBody FeedbackCategoryRequest feedbackCategory) {
return new ResponseEntity<>(feedbackCategoryService.save(feedbackCategory), HttpStatus.CREATED);
}

@DeleteMapping("/admins/feedbackcategories/{catId}")
public String delete(@PathVariable Long catId) {
public List<FeedbackCategory> delete(@PathVariable Long catId) {
return feedbackCategoryService.delete(catId);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package com.waa.project.controller.feedback;

import com.waa.project.dto.FeedbackDto;
import com.waa.project.dto.requests.FeedbackRequest;
import com.waa.project.dto.responses.FeedbackResponse;
import com.waa.project.entity.Feedback;
import com.waa.project.service.FeedbackService;
import com.waa.project.service.UserService;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;
Expand All @@ -28,7 +34,7 @@ public class FeedbackController {
private UserService userService;

@GetMapping("/feedbacks")
public List<FeedbackDto> getAllFeedBack() {
public List<Feedback> getAllFeedBack() {

return feedbackService.getAllFeedbacks();
}
Expand All @@ -53,34 +59,35 @@ public List<FeedbackDto> getFeedByCategory(@PathVariable Long Id) {
return feedbackService.findFeedbackByCategory(Id);
}

@PutMapping({"/admins/feedbacks/{Id}", "/students/feedbacks/{Id}"})
public String update(
@RequestBody FeedbackDto feedbackDto,
@PutMapping({"/feedbacks/{Id}"})//, "/students/feedbacks/{Id}"})
public ResponseEntity<FeedbackResponse> update(
@Valid @RequestBody FeedbackRequest feedbackRequest,
@PathVariable Long Id,
@AuthenticationPrincipal UserDetails userDetails
) {

Long currentUser = null;

if (userDetails != null && userDetails.getUsername() != null) {
currentUser = userService.findByUsername(userDetails.getUsername()).getId();
}
return new ResponseEntity<>(feedbackService.update(feedbackRequest, Id, currentUser), HttpStatus.CREATED);

return feedbackService.update(feedbackDto, Id, currentUser);
}

@PostMapping("/feedbacks")
public String save(@RequestBody FeedbackDto feedbackDto, @AuthenticationPrincipal UserDetails userDetails) {
public ResponseEntity<FeedbackResponse> save(
@Valid @RequestBody FeedbackRequest feedbackRequest,
@AuthenticationPrincipal UserDetails userDetails) {
Long currentUser = null;

if (userDetails != null && userDetails.getUsername() != null) {
currentUser = userService.findByUsername(userDetails.getUsername()).getId();
}
return feedbackService.save(feedbackDto, currentUser);
return new ResponseEntity<>(feedbackService.save(feedbackRequest, currentUser), HttpStatus.CREATED);
}

@DeleteMapping({"/admins/feedbacks/{Id}", "/students/feedbacks/{Id}"})
public String delete(@PathVariable Long Id) {

@DeleteMapping({"/feedbacks/{Id}"})// "/students/feedbacks/{Id}"})
public List<Feedback> delete(@PathVariable Long Id) {
return feedbackService.delete(Id);
}

Expand All @@ -97,13 +104,13 @@ public Map<String, Integer> findFeedbackByCategoryCount() {

@GetMapping("/feedbacks/showMe")
public Map<String, String> showMe(@AuthenticationPrincipal UserDetails userDetails) {
System.out.println("userDetails===" + userDetails);
var result = userService.findByUsername(userDetails.getUsername());
Map<String, String> response = new HashMap<>();
response.put("name", result.getUsername());
response.put("email", result.getUsername());
response.put("role", result.getUsername());
response.put("id", result.getId().toString());
return response;

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@Data
public class FeedbackCategoryDto {
private Long id;
private Long id;
private String name;
private String description;
}
9 changes: 5 additions & 4 deletions backend/src/main/java/com/waa/project/dto/FeedbackDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

@Data
public class FeedbackDto {
private Long id;
private String title;
private String body;
private Long id;
private String title;
private String body;
private FeedbackCategory feedbackCategory;
private Student student;
private Student student;
private Long category;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.waa.project.dto.requests;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.File;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AcademicResourceRequest {
@NotNull(message = "Name cannot be null.")
@NotBlank(message = "Name cannot be blank.")
@Size(min = 2, max = 250, message = "Name must be minimum of 2 characters long.")
private String name;

@NotNull(message = "Description cannot be null.")
@NotBlank(message = "Description cannot be blank.")
@Size(min = 2, max = 250, message = "Description must be minimum of 2 characters long.")
private String body;

private File file;

@NotNull(message = "Category cannot be empty.")
private Long resourceId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.waa.project.dto.requests;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

@Data
public class AcademicResourceTypeRequest {
@NotNull(message = "Name cannot be null.")
@NotBlank(message = "Name cannot be blank.")
@Size(min = 2, max = 250, message = "Name must be minimum of 2 characters long.")
private String name;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.waa.project.dto.requests;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

@Data
public class FeedbackCategoryRequest {
@NotNull(message = "Category name cannot be null.")
@NotBlank(message = "Category name cannot be blank.")
@Size(min = 2, max = 250, message = "Category name must be minimum of 2 characters long.")
private String name;

@NotNull(message = "Description cannot be null.")
@NotBlank(message = "Description cannot be blank.")
@Size(min = 2, max = 250, message = "Description must be minimum of 2 characters long.")
private String description;
}
Loading

0 comments on commit 09a386d

Please sign in to comment.