Skip to content
Merged
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 @@ -3,6 +3,7 @@
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import org.example.crm.entity.dto.attendance.*;
import org.example.crm.filters.AttendanceFilterDto;
import org.example.crm.service.AttendanceService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -32,7 +33,7 @@ public ResponseEntity<Page<AttendanceDto>> getAll(
@RequestParam(required = false) String search
) {
Pageable pageable = PageRequest.of(page, size);
Page<AttendanceDto> attendances = service.getAll(pageable, search);
Page<AttendanceDto> attendances = service.getAll(pageable, new AttendanceFilterDto(search));
return ResponseEntity.ok(attendances);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.example.crm.annotation.CurrentUser;
import org.example.crm.entity.dto.branch.BranchCreateDto;
import org.example.crm.entity.dto.branch.BranchDto;
import org.example.crm.filters.BranchFilterDto;
import org.example.crm.entity.dto.branch.BranchUpdateDto;
import org.example.crm.entity.model.User;
import org.example.crm.service.BranchService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand All @@ -31,7 +30,7 @@ public ResponseEntity<Page<BranchDto>> getAll(
@RequestParam(required = false) String search
) {
Pageable pageable = PageRequest.of(page, size);
Page<BranchDto> lessons = branchService.getAll(pageable, search);
Page<BranchDto> lessons = branchService.getAll(pageable, new BranchFilterDto(search));
return ResponseEntity.ok(lessons);
}

Expand Down
19 changes: 10 additions & 9 deletions src/main/java/org/example/crm/controller/EnrollmentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.validation.Valid;
import org.example.crm.entity.dto.enrollment.EnrollmentCreateDto;
import org.example.crm.entity.dto.enrollment.EnrollmentDto;
import org.example.crm.filters.EnrollmentFilterDto;
import org.example.crm.entity.dto.enrollment.EnrollmentUpdateDto;
import org.example.crm.service.EnrollmentService;
import org.springframework.data.domain.Page;
Expand All @@ -17,10 +18,10 @@
@RequestMapping("api/v1/enrollments")
public class EnrollmentController {

private final EnrollmentService enrollmentService;
private final EnrollmentService service;

public EnrollmentController(EnrollmentService enrollmentService) {
this.enrollmentService = enrollmentService;
public EnrollmentController(EnrollmentService service) {
this.service = service;
}

@GetMapping
Expand All @@ -29,19 +30,19 @@ public ResponseEntity<Page<EnrollmentDto>> getAll(
@RequestParam(required = false) String search,
@RequestParam(required = false) String groupId
) {
Page<EnrollmentDto> enrollments = groupId == null ? enrollmentService.getAll(pageable, search) : enrollmentService.getAll(pageable, search, groupId);
Page<EnrollmentDto> enrollments = service.getAll(pageable,new EnrollmentFilterDto(search,groupId));
return ResponseEntity.ok(enrollments);
}

@GetMapping("/{id}")
public ResponseEntity<EnrollmentDto> getById(@PathVariable String id) {
EnrollmentDto enrollment = enrollmentService.get(id);
EnrollmentDto enrollment = service.get(id);
return ResponseEntity.ok(enrollment);
}

@PostMapping
public ResponseEntity<EnrollmentDto> create(@Valid @RequestBody EnrollmentCreateDto createDto) {
EnrollmentDto createdEnrollment = enrollmentService.create(createDto);
EnrollmentDto createdEnrollment = service.create(createDto);
return ResponseEntity.status(HttpStatus.CREATED).body(createdEnrollment);
}

Expand All @@ -51,18 +52,18 @@ public ResponseEntity<EnrollmentDto> update(
@PathVariable String id,
@Valid @RequestBody EnrollmentUpdateDto updateDto
) {
EnrollmentDto updatedEnrollment = enrollmentService.update(updateDto, id);
EnrollmentDto updatedEnrollment = service.update(updateDto, id);
return ResponseEntity.ok(updatedEnrollment);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> delete(@PathVariable String id, @RequestParam String reason) {
enrollmentService.delete(id,reason);
service.delete(id,reason);
return ResponseEntity.noContent().build();
}

@GetMapping("/student/{studentId}")
public ResponseEntity<List<EnrollmentDto>> getByStudentId(@PathVariable String studentId) {
return ResponseEntity.ok(enrollmentService.getByStudentId(studentId));
return ResponseEntity.ok(service.getByStudentId(studentId));
}
}
8 changes: 3 additions & 5 deletions src/main/java/org/example/crm/controller/GroupController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.example.crm.entity.dto.group.FullGroupDto;
import org.example.crm.entity.dto.group.GroupCreateDto;
import org.example.crm.entity.dto.group.GroupDto;
import org.example.crm.entity.dto.group.GroupUpdateDto;
import org.example.crm.entity.dto.group.*;
import org.example.crm.entity.enums.GroupStatus;
import org.example.crm.filters.GroupFilterDto;
import org.example.crm.projection.GroupNameProjection;
import org.example.crm.service.GroupService;
import org.springframework.data.domain.Page;
Expand All @@ -31,7 +29,7 @@ public ResponseEntity<Page<GroupDto>> getAllGroups(@RequestParam(required = fals
@RequestParam(required = false) GroupStatus status,
@RequestParam(required = false) String level) {
Pageable pageable = PageRequest.of(page, size);
return ResponseEntity.ok(service.getAll(pageable, search, status, level));
return ResponseEntity.ok(service.getAll(pageable, new GroupFilterDto(search,status,level)));
}

@GetMapping("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.example.crm.entity.dto.groupLevel.GroupLevelNameDto;
import org.example.crm.entity.dto.groupLevel.GroupLevelUpdateDto;
import org.example.crm.entity.request.GroupLevelList;
import org.example.crm.filters.SearchFilterDto;
import org.example.crm.service.GroupLevelService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/example/crm/controller/ImageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import lombok.RequiredArgsConstructor;
import org.example.crm.entity.dto.image.ImageDto;
import org.example.crm.service.ImageService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
Expand All @@ -22,11 +21,8 @@ public class ImageController {
private final ImageService imageService;

@GetMapping
public ResponseEntity<Page<ImageDto>> getAll(
Pageable pageable,
@RequestParam(required = false) String search
) {
Page<ImageDto> images = imageService.getAll(pageable, search);
public ResponseEntity<List<ImageDto>> getAll() {
List<ImageDto> images = imageService.getAll(null, null);
return ResponseEntity.ok(images);
}

Expand All @@ -38,7 +34,7 @@ public ResponseEntity<ImageDto> getById(@PathVariable String id) {

@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Object> upload(@Valid @RequestParam MultipartFile file) throws IOException {
return ResponseEntity.ok(Map.of("imageUrl",imageService.uploadImage(file)));
return ResponseEntity.ok(Map.of("imageUrl", imageService.uploadImage(file)));
}

@PutMapping("/main/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.example.crm.entity.dto.InvoiceCreateDto;
import org.example.crm.entity.dto.InvoiceDto;
import org.example.crm.entity.enums.InvoiceStatus;
import org.example.crm.filters.InvoiceFilterDto;
import org.example.crm.service.InvoiceService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand All @@ -30,7 +31,7 @@ public ResponseEntity<Page<InvoiceDto>> getAllInvoices(@RequestParam(required =
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "20") Integer size) {
Pageable pageable = PageRequest.of(page, size);
return ResponseEntity.ok(service.getAllInvoices(search, from, to, status, pageable));
return ResponseEntity.ok(service.getAll(pageable,new InvoiceFilterDto(from, to, status, search)));
}

@GetMapping("/{id}")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/example/crm/controller/LeadController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.example.crm.entity.dto.lead.LeadRejectDto;
import org.example.crm.entity.dto.lead.LeadUpdateDto;
import org.example.crm.entity.enums.LeadStatus;
import org.example.crm.filters.LeadFilterDto;
import org.example.crm.service.LeadService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -32,7 +33,7 @@ public ResponseEntity<Page<LeadDto>> getAll(
@PageableDefault Pageable pageable,
@RequestParam(required = false) String search,
@RequestParam(required = false) LeadStatus status) {
return ResponseEntity.ok(service.getAll(pageable, search, status));
return ResponseEntity.ok(service.getAll(pageable,new LeadFilterDto( search, status)));
}

@GetMapping("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.example.crm.entity.dto.lesson.LessonCreateDto;
import org.example.crm.entity.dto.lesson.LessonDto;
import org.example.crm.entity.dto.lesson.LessonUpdateDto;
import org.example.crm.filters.LessonFilterDto;
import org.example.crm.service.LessonService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -28,7 +29,7 @@ public ResponseEntity<Page<LessonDto>> getAll(
Pageable pageable,
@RequestParam(required = false) String search
) {
Page<LessonDto> lessons = lessonService.getAll(pageable, search);
Page<LessonDto> lessons = lessonService.getAll(pageable, new LessonFilterDto(search));
return ResponseEntity.ok(lessons);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.example.crm.entity.dto.organization.OrganizationCreateDto;
import org.example.crm.entity.dto.organization.OrganizationDto;
import org.example.crm.entity.dto.organization.OrganizationUpdateDto;
import org.example.crm.filters.OrganizationFilterDto;
import org.example.crm.service.OrganizationService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -24,7 +25,7 @@ public class OrganizationController {
public ResponseEntity<Page<OrganizationDto>> getAll(
@PageableDefault(size = 10, sort = "createdAt") Pageable pageable,
@RequestParam(required = false) String search) {
return ResponseEntity.ok(organizationService.getAll(pageable, search));
return ResponseEntity.ok(organizationService.getAll(pageable, new OrganizationFilterDto(search)));
}

@GetMapping("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.example.crm.entity.dto.student.StudentCreateDto;
import org.example.crm.entity.dto.student.StudentDto;
import org.example.crm.entity.dto.student.StudentUpdateDto;
import org.example.crm.filters.StudentFilterDto;
import org.example.crm.service.StudentService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -31,7 +32,7 @@ public ResponseEntity<Page<StudentDto>> getAll(
Pageable pageable,
@RequestParam(required = false) String search
) {
Page<StudentDto> students = studentService.getAll(pageable, search);
Page<StudentDto> students = studentService.getAll(pageable, new StudentFilterDto(search));
return ResponseEntity.ok(students);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.example.crm.entity.dto.teacher.TeacherCreateDto;
import org.example.crm.entity.dto.teacher.TeacherDto;
import org.example.crm.entity.dto.teacher.TeacherUpdateDto;
import org.example.crm.filters.TeacherFilterDto;
import org.example.crm.service.TeacherService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -30,7 +31,7 @@ public ResponseEntity<Page<TeacherDto>> getAll(
Pageable pageable,
@RequestParam(required = false) String search
) {
Page<TeacherDto> teachers = teacherService.getAll(pageable, search);
Page<TeacherDto> teachers = teacherService.getAll(pageable, new TeacherFilterDto(search));
return ResponseEntity.ok(teachers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.example.crm.entity.dto.TimeTableUpdateDto;
import org.example.crm.entity.dto.timeTable.TimeTableDto;
import org.example.crm.entity.enums.DayType;
import org.example.crm.filters.TimeTableFilterDto;
import org.example.crm.service.TimeTableService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -23,7 +24,7 @@ public class TimeTableController {
public ResponseEntity<List<TimeTableDto>> findAll(@RequestParam(required = false) DayType dayType,
@RequestParam(required = false, defaultValue = "00:00") LocalTime start,
@RequestParam(required = false, defaultValue = "23:59:59") LocalTime end) {
return ResponseEntity.ok(service.getAll(dayType,start,end));
return ResponseEntity.ok(service.getAll(null,new TimeTableFilterDto(dayType,start,end)));
}

@GetMapping("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import lombok.RequiredArgsConstructor;
import org.example.crm.entity.dto.transaction.TransactionCreateDto;
import org.example.crm.entity.dto.transaction.TransactionDto;
import org.example.crm.filters.TransactionFilterDto;
import org.example.crm.entity.dto.transaction.TransactionUpdateDto;
import org.example.crm.entity.enums.TransactionType;
import org.example.crm.service.TransactionService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand All @@ -26,10 +28,11 @@ public class TransactionController {
public ResponseEntity<Page<TransactionDto>> getAll(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(defaultValue = "10") TransactionType type,
@RequestParam(required = false) String search
) {
Pageable pageable = PageRequest.of(page, size);
Page<TransactionDto> transactions = transactionService.getAll(pageable, search);
Page<TransactionDto> transactions = transactionService.getAll(pageable, new TransactionFilterDto(type,search));
return ResponseEntity.ok(transactions);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/example/crm/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.example.crm.entity.dto.user.UserCreateDto;
import org.example.crm.entity.dto.user.UserDto;
import org.example.crm.entity.dto.user.UserUpdateDto;
import org.example.crm.filters.UserFilterDto;
import org.example.crm.service.UserService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -28,7 +29,7 @@ public ResponseEntity<Page<UserDto>> getAll(
Pageable pageable,
@RequestParam(required = false) String search
) {
Page<UserDto> users = userService.getAll(pageable, search);
Page<UserDto> users = userService.getAll(pageable, new UserFilterDto(search));
return ResponseEntity.ok(users);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@

public record TransactionCreateDto(
@NotNull
@Schema(allowableValues = {"PAID", "RETURNED","MONTHLY_FEE"})
@Schema(allowableValues = {"PAID", "RETURNED","MONTHLY_FEE","CORRECTION"})
TransactionType type,

@NotNull
BigDecimal amount,

String note,

@NotNull
String studentId,

@NotNull
String studentId
String invoiceId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public record TransactionDto(
String id,
TransactionType type,
BigDecimal amount,
String note,
InvoiceDto invoice,
StudentDto user,
LocalDateTime createdAt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.example.crm.entity.dto.transaction;

import io.swagger.v3.oas.annotations.media.Schema;
import org.example.crm.entity.enums.TransactionType;

import java.math.BigDecimal;

public record TransactionUpdateDto(
TransactionType type,
BigDecimal amount,
String note,
String invoiceId,
String studentId
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public enum TransactionType {
PAID,
RETURNED,
MONTHLY_FEE
REFUND,
MONTHLY_FEE,
CORRECTION
}
Loading