if(tableName.equals("yonghu")) { tijiananpai.setYonghuming((String)request.getSession().getAttribute("username")); }
时间: 2024-06-02 08:11:27 浏览: 7
这段代码的意思是,如果传入的表名为"yonghu",那么就将体检安排对象(tijiananpai)的“用户名称”(Yonghuming)属性设置为当前请求(request)中保存的session中的“username”属性值。换句话说,这段代码是根据传入的表名来设置体检安排对象的用户名称属性,以便后续操作可以使用该属性。
相关问题
/** * 后端列表 */ @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); }
这段代码是一个后端控制器的方法,用于处理后端页面的分页请求。它的路由是“/page”,并且接受两个参数:params和yuyuekanfang。其中params是一个Map类型的参数,用于传递分页参数;yuyuekanfang是一个YuyuekanfangEntity类型的参数,用于传递查询条件。在方法中,首先从会话中获取表名,如果表名是“yonghu”,则将当前用户的用户名设置为查询条件。然后使用Mybatis-Plus提供的Wrapper类构建查询条件,根据传入的分页参数和查询条件,调用yuyuekanfangService的queryPage方法进行查询,并将查询结果封装在一个PageUtils对象中返回。最后,将查询结果封装在一个R对象中,并返回给前端。
解释 public R page(@RequestParam Map<String, Object> params,BaoxiujinduEntity baoxiujindu, HttpServletRequest request){ String tableName = request.getSession().getAttribute("tableName").toString(); if(tableName.equals("yonghu")) { baoxiujindu.setGerenzhanghao((String)request.getSession().getAttribute("username")); } EntityWrapper<BaoxiujinduEntity> ew = new EntityWrapper<BaoxiujinduEntity>(); PageUtils page = baoxiujinduService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, baoxiujindu), params), params)); return R.ok().put("data", page); }
这段代码是一个Controller中的方法,主要实现的功能是查询并返回一个分页数据。
首先,从request中获取tableName属性,如果tableName等于"yonghu",则获取当前登录用户的用户名,并把它设置到baoxiujindu对象的gerenzhanghao属性中。
然后,创建一个EntityWrapper对象,用于构造查询条件。通过调用MPUtil类的likeOrEq方法、between方法和sort方法,将查询条件和排序方式组合成一个查询条件对象,并传递给baoxiujinduService的queryPage方法进行查询。queryPage方法会返回一个PageUtils对象,包含查询结果和分页信息。
最后,将查询结果封装成一个R对象返回,其中"data"属性对应的值为查询结果。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)
![](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)