@RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,XueshengjianliEntity xueshengjianli, HttpServletRequest request){ String tableName = request.getSession().getAttribute("tableName").toString(); if(tableName.equals("xuesheng")) { xueshengjianli.setXuehao((String)request.getSession().getAttribute("username")); } EntityWrapper<XueshengjianliEntity> ew = new EntityWrapper<XueshengjianliEntity>(); PageUtils page = xueshengjianliService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xueshengjianli), params), params)); return R.ok().put("data", page); }
时间: 2024-04-27 13:22:41 浏览: 22
这是一个分页查询方法,使用了Spring框架的注解。该方法接受一个Map类型的参数params,用于封装分页和排序条件,同时还接受一个XueshengjianliEntity类型的参数xueshengjianli,用于封装查询条件。在方法中,首先从当前Session中获取表名,如果是学生表,则将当前登录的学生的学号设置为查询条件的xuehao属性。接着创建一个EntityWrapper对象,用于构建查询条件。然后调用MPUtil.likeOrEq方法生成模糊查询和精确查询条件,再调用MPUtil.between方法生成介于查询条件,最后调用MPUtil.sort方法生成排序条件。接着调用xueshengjianliService的queryPage方法执行分页查询操作,该方法会返回一个PageUtils对象,包含查询结果和分页信息。最后返回一个表示操作成功的R对象,并将查询结果放入data字段中。
相关问题
/** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,YuyuekanfangEntity yuyuekanfang, HttpServletRequest request){ String tableName = request.getSession().getAttribute("tableName").toString(); if(tableName.equals("yonghu")) { yuyuekanfang.setYonghuming((String)request.getSession().getAttribute("username")); } EntityWrapper<YuyuekanfangEntity> ew = new EntityWrapper<YuyuekanfangEntity>(); PageUtils page = yuyuekanfangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yuyuekanfang), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,YuyuekanfangEntity yuyuekanfang, HttpServletRequest request){ EntityWrapper<YuyuekanfangEntity> ew = new EntityWrapper<YuyuekanfangEntity>(); PageUtils page = yuyuekanfangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yuyuekanfang), params), params)); return R.ok().put("data", page); }
这段代码是一个基于Spring框架的Java Web项目的控制器类中的两个请求映射方法。第一个方法用于后端列表展示,接受一个Map类型的参数params、一个YuyuekanfangEntity类型的参数yuyuekanfang和一个HttpServletRequest类型的参数request,返回一个包含分页数据的R对象。其中YuyuekanfangEntity是一个实体类,用于封装预约看房信息,EntityWrapper是Mybatis-Plus框架提供的实体类包装器,MPUtil是一个工具类,用于封装Mybatis-Plus的查询条件。
第二个方法用于前端列表展示,接受与第一个方法相同的参数,返回一个包含分页数据的R对象。
解释一下下面代码:@RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,ShangpindaimaiEntity shangpindaimai, HttpServletRequest request){ String tableName = request.getSession().getAttribute("tableName").toString(); if(tableName.equals("yonghu")) { shangpindaimai.setYonghuming((String)request.getSession().getAttribute("username")); } EntityWrapper<ShangpindaimaiEntity> ew = new EntityWrapper<ShangpindaimaiEntity>(); PageUtils page = shangpindaimaiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpindaimai), params), params)); return R.ok().put("data", page); } /** * 前端列表 / @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ShangpindaimaiEntity shangpindaimai, HttpServletRequest request){ EntityWrapper<ShangpindaimaiEntity> ew = new EntityWrapper<ShangpindaimaiEntity>(); PageUtils page = shangpindaimaiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpindaimai), params), params)); return R.ok().put("data", page); } /* * 列表 */ @RequestMapping("/lists") public R list( ShangpindaimaiEntity shangpindaimai){ EntityWrapper<ShangpindaimaiEntity> ew = new EntityWrapper<ShangpindaimaiEntity>(); ew.allEq(MPUtil.allEQMapPre( shangpindaimai, "shangpindaimai")); return R.ok().put("data", shangpindaimaiService.selectListView(ew)); }
这段代码是一个 Java Web 的控制器,包含了三个方法用于处理不同的请求。
第一个方法是 @RequestMapping("/page"),用于处理页面请求,主要功能是查询商品代卖相关的数据,并返回一个分页数据。其中,通过 request.getSession().getAttribute("tableName") 获取了一个表名,如果表名是 yonghu,则从 session 中获取用户名并将其赋值给 shangpindaimai 对象的 Yonghuming 属性。然后通过 shangpindaimaiService.queryPage 方法调用查询数据,并返回一个封装好的 PageUtils 对象。
第二个方法是 @RequestMapping("/list"),用于查询商品代卖相关的数据,并返回一个封装好的 PageUtils 对象。
第三个方法是 @RequestMapping("/lists"),用于查询商品代卖相关的数据,并返回一个封装好的集合对象。其中,通过 EntityWrapper<ShangpindaimaiEntity> ew 指定了查询条件,然后通过 shangpindaimaiService.selectListView 方法调用查询数据,并返回一个封装好的集合。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)