更新参数传递方式,调整参数解析内容,新增工具类,新增条件Dto

11111
zhouj1203@hotmail.com 5 months ago
parent a801724b75
commit db6c7d402f

@ -73,8 +73,8 @@ public class AdminDutyController {
} }
@PostMapping("getLessonRecord") @PostMapping("getLessonRecord")
@ApiOperation("获取课堂记录") @ApiOperation("获取课堂记录")
public R<Map<String, Object> > appraiseNodeRank(@Valid @RequestBody Map<String, Object> map , HttpServletRequest request) { public R<Map<String, Object> > appraiseNodeRank(@Valid @RequestBody LessonRecordDto lessonRecordDto , HttpServletRequest request) {
Map<String, Object> res = adminIndexDutyService.getLessonRecord(map,request); Map<String, Object> res = adminIndexDutyService.getLessonRecord(lessonRecordDto,request);
return R.success(res); return R.success(res);
} }
} }

@ -24,6 +24,6 @@ public interface AdminIndexDutyService {
List<DutyNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto); List<DutyNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto);
Map<String, Object> getLessonRecord (Map<String, Object> map, HttpServletRequest request); Map<String, Object> getLessonRecord (LessonRecordDto lessonRecordDto, HttpServletRequest request);
} }

@ -21,6 +21,7 @@ import cn.teammodel.repository.DutyRecordRepository;
import cn.teammodel.repository.SchoolRepository; import cn.teammodel.repository.SchoolRepository;
import cn.teammodel.repository.TeacherRepository; import cn.teammodel.repository.TeacherRepository;
import cn.teammodel.security.utils.SecurityUtil; import cn.teammodel.security.utils.SecurityUtil;
import cn.teammodel.utils.JsonUtil;
import cn.teammodel.utils.SchoolDateUtil; import cn.teammodel.utils.SchoolDateUtil;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest; import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -73,13 +74,13 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
private ClassRepository classRepository; private ClassRepository classRepository;
@Resource @Resource
private DutyRecordRepository dutyRecordRepository; private DutyRecordRepository dutyRecordRepository;
private final Environment env;
@Autowired @Autowired
private Environment env;
/* @Autowired
public AdminIndexDutyServiceImpl(Environment env) { public AdminIndexDutyServiceImpl(Environment env) {
this.env = env; this.env = env;
} }*/
@Override @Override
public DutyIndexData getIndexData(String periodId) { public DutyIndexData getIndexData(String periodId) {
@ -224,7 +225,7 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
} }
@Override @Override
public Map<String, Object> getLessonRecord(Map<String, Object> map, HttpServletRequest request) { public Map<String, Object> getLessonRecord(LessonRecordDto lessonRecordDto, HttpServletRequest request) {
Map<String, Object> mapper = new HashMap<>(); Map<String, Object> mapper = new HashMap<>();
String apiUrl = env.getProperty("ies.server-url"); String apiUrl = env.getProperty("ies.server-url");
@ -240,8 +241,9 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
httpPost.setHeader("Content-Type", "application/json; charset=utf-8"); httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
// 设置请求体 // 设置请求体
JsonUtil.convertToJson(lessonRecordDto);
//String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId); //String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId);
httpPost.setEntity(new StringEntity(new Gson().toJson(map))); httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(lessonRecordDto)));
// 发送请求 // 发送请求
try (CloseableHttpResponse response = httpClient.execute(httpPost)) { try (CloseableHttpResponse response = httpClient.execute(httpPost)) {

@ -2,14 +2,26 @@ package cn.teammodel.model.dto.weekDuty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
@Data @Data
public class LessonRecordDto { public class LessonRecordDto {
private String code; private String tmdid;
private String scope;
private String school;
private String name; private String name;
private String periodId; private String periodId;
private Long startTime; private Long stime;
private Long endTime; private Long etime;
private String Authorization; private ArrayList<String> category;
private String AuthToken; private ArrayList<String> subjectId;
private ArrayList<String> grade;
private boolean doubleGreen = false;
private boolean singleGreen = false;
private boolean isOk = false;
private boolean quality = false;
private String DESC = "startTime";
private int pageCount;
private String continuationToken; private String continuationToken;
private boolean managePage = true;
} }

@ -0,0 +1,22 @@
package cn.teammodel.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
/**
* Converts an object to a JSON string.
*
* @param obj The object to be converted.
* @return The JSON string representation of the object.
*/
public static String convertToJson(Object obj) {
try {
return objectMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new RuntimeException("Failed to convert object to JSON", e);
}
}
}
Loading…
Cancel
Save