update 查询参数

develop
hhb@hotmail.com 3 months ago
parent 87f75f34e5
commit 2f8bb75d6f

@ -45,10 +45,10 @@ public class AdminDutyController {
return R.success(res); return R.success(res);
} }
@GetMapping("index/{periodId}") @PostMapping("index")
@ApiOperation("获取首页数据") @ApiOperation("获取首页数据")
public R<DutyIndexData> index(@PathVariable String periodId){ public R<DutyIndexData> index(@Valid @RequestBody TimeRangeDto timeRangeDto){
DutyIndexData dutyIndexData = adminIndexDutyService.getIndexData(periodId); DutyIndexData dutyIndexData = adminIndexDutyService.getIndexData(timeRangeDto);
return R.success(dutyIndexData); return R.success(dutyIndexData);
} }

@ -16,7 +16,7 @@ import java.util.List;
/** /**
* *
* @author winter * @author winter
* @create 2023-12-06 14:37 * &#064;create 2023-12-06 14:37
*/ */
@RestController @RestController
@RequestMapping("admin/index") @RequestMapping("admin/index")
@ -26,10 +26,10 @@ public class IndexController {
private AdminAppraiseService adminAppraiseService; private AdminAppraiseService adminAppraiseService;
@GetMapping("/{periodId}") @PostMapping("/")
@ApiOperation("获取首页数据") @ApiOperation("获取首页数据")
public R<AppraiseIndexData> index(@PathVariable String periodId){ public R<AppraiseIndexData> index(@Valid @RequestBody TimeRangeDto timeRangeDto){
AppraiseIndexData appraiseIndexData = adminAppraiseService.getIndexData(periodId); AppraiseIndexData appraiseIndexData = adminAppraiseService.getIndexData(timeRangeDto);
return R.success(appraiseIndexData); return R.success(appraiseIndexData);
} }

@ -13,7 +13,7 @@ import java.util.List;
* @create 2023-12-06 14:45 * @create 2023-12-06 14:45
*/ */
public interface AdminAppraiseService { public interface AdminAppraiseService {
AppraiseIndexData getIndexData(String periodId); AppraiseIndexData getIndexData(TimeRangeDto timeRangeDto);
/** /**
* *

@ -16,7 +16,7 @@ import java.util.Map;
* @create 2024-02-28 15:07 * @create 2024-02-28 15:07
*/ */
public interface AdminIndexDutyService { public interface AdminIndexDutyService {
DutyIndexData getIndexData(String periodId); DutyIndexData getIndexData(TimeRangeDto timeRangeDto);
List<DutyRankPo> classRank(TimeRangeDto timeRangeDto); List<DutyRankPo> classRank(TimeRangeDto timeRangeDto);

@ -57,9 +57,9 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
private AppraiseRecordRepository appraiseRecordRepository; private AppraiseRecordRepository appraiseRecordRepository;
@Override @Override
public AppraiseIndexData getIndexData(String periodId) { public AppraiseIndexData getIndexData(TimeRangeDto timeRangeDto) {
final int SLICE_SIZE = 100; final int SLICE_SIZE = 100;
if (StringUtils.isBlank(periodId)) { if (StringUtils.isBlank(timeRangeDto.getPeriodId())) {
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不能为空"); throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不能为空");
} }
@ -72,11 +72,21 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
String schoolId = loginUser.getSchoolId(); String schoolId = loginUser.getSchoolId();
// 获取学期起止时间 // 获取学期起止时间
List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, periodId); List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, timeRangeDto.getPeriodId());
SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now()); SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now());
String academicYearId = semesterModel.getAcademicYearId(); LocalDateTime startDatetime = null;
LocalDateTime startDatetime = semesterModel.getStartDatetime(); LocalDateTime endDatetime = null;
LocalDateTime endDatetime = semesterModel.getEndDatetime(); String academicYearId = null;
if(timeRangeDto.getStartTime() != null) {
startDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getStartTime()), ZoneId.systemDefault());
endDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getEndTime()), ZoneId.systemDefault());
academicYearId = timeRangeDto.getAcademicYearId();
}else {
academicYearId = semesterModel.getAcademicYearId();
startDatetime = semesterModel.getStartDatetime();
endDatetime = semesterModel.getEndDatetime();
}
if (startDatetime == null || endDatetime == null) throw new ServiceException(ErrorCode.PARAMS_ERROR); if (startDatetime == null || endDatetime == null) throw new ServiceException(ErrorCode.PARAMS_ERROR);
long totalWeek = calculateWeekNum(startDatetime, endDatetime, null); long totalWeek = calculateWeekNum(startDatetime, endDatetime, null);

@ -33,8 +33,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -67,12 +69,12 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
}*/ }*/
@Override @Override
public DutyIndexData getIndexData(String periodId) { public DutyIndexData getIndexData(TimeRangeDto timeRangeDto) {
User loginUser = SecurityUtil.getLoginUser(); User loginUser = SecurityUtil.getLoginUser();
String schoolId = loginUser.getSchoolId(); String schoolId = loginUser.getSchoolId();
final int SLICE_SIZE = 100; final int SLICE_SIZE = 100;
if (StringUtils.isBlank(periodId)) { if (StringUtils.isBlank(timeRangeDto.getPeriodId())) {
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不能为空"); throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不能为空");
} }
final DutyIndexData DutyIndexData = new DutyIndexData(); final DutyIndexData DutyIndexData = new DutyIndexData();
@ -83,11 +85,21 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
Set<String> classIdSet = new HashSet<>(); Set<String> classIdSet = new HashSet<>();
// 获取学期起止时间 // 获取学期起止时间
List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, periodId); List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, timeRangeDto.getPeriodId());
SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now()); SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now());
String academicYearId = semesterModel.getAcademicYearId(); LocalDateTime startDatetime = null;
LocalDateTime startDatetime = semesterModel.getStartDatetime(); LocalDateTime endDatetime = null;
LocalDateTime endDatetime = semesterModel.getEndDatetime(); String academicYearId = null;
if(timeRangeDto.getStartTime() != null) {
startDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getStartTime()), ZoneId.systemDefault());
endDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getEndTime()), ZoneId.systemDefault());
academicYearId = timeRangeDto.getAcademicYearId();
}else {
academicYearId = semesterModel.getAcademicYearId();
startDatetime = semesterModel.getStartDatetime();
endDatetime = semesterModel.getEndDatetime();
}
if (startDatetime == null || endDatetime == null) throw new ServiceException(ErrorCode.PARAMS_ERROR); if (startDatetime == null || endDatetime == null) throw new ServiceException(ErrorCode.PARAMS_ERROR);
long totalWeek = calculateWeekNum(startDatetime, endDatetime, null); long totalWeek = calculateWeekNum(startDatetime, endDatetime, null);

@ -12,6 +12,7 @@ public class TimeRangeDto {
private Long startTime; private Long startTime;
private Long endTime; private Long endTime;
@NotNull @NotNull
private String periodId;
// todo: 似乎不需要(有时间范围就不需要这个字段来划分时间,如果不传时间那就需要) // todo: 似乎不需要(有时间范围就不需要这个字段来划分时间,如果不传时间那就需要)
private String academicYearId; private String academicYearId;
} }

Loading…
Cancel
Save