public Map<String, Object> getCourseChoiceList(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@RequestParam(defaultValue="1") int isAll,
@RequestParam(defaultValue="")String searchKey) throws Exception {
Map<String, Object> map = new HashMap<>();
EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
String username = easUser.getUsername();
EasStudent easStudent = easStudentService.getStudentByUsername(username);
if (easStudent.getUsername() == null || easStudent.getUsername().equals("")){
map.put("code",1);
map.put("msg","目前还没有选课信息");
}else{
PageUtil pageUtil = new PageUtil(page,limit);
int sId = easStudent.getId();
int count = easCourseService.getTotalItemsCountBySid(isAll, searchKey, sId);
List<EasCourse> list = easCourseService.getCourseListBySid(isAll, searchKey, sId,pageUtil);
map.put("count",count);
map.put("data",list);
map.put("code",0);
map.put("msg","");
}
return map;
}
根据Security框架获取登录者信息,然后根据登陆者username获取easStudent 信息,如果easStudent的username为空,提示“目前还没有选课信息”返回map,如果不为空根据easStudent的id去查询EasCourse,把查询的数据数量放入map的count中,把查询的数据放入map的data中,最后返回map信息
Executors各个方法的弊端:
1)newFixedThreadPool和newSingleThreadExecutor:
主要问题是堆积的请求处理队列可能会耗费非常大的内存,甚至OOM。
2)newCachedThreadPool和newScheduledThreadPool:
主要问题是线程数最大数是Integer.MAX_VALUE,可能会创建数量非常多的线程,甚至OOM。
我可以提供一段简单的Java代码,用于计算一元多项式的值。该代码实现的功能是通过传入一个double类型的自变量x和一组double类型的系数,计算出多项式的值。
double polynomial(double x, double[] coefficients) { double result = 0; for (int i = 0; i <= coefficients.length - 1; i++) { result += coefficients[i] * Math.pow(x, i); } return result; }
该函数接受两个参数,第一个参数是double类型的自变量x,第二个参数是double类型的系数数组coefficients。函数首先初始化多项式的值为0,然后通过for循环遍历系数数组coefficients,并使用Math.pow(x, i)函数计算出x的i次方,然后将其乘以该系数并加到多项式的值中。最后返回计算结果。
这段代码的用途非常广泛,可以在计算机科学、数学、工程等领域的各种计算中使用。其中一个应用是在图形图像处理中,可以使用多项式函数来拟合数据,实现曲线拟合等功能。