готовая лаб 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);
|
return modelMapper.map(entity, EntrysDataDto.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntrysDataGroupedDto toGroupedDto(EntrysDataGrouped entity){
|
private EntrysDataGroupedDto toGroupedDto(EntrysDataGrouped entity) {
|
||||||
return modelMapper.map(entity, EntrysDataGroupedDto.class);
|
return modelMapper.map(entity, EntrysDataGroupedDto.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +85,12 @@ public class EntrysDataController {
|
|||||||
@RequestParam(name = "oldPassword") String oldPas) {
|
@RequestParam(name = "oldPassword") String oldPas) {
|
||||||
return toDto(entrysDataService.updatePassword(id, newPas, oldPas));
|
return toDto(entrysDataService.updatePassword(id, newPas, oldPas));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/count")
|
@GetMapping("/count")
|
||||||
public List<EntrysDataGroupedDto> getCount(){
|
public List<EntrysDataGroupedDto> getCount() {
|
||||||
return entrysDataService.getCount().stream().map(this::toGroupedDto).toList();
|
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 {
|
public class EntrysDataGroupedDto {
|
||||||
private Long DepartmentId;
|
private Long DepartmentId;
|
||||||
|
|
||||||
private int Count;
|
private Long Count;
|
||||||
|
|
||||||
public Long getDepartmentId(){
|
public Long getDepartmentId() {
|
||||||
return DepartmentId;
|
return DepartmentId;
|
||||||
}
|
}
|
||||||
public void setDepartmentId(Long DepartmentId){
|
|
||||||
|
public void setDepartmentId(Long DepartmentId) {
|
||||||
this.DepartmentId = DepartmentId;
|
this.DepartmentId = DepartmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount(){
|
public Long getCount() {
|
||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCount(int Count){
|
public void setCount(Long Count) {
|
||||||
this.Count = Count;
|
this.Count = Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,5 @@ package com.example.demo.entrysData.model;
|
|||||||
public interface EntrysDataGrouped {
|
public interface EntrysDataGrouped {
|
||||||
Long getDepartmentId();
|
Long getDepartmentId();
|
||||||
|
|
||||||
int getCount();
|
Long getCount();
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,8 @@ public interface EntrysDataRepository extends CrudRepository<EntrysDataEntity, L
|
|||||||
|
|
||||||
Page<EntrysDataEntity> findAll(Pageable pageable);
|
Page<EntrysDataEntity> findAll(Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT department_id, COUNT(id) AS count_id" +
|
@Query("SELECT e.department.id AS departmentId, COUNT(e.id) AS count " +
|
||||||
"FROM entrys_data" +
|
"FROM EntrysDataEntity e " +
|
||||||
"GROUP BY department_id" +
|
"GROUP BY departmentId ORDER BY count DESC")
|
||||||
"ORDER BY count_id DESC")
|
|
||||||
List<EntrysDataGrouped> getCountEntrysInDepartment();
|
List<EntrysDataGrouped> getCountEntrysInDepartment();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ public class EntrysDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<EntrysDataGrouped> getCount(){
|
public List<EntrysDataGrouped> getCount() {
|
||||||
return repository.getCountEntrysInDepartment();
|
List<EntrysDataGrouped> list = repository.getCountEntrysInDepartment();
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user