use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.
the class RoleController method pageInfo.
@PostMapping("/roles")
@ApiOperation(value = "分页获取角色信息接口")
@LogAnnotation(title = "角色管理", action = "分页获取角色信息")
@RequiresPermissions("sys:role:list")
@SuppressWarnings("unchecked")
public DataResult pageInfo(@RequestBody SysRole vo) {
Page page = new Page(vo.getPage(), vo.getLimit());
LambdaQueryWrapper<SysRole> queryWrapper = Wrappers.lambdaQuery();
if (!StringUtils.isEmpty(vo.getName())) {
queryWrapper.like(SysRole::getName, vo.getName());
}
if (!StringUtils.isEmpty(vo.getStartTime())) {
queryWrapper.gt(SysRole::getCreateTime, vo.getStartTime());
}
if (!StringUtils.isEmpty(vo.getEndTime())) {
queryWrapper.lt(SysRole::getCreateTime, vo.getEndTime());
}
if (!StringUtils.isEmpty(vo.getStatus())) {
queryWrapper.eq(SysRole::getStatus, vo.getStatus());
}
queryWrapper.orderByDesc(SysRole::getCreateTime);
return DataResult.success(roleService.page(page, queryWrapper));
}
use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.
the class RoleController method bindDept.
@PostMapping("/role/bindDept")
@ApiOperation(value = "绑定角色部门接口")
@LogAnnotation(title = "角色管理", action = "绑定角色部门信息")
@RequiresPermissions("sys:role:bindDept")
public DataResult bindDept(@RequestBody SysRole vo) {
if (StringUtils.isEmpty(vo.getId())) {
return DataResult.fail("id不能为空");
}
if (roleService.getById(vo.getId()) == null) {
return DataResult.fail("获取角色失败");
}
// 先删除所有绑定
sysRoleDeptService.remove(Wrappers.<SysRoleDeptEntity>lambdaQuery().eq(SysRoleDeptEntity::getRoleId, vo.getId()));
// 如果不是自定义
if (vo.getDataScope() != 2) {
vo.setDepts(null);
}
if (!CollectionUtils.isEmpty(vo.getDepts())) {
List<SysRoleDeptEntity> list = new ArrayList<>();
for (String deptId : vo.getDepts()) {
SysRoleDeptEntity sysRoleDeptEntity = new SysRoleDeptEntity();
sysRoleDeptEntity.setDeptId(deptId);
sysRoleDeptEntity.setRoleId(vo.getId());
list.add(sysRoleDeptEntity);
}
sysRoleDeptService.saveBatch(list);
}
roleService.updateById(new SysRole().setId(vo.getId()).setDataScope(vo.getDataScope()));
return DataResult.success();
}
Aggregations