调整返回内容

develop
zhouj1203@hotmail.com 4 months ago
parent 7ddcf2aed5
commit 26e7574eec

@ -3,19 +3,24 @@ package cn.teammodel.controller.admin.service.impl;
import cn.teammodel.common.ErrorCode; import cn.teammodel.common.ErrorCode;
import cn.teammodel.config.exception.ServiceException; import cn.teammodel.config.exception.ServiceException;
import cn.teammodel.controller.admin.service.ExamService; import cn.teammodel.controller.admin.service.ExamService;
import cn.teammodel.model.dto.admin.exam.BlobSasDto;
import cn.teammodel.model.dto.admin.exam.OverViewDto; import cn.teammodel.model.dto.admin.exam.OverViewDto;
import cn.teammodel.model.entity.school.School;
import cn.teammodel.repository.SchoolRepository;
import cn.teammodel.utils.GroupUtil; import cn.teammodel.utils.GroupUtil;
import com.azure.cosmos.models.PartitionKey;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.*; import java.util.*;
@Service @Service
public class ExamServiceImpl implements ExamService { public class ExamServiceImpl implements ExamService {
@Resource
private SchoolRepository schoolRepository;
@Autowired @Autowired
private Environment env; private Environment env;
@Override @Override
@ -26,11 +31,17 @@ public class ExamServiceImpl implements ExamService {
String url = env.getProperty("ies.server-url-overview"); String url = env.getProperty("ies.server-url-overview");
String url_exam = env.getProperty("ies.server-url-exam-rate"); String url_exam = env.getProperty("ies.server-url-exam-rate");
try { try {
Optional<School> school = schoolRepository.findById(overViewDto.getSchool(), new PartitionKey("Base"));
overView = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url); overView = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url);
examRate = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url_exam); examRate = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url_exam);
//SnowflakeIdGenerator generator = new SnowflakeIdGenerator(1); //SnowflakeIdGenerator generator = new SnowflakeIdGenerator(1);
//overView.put("reportId",generator.nextId()); //overView.put("reportId",generator.nextId());
overView.putAll(examRate); overView.putAll(examRate);
school.ifPresent(value -> overView.put("schoolName", value.getName()));
school.flatMap(value -> value.getPeriod().stream().filter(period ->
period.getId().equals(overViewDto.getPeriodId())).findFirst()).ifPresent(value1 ->
overView.put("semesters", value1.getSemesters()));
//获取所有考试数据 //获取所有考试数据
//List<Exam> exams = examRepository.findExamByClassId("Exam-"+overViewDto.getSchool(),overViewDto.getClassId(),overViewDto.getPeriodId()); //List<Exam> exams = examRepository.findExamByClassId("Exam-"+overViewDto.getSchool(),overViewDto.getClassId(),overViewDto.getPeriodId());

@ -23,6 +23,8 @@ public interface SchoolRepository extends CosmosRepository<School, String> {
List<School.Semester> findSemestersById(@Param("schoolId") String schoolId, @Param("periodId") String periodId); List<School.Semester> findSemestersById(@Param("schoolId") String schoolId, @Param("periodId") String periodId);
@Query("select value p.subjects from School as s join p in s.period where s.id = @schoolId and s.code = 'Base' and p.id = @periodId") @Query("select value p.subjects from School as s join p in s.period where s.id = @schoolId and s.code = 'Base' and p.id = @periodId")
List<School.Subject> findSubjectById(@Param("schoolId") String schoolId, @Param("periodId") String periodId); List<School.Subject> findSubjectById(@Param("schoolId") String schoolId, @Param("periodId") String periodId);
@Query("select * from School as s where s.id = @schoolId and s.code = 'Base' ")
List<School> findBaseById(@Param("schoolId") String schoolId);
School findSchoolByIdAndCode(String schoolId, String code); School findSchoolByIdAndCode(String schoolId, String code);
} }

Loading…
Cancel
Save