依据学生id和姓名获取四级成绩
This commit is contained in:
parent
ceac91707d
commit
ad3f4c73eb
|
@ -3,6 +3,9 @@ package org.jeecg.modules.controller;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.modules.entity.Cet_4;
|
import org.jeecg.modules.entity.Cet_4;
|
||||||
|
@ -36,6 +39,9 @@ public class Cet_4Controller extends JeecgController<Cet_4, ICet_4Service> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICet_4Service cet_4Service;
|
private ICet_4Service cet_4Service;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
|
@ -160,4 +166,17 @@ public class Cet_4Controller extends JeecgController<Cet_4, ICet_4Service> {
|
||||||
return super.importExcel(request, response, Cet_4.class);
|
return super.importExcel(request, response, Cet_4.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依据学生id和姓名获取四级成绩
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDataByStudent")
|
||||||
|
public Result<JSONObject> getDataByStudent(@RequestParam("id") Integer id, @RequestParam("name") String name){
|
||||||
|
// 参数检查
|
||||||
|
if (id == null || name == null) {
|
||||||
|
return Result.error("ID 或姓名不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
return cet_4Service.getDataByStudent(id , name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,6 @@ public interface ICet_4Service extends IService<Cet_4> {
|
||||||
Result<JSONObject> getRateByCollege(JSONObject webData);
|
Result<JSONObject> getRateByCollege(JSONObject webData);
|
||||||
|
|
||||||
Result<JSONObject> getRateByMajor(JSONObject webData);
|
Result<JSONObject> getRateByMajor(JSONObject webData);
|
||||||
|
|
||||||
|
Result<JSONObject> getDataByStudent(Integer studentId, String studentName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,6 +536,37 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
|
||||||
return Result.ok(result);
|
return Result.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依据学生id和姓名获取四级数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<JSONObject> getDataByStudent(Integer id,String name) {
|
||||||
|
//判断是否存在缓存
|
||||||
|
String key = "getDataByStudent:"+id + name;
|
||||||
|
if (Boolean.TRUE.equals(redisTemplate.hasKey(key))) {
|
||||||
|
System.out.println((JSONObject) redisTemplate.opsForValue().get(key));
|
||||||
|
return Result.ok((JSONObject) redisTemplate.opsForValue().get(key));
|
||||||
|
}
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
//收集成绩
|
||||||
|
LambdaQueryWrapper<Cet_4> Cet_4ResultQW = new LambdaQueryWrapper<>();
|
||||||
|
Cet_4ResultQW.select(Cet_4::getResult)
|
||||||
|
.groupBy(Cet_4::getResult);
|
||||||
|
|
||||||
|
List<Map<String, Object>> Cet_4Result = cet4Mapper.selectMaps(Cet_4ResultQW);
|
||||||
|
if (Cet_4Result == null) {
|
||||||
|
return Result.error("查询结果为空");
|
||||||
|
}
|
||||||
|
System.out.println(Cet_4Result);
|
||||||
|
|
||||||
|
result.put("results", Cet_4Result);
|
||||||
|
|
||||||
|
//将数据存入缓存
|
||||||
|
redisTemplate.opsForValue().set(key, result);
|
||||||
|
|
||||||
|
return Result.ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
//获取全校人数
|
//获取全校人数
|
||||||
private long getNumAll(Date batch) {
|
private long getNumAll(Date batch) {
|
||||||
LambdaQueryWrapper<Cet_4> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Cet_4> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.jeecg.modules;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.jeecg.JeecgSystemApplication;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.controller.Cet_4Controller;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest(classes= JeecgSystemApplication.class)//指定要测试的Spring应用程序类
|
||||||
|
public class text {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Cet_4Controller cet_4Controller;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void T() {
|
||||||
|
// 检查 cet_4Controller 是否为 null
|
||||||
|
if (cet_4Controller == null) {
|
||||||
|
System.err.println("Cet_4Controller 未正确注入");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Result<JSONObject> result = cet_4Controller.getDataByStudent(2023011559, "余映婵");
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue