依据学生id和姓名获取四级成绩 #1

Merged
Cool merged 3 commits from YuNan/CET-cmd-2.0:dev into dev 2024-09-09 21:40:07 +08:00
4 changed files with 67 additions and 4 deletions

View File

@ -3,6 +3,9 @@ package org.jeecg.modules.controller;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
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.system.query.QueryGenerator;
import org.jeecg.modules.entity.Cet_4;
@ -36,6 +39,9 @@ public class Cet_4Controller extends JeecgController<Cet_4, ICet_4Service> {
@Autowired
private ICet_4Service cet_4Service;
/**
* 分页列表查询
*
@ -160,4 +166,12 @@ public class Cet_4Controller extends JeecgController<Cet_4, ICet_4Service> {
return super.importExcel(request, response, Cet_4.class);
}
/**
* 依据学生id和姓名获取四级成绩
*/
@GetMapping("/getDataByStudent")
public Result<JSONObject> getDataByStudent(@RequestBody JSONObject jsonObject){
return cet_4Service.getDataByStudent(jsonObject);
}
}

View File

@ -22,5 +22,7 @@ public interface ICet_4Service extends IService<Cet_4> {
Result<JSONObject> getRateByCollege(JSONObject webData);
Result<JSONObject> getRateByMajor(JSONObject webData);
Result<JSONObject> getDataByStudent(JSONObject jsonObject);
boolean cleanData();
}

View File

@ -553,12 +553,32 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
return remove(cet4Wrapper);
}
/**
* 依据学生id和姓名获取四级数据
*/
@Override
public Result<JSONObject> getDataByStudent(JSONObject jsonObject) {
String name = jsonObject.getString("name");
Integer id = jsonObject.getInteger("id");
if (name == null || id == null) {
return Result.error("请填写完整的参数");
}
JSONObject result = new JSONObject();
LambdaQueryWrapper<Cet_4> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Cet_4::getName, name)
.eq(Cet_4::getId, id);
List<Cet_4> list = list(wrapper);
result.put("results", list);
return Result.ok(result);
}
//获取全校人数
private long getNumAll(Date batch) {
LambdaQueryWrapper<Cet_4> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Cet_4::getBatch, batch);
return cet4Mapper.selectCount(queryWrapper);
}
//获取学院的人数
private long getNumCollege(String college, Date batch) {
LambdaQueryWrapper<Cet_4> queryWrapper = new LambdaQueryWrapper<>();

View File

@ -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);
}
}