Search in sources :

Example 1 with LogAnnotation

use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.

the class SysJobController method update.

@ApiOperation(value = "更新")
@PutMapping("/update")
@RequiresPermissions("sysJob:update")
@LogAnnotation(title = "更新")
public DataResult update(@RequestBody SysJobEntity sysJob) {
    if (isValidExpression(sysJob.getCronExpression())) {
        return DataResult.fail("cron表达式有误");
    }
    DataResult dataResult = ScheduleJob.judgeBean(sysJob.getBeanName());
    if (BaseResponseCode.SUCCESS.getCode() != dataResult.getCode()) {
        return dataResult;
    }
    sysJobService.updateJobById(sysJob);
    return DataResult.success();
}
Also used : DataResult(com.company.project.common.utils.DataResult) LogAnnotation(com.company.project.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with LogAnnotation

use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.

the class SysJobController method add.

@ApiOperation(value = "新增")
@LogAnnotation(title = "新增")
@PostMapping("/add")
@RequiresPermissions("sysJob:add")
public DataResult add(@RequestBody SysJobEntity sysJob) {
    if (isValidExpression(sysJob.getCronExpression())) {
        return DataResult.fail("cron表达式有误");
    }
    DataResult dataResult = ScheduleJob.judgeBean(sysJob.getBeanName());
    if (BaseResponseCode.SUCCESS.getCode() != dataResult.getCode()) {
        return dataResult;
    }
    sysJobService.saveJob(sysJob);
    return DataResult.success();
}
Also used : DataResult(com.company.project.common.utils.DataResult) LogAnnotation(com.company.project.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with LogAnnotation

use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.

the class SysLogController method pageInfo.

@PostMapping("/logs")
@ApiOperation(value = "分页查询系统操作日志接口")
@LogAnnotation(title = "系统操作日志管理", action = "分页查询系统操作日志")
@RequiresPermissions("sys:log:list")
public DataResult pageInfo(@RequestBody SysLog vo) {
    Page page = new Page(vo.getPage(), vo.getLimit());
    LambdaQueryWrapper<SysLog> queryWrapper = Wrappers.lambdaQuery();
    if (!StringUtils.isEmpty(vo.getUsername())) {
        queryWrapper.like(SysLog::getUsername, vo.getUsername());
    }
    if (!StringUtils.isEmpty(vo.getOperation())) {
        queryWrapper.like(SysLog::getOperation, vo.getOperation());
    }
    if (!StringUtils.isEmpty(vo.getStartTime())) {
        queryWrapper.gt(SysLog::getCreateTime, vo.getStartTime());
    }
    if (!StringUtils.isEmpty(vo.getEndTime())) {
        queryWrapper.lt(SysLog::getCreateTime, vo.getEndTime());
    }
    queryWrapper.orderByDesc(SysLog::getCreateTime);
    return DataResult.success(logService.page(page, queryWrapper));
}
Also used : SysLog(com.company.project.entity.SysLog) 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 4 with LogAnnotation

use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.

the class UserController method getUserOwnRole.

@GetMapping("/user/roles/{userId}")
@ApiOperation(value = "赋予角色-获取所有角色接口")
@LogAnnotation(title = "用户管理", action = "赋予角色-获取所有角色接口")
@RequiresPermissions("sys:user:role:detail")
public DataResult getUserOwnRole(@PathVariable("userId") String userId) {
    DataResult result = DataResult.success();
    result.setData(userService.getUserOwnRole(userId));
    return result;
}
Also used : DataResult(com.company.project.common.utils.DataResult) LogAnnotation(com.company.project.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with LogAnnotation

use of com.company.project.common.aop.annotation.LogAnnotation in project springboot-manager by aitangbao.

the class UserController method setUserOwnRole.

@PutMapping("/user/roles/{userId}")
@ApiOperation(value = "赋予角色-用户赋予角色接口")
@LogAnnotation(title = "用户管理", action = "赋予角色-用户赋予角色接口")
@RequiresPermissions("sys:user:update:role")
public DataResult setUserOwnRole(@PathVariable("userId") String userId, @RequestBody List<String> roleIds) {
    LambdaQueryWrapper<SysUserRole> queryWrapper = Wrappers.lambdaQuery();
    queryWrapper.eq(SysUserRole::getUserId, userId);
    userRoleService.remove(queryWrapper);
    if (!CollectionUtils.isEmpty(roleIds)) {
        UserRoleOperationReqVO reqVO = new UserRoleOperationReqVO();
        reqVO.setUserId(userId);
        reqVO.setRoleIds(roleIds);
        userRoleService.addUserRoleInfo(reqVO);
    }
    // 刷新权限
    httpSessionService.refreshUerId(userId);
    return DataResult.success();
}
Also used : UserRoleOperationReqVO(com.company.project.vo.req.UserRoleOperationReqVO) SysUserRole(com.company.project.entity.SysUserRole) 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