发表于: 2019-08-29 21:52:04
1 645
今天完成的事情:
继续和前端调接口
新增角色权限接口、账户编辑角色下拉框接口
/** 角色权限 */
@RequestMapping(value = "/a/u/role/{roleId}", method = RequestMethod.GET)
public String updateRole(@PathVariable(value = "roleId") Long roleId, ModelMap model)
throws Exception {
log.info("post role : roleId========" + roleId);
try {
Role role = roleService.getObjectById(roleId);
log.info("get manager data====" + role);
if (DataUtils.isNotNullOrEmpty(role)) {
String module = role.getModule();
model.addAttribute("code", 0);
log.info("查看角色权限成功");
model.addAttribute("module", module);
} else {
model.addAttribute("code", -7002);
return "/data/json";
}
} catch (Throwable e) {
e.printStackTrace();
log.error(e.getMessage());
model.addAttribute("code", -100000);
}
return "/role/json/roleDetailJson";
}
/** 角色下拉框 */
@RequestMapping(value = "/a/u/role", method = RequestMethod.GET)
public String getRole(ModelMap model) throws Exception {
log.info("get role name =================");
try {
Map<String, Object> params = SqlUtil.getRole();
log.info("params===================" + params);
List<Long> Ids =
roleService.getIdsByDynamicCondition(Role.class, params, 0, Integer.MAX_VALUE);
log.info("Ids==========" + Ids);
List<Role> roles = roleService.getObjectsByIds(Ids);
log.info("role===================" + roles.toString());
model.addAttribute("roles", roles);
model.addAttribute("code", 0);
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
model.addAttribute("code", -10000);
return "/data/json";
}
return "/role/json/roleName";
}
使用stream List转Map
Map<Long, User> map =
userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
防止出现key一样的情况,可以加一种覆盖规则,使用这种方式
Map<Long, Course> map =
courseList.stream()
.collect(Collectors.toMap(Course::getId, Function.identity(), (key1, key2) ->
key2));
明天计划的事情:
继续复习
看面试题
遇到的问题:
收获:
以上
评论