Commit a556a2b1 authored by Mindfaker's avatar Mindfaker

fix

parent 244590fd
......@@ -20,6 +20,21 @@ public class ClassService {
@Resource
ClassInfoMapper classInfoMapper;
public Map<Integer, String> getClassNameMap() {
ClassInfoExample example = new ClassInfoExample();
ClassInfoExample.Criteria criteria = example.createCriteria();
criteria.andDeletedEqualTo(false);
List<ClassInfo> dataList = classInfoMapper.selectByExample(example);
return dataList.stream().map(x -> {
Map oneData = new HashMap();
oneData.put(x.getId(), x.getClassName());
return oneData;
}).reduce(new HashMap(), (x, y) -> {
x.putAll(y);
return x;
});
}
public List<ClassInfo> selectClass(String className, List<Integer> idList) {
ClassInfoExample example = new ClassInfoExample();
ClassInfoExample.Criteria criteria = example.createCriteria();
......
......@@ -4,6 +4,7 @@ import cn.exploring.engine.server.db.dao.SpecialSqlMapper;
import cn.exploring.engine.server.db.dao.StudentInfoMapper;
import cn.exploring.engine.server.db.domain.StudentInfo;
import cn.exploring.engine.server.db.domain.StudentInfoExample;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
......@@ -14,6 +15,7 @@ import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class StudentInfoService {
......@@ -21,6 +23,9 @@ public class StudentInfoService {
@Resource
StudentInfoMapper studentInfoMapper;
@Resource
ClassService classService;
@Resource
SpecialSqlMapper specialSqlMapper;
......@@ -120,10 +125,16 @@ public class StudentInfoService {
PageHelper.startPage(page, limit);
example.setOrderByClause(sort + " " + order);
List<StudentInfo> studentInfoList = studentInfoMapper.selectByExample(example);
Map<Integer, String> classMap = classService.getClassNameMap();
List<Map> dataList = studentInfoList.stream().map(x -> {
Map oneData = JSON.parseObject(JSON.toJSONString(x), Map.class);
oneData.put("className", classMap.get(classId));
return oneData;
}).collect(Collectors.toList());
Long total = PageInfo.of(studentInfoList).getTotal();
return new HashMap(){{
put("total", total);
put("items", studentInfoList);
put("items", dataList);
}};
}
......
......@@ -30,7 +30,7 @@ public class StudentController {
return ResponseUtil.ok(studentInfoService.selectStudentInfo(classId));
}
@GetMapping("add")
@PostMapping("add")
public Object add(@RequestBody StudentInfo studentInfo) {
String status = studentInfoService.addStudentInfo(studentInfo);
return status.contains("OK") ? ResponseUtil.ok(status) : ResponseUtil.fail(502, status);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment