@RequestMapping("/page") public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); String role = String.valueOf(request.getSession().getAttribute("role")); if(false) return R.error(511,"永不会进入"); else if("老师".equals(role)){ params.put("laoshiId",request.getSession().getAttribute("userId")); LaoshiEntity laoshiEntity = laoshiService.selectById(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); if(laoshiEntity == null) return R.error("查不到登录的老师"); params.put("yuanxiTypes", laoshiEntity.getYuanxiTypes()); } if(params.get("orderBy")==null || params.get("orderBy")==""){ params.put("orderBy","id"); } PageUtils page = banjiService.queryPage(params); //字典表数据转换 List<BanjiView> list =(List<BanjiView>)page.getList(); for(BanjiView c:list){ //修改对应字典表字段 dictionaryService.dictionaryConvert(c, request); } return R.ok().put("data", page); }把这段代码改为不需要验证身份
时间: 2024-01-28 12:05:31 浏览: 34
可以将以下代码删除或注释掉,即可实现不需要验证身份:
```
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("老师".equals(role)){
params.put("laoshiId",request.getSession().getAttribute("userId"));
LaoshiEntity laoshiEntity = laoshiService.selectById(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
if(laoshiEntity == null)
return R.error("查不到登录的老师");
params.put("yuanxiTypes", laoshiEntity.getYuanxiTypes());
}
```
相关问题
public R page(@RequestParam Map<String, Object> params,ChuxiaodengjiEntity chuxiaodengji, HttpServletRequest request)
这是一个Java Spring Boot应用程序中的一个Controller类的方法,使用了RequestMapping和RequestParam注解来接收请求参数。其中,@RequestParam注解用于指定该方法的params参数来自于请求参数中的Map类型的字段,@PathVariable("id")注解用于指定该方法的chuxiaodengji参数来自于请求路径中的占位符。此外,该方法还接收了一个HttpServletRequest参数,用于获取请求对象。
在该方法中,首先构建了一个EntityWrapper对象ew,然后使用MPUtil工具类对查询条件进行了构建,最终调用了chuxiaodengjiService的queryPage方法来查询符合条件的数据,并将结果封装在一个PageUtils对象中。最后将该PageUtils对象封装在一个R对象中,并返回给前端。R对象可能是自定义的响应类,用于封装返回给前端的数据。
public R list(@RequestParam Map<String, Object> params,BaoxiuxinxiEntity baoxiuxinxi, HttpServletRequest request)
这是一个 Java 方法,方法名为 `list`,返回值类型为 `R`。该方法接收三个参数:
- `params`:类型为 `Map<String, Object>`,用于接收查询参数。
- `baoxiuxinxi`:类型为 `BaoxiuxinxiEntity`,表示一个维修信息实体类,用于接收查询参数。
- `request`:类型为 `HttpServletRequest`,表示一个 HTTP 请求对象。
该方法主要用于查询维修信息列表,并返回一个 `R` 类型的响应结果。其中,`@RequestParam` 注解用于将查询参数绑定到 `params` 参数上,`@RequestBody` 注解用于将 POST 请求体绑定到 `baoxiuxinxi` 参数上。
下面是一个示例代码:
```java
@RestController
@RequestMapping("/baoxiu")
public class BaoxiuController {
@Autowired
private BaoxiuService baoxiuService;
@GetMapping("/list")
public R list(@RequestParam Map<String, Object> params, BaoxiuxinxiEntity baoxiuxinxi, HttpServletRequest request) {
QueryWrapper<BaoxiuxinxiEntity> wrapper = new QueryWrapper<>(baoxiuxinxi);
wrapper.allEq(params);
PageUtils page = baoxiuService.queryPage(params, wrapper);
return R.ok().put("page", page);
}
// 其他方法省略...
}
```
在上面的示例代码中,使用 `@GetMapping` 注解标识处理 HTTP GET 请求的方法,请求路径为 `/baoxiu/list`。在方法中,首先创建一个 `QueryWrapper` 对象,将 `baoxiuxinxi` 参数传入其中,然后使用 `wrapper.allEq(params)` 方法将查询参数绑定到查询条件中。最后调用 `baoxiuService.queryPage` 方法查询维修信息列表,并将查询结果封装为一个 `PageUtils` 对象返回。