готовая лаб 3
This commit is contained in:
parent
7094911275
commit
c26da9cafc
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
3081
data.trace.db
3081
data.trace.db
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ public class EntrysDataController {
|
||||
return modelMapper.map(entity, EntrysDataDto.class);
|
||||
}
|
||||
|
||||
private EntrysDataGroupedDto toGroupedDto(EntrysDataGrouped entity){
|
||||
private EntrysDataGroupedDto toGroupedDto(EntrysDataGrouped entity) {
|
||||
return modelMapper.map(entity, EntrysDataGroupedDto.class);
|
||||
}
|
||||
|
||||
@ -53,9 +53,9 @@ public class EntrysDataController {
|
||||
|
||||
@GetMapping
|
||||
public PageDto<EntrysDataDto> getAll(
|
||||
@RequestParam(name = "departmentId", defaultValue = "0") Long departmentId,
|
||||
@RequestParam(name = "page", defaultValue = "0") int page,
|
||||
@RequestParam(name = "size", defaultValue = Constants.DEFAULT_PAGE_SIZE) int size) {
|
||||
@RequestParam(name = "departmentId", defaultValue = "0") Long departmentId,
|
||||
@RequestParam(name = "page", defaultValue = "0") int page,
|
||||
@RequestParam(name = "size", defaultValue = Constants.DEFAULT_PAGE_SIZE) int size) {
|
||||
return PageDtoMapper.toDto(entrysDataService.getAll(departmentId, page, size), this::toDto);
|
||||
}
|
||||
|
||||
@ -85,8 +85,12 @@ public class EntrysDataController {
|
||||
@RequestParam(name = "oldPassword") String oldPas) {
|
||||
return toDto(entrysDataService.updatePassword(id, newPas, oldPas));
|
||||
}
|
||||
|
||||
@GetMapping("/count")
|
||||
public List<EntrysDataGroupedDto> getCount(){
|
||||
return entrysDataService.getCount().stream().map(this::toGroupedDto).toList();
|
||||
public List<EntrysDataGroupedDto> getCount() {
|
||||
var val1 = entrysDataService.getCount().stream();
|
||||
var val2 = val1.map(this::toGroupedDto).toList();
|
||||
List<EntrysDataGroupedDto> list = val2;
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -3,20 +3,21 @@ package com.example.demo.entrysData.api;
|
||||
public class EntrysDataGroupedDto {
|
||||
private Long DepartmentId;
|
||||
|
||||
private int Count;
|
||||
private Long Count;
|
||||
|
||||
public Long getDepartmentId(){
|
||||
public Long getDepartmentId() {
|
||||
return DepartmentId;
|
||||
}
|
||||
public void setDepartmentId(Long DepartmentId){
|
||||
|
||||
public void setDepartmentId(Long DepartmentId) {
|
||||
this.DepartmentId = DepartmentId;
|
||||
}
|
||||
|
||||
public int getCount(){
|
||||
public Long getCount() {
|
||||
return Count;
|
||||
}
|
||||
|
||||
public void setCount(int Count){
|
||||
public void setCount(Long Count) {
|
||||
this.Count = Count;
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ package com.example.demo.entrysData.model;
|
||||
public interface EntrysDataGrouped {
|
||||
Long getDepartmentId();
|
||||
|
||||
int getCount();
|
||||
Long getCount();
|
||||
}
|
||||
|
@ -22,9 +22,8 @@ public interface EntrysDataRepository extends CrudRepository<EntrysDataEntity, L
|
||||
|
||||
Page<EntrysDataEntity> findAll(Pageable pageable);
|
||||
|
||||
@Query("SELECT department_id, COUNT(id) AS count_id" +
|
||||
"FROM entrys_data" +
|
||||
"GROUP BY department_id" +
|
||||
"ORDER BY count_id DESC")
|
||||
@Query("SELECT e.department.id AS departmentId, COUNT(e.id) AS count " +
|
||||
"FROM EntrysDataEntity e " +
|
||||
"GROUP BY departmentId ORDER BY count DESC")
|
||||
List<EntrysDataGrouped> getCountEntrysInDepartment();
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ public class EntrysDataService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<EntrysDataGrouped> getCount(){
|
||||
return repository.getCountEntrysInDepartment();
|
||||
public List<EntrysDataGrouped> getCount() {
|
||||
List<EntrysDataGrouped> list = repository.getCountEntrysInDepartment();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user