use of com.codingmore.model.Role in project coding-more by itwanger.
the class RoleController method create.
@ApiOperation("添加角色")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public ResultObject<String> create(@Valid RoleParam roleParam) {
if (roleParam.getCreateTime() == null) {
roleParam.setCreateTime(new Date());
}
if (roleParam.getStatus() != 0 && roleParam.getStatus() != 1) {
return ResultObject.failed("状态不合法");
}
Role role = new Role();
BeanUtils.copyProperties(roleParam, role);
return ResultObject.success(roleService.save(role) ? "添加成功" : "添加失败");
}
use of com.codingmore.model.Role in project coding-more by itwanger.
the class RoleController method update.
@ApiOperation("修改角色")
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public ResultObject<String> update(@Valid RoleParam roleParam) {
if (roleParam.getStatus() != 0 && roleParam.getStatus() != 1) {
return ResultObject.failed("状态不合法");
}
if (roleParam.getRoleId() == null) {
return ResultObject.failed("角色id不能为空");
}
Role role = roleService.getById(roleParam.getRoleId());
BeanUtils.copyProperties(roleParam, role);
return ResultObject.success(roleService.updateById(role) ? "修改成功" : "修改失败");
}
use of com.codingmore.model.Role in project coding-more by itwanger.
the class RoleController method updateStatus.
@ApiOperation("修改角色状态")
@RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
@ResponseBody
public ResultObject updateStatus(@RequestParam(value = "id") Long id, @RequestParam(value = "status") Integer status) {
if (status != 0 && status != 1) {
return ResultObject.failed("状态不合法");
}
Role role = roleService.getById(id);
if (role == null) {
return ResultObject.failed("角色不存在");
}
role.setStatus(status);
return ResultObject.success(roleService.updateById(role) ? "修改成功" : "修改失败");
}
use of com.codingmore.model.Role in project coding-more by itwanger.
the class UsersController method getAdminInfo.
@ApiOperation(value = "获取当前登录用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ResponseBody
public ResultObject getAdminInfo(Principal principal) {
if (principal == null) {
return ResultObject.unauthorized(null);
}
AdminUserDetails adminUserDetails = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Users user = adminUserDetails.getUsers();
// ?
user.setUserPass(null);
Map<String, Object> data = new HashMap<>();
data.put("userDetail", adminUserDetails.getUsers());
data.put("username", user.getUserLogin());
data.put("menus", roleService.getMenuList(user.getUsersId()));
data.put("icon", user.getDisplayName());
List<Role> roleList = usersService.getRoleList(user.getUsersId());
if (CollUtil.isNotEmpty(roleList)) {
List<String> roles = roleList.stream().map(Role::getName).collect(Collectors.toList());
data.put("roles", roles);
}
return ResultObject.success(data);
}
Aggregations