@RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<FufeiziliaoEntity> wrapper = new EntityWrapper<FufeiziliaoEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = fufeiziliaoService.selectCount(wrapper); return R.ok().put("count", count); }
时间: 2024-03-04 17:52:08 浏览: 198
SpringMVC@RequestMapping(重点)@RequestParam@PathVariable示例
这段代码是一个Java Spring Boot中的Controller方法,它接受一个带有PathVariable和RequestParam的HTTP GET请求,并返回一个包含计数结果的JSON格式的响应。其中,@PathVariable注解用于获取URL中的路径参数,@RequestParam注解用于获取URL中的查询参数。在方法中,根据传入的参数设置查询条件,然后使用EntityWrapper对数据库进行查询,最后通过R.ok()方法将查询结果封装成JSON响应返回给前端。
阅读全文