Search in sources :

Example 11 with LogAnnotation

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));
}
Also used : SysRole(com.company.project.entity.SysRole) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) LogAnnotation(com.company.project.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 12 with LogAnnotation

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();
}
Also used : ArrayList(java.util.ArrayList) SysRole(com.company.project.entity.SysRole) SysRoleDeptEntity(com.company.project.entity.SysRoleDeptEntity) LogAnnotation(com.company.project.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

LogAnnotation (com.company.project.common.aop.annotation.LogAnnotation)12 ApiOperation (io.swagger.annotations.ApiOperation)11 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)10 DataResult (com.company.project.common.utils.DataResult)3 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)2 SysLog (com.company.project.entity.SysLog)2 SysRole (com.company.project.entity.SysRole)2 ArrayList (java.util.ArrayList)2 BusinessException (com.company.project.common.exception.BusinessException)1 SysDept (com.company.project.entity.SysDept)1 SysPermission (com.company.project.entity.SysPermission)1 SysRoleDeptEntity (com.company.project.entity.SysRoleDeptEntity)1 SysUserRole (com.company.project.entity.SysUserRole)1 UserRoleOperationReqVO (com.company.project.vo.req.UserRoleOperationReqVO)1 Method (java.lang.reflect.Method)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Subject (org.apache.shiro.subject.Subject)1