Search in sources :

Example 6 with LogAnnotation

use of com.jun.plugin.system.common.aop.annotation.LogAnnotation in project jun_springboot_api_service by wujun728.

the class DeptController method getDeptAll.

@GetMapping("/depts")
@ApiOperation(value = "获取机构列表接口")
@LogAnnotation(title = "机构管理", action = "获取所有组织机构")
@RequiresPermissions("sys:dept:list")
public DataResult getDeptAll() {
    List<SysDept> deptList = deptService.list();
    deptList.parallelStream().forEach(entity -> {
        SysDept parentDept = deptService.getById(entity.getPid());
        if (parentDept != null) {
            entity.setPidName(parentDept.getName());
        }
    });
    return DataResult.success(deptList);
}
Also used : SysDept(com.jun.plugin.system.entity.SysDept) LogAnnotation(com.jun.plugin.system.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with LogAnnotation

use of com.jun.plugin.system.common.aop.annotation.LogAnnotation in project jun_springboot_api_service by wujun728.

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.jun.plugin.system.common.utils.DataResult) LogAnnotation(com.jun.plugin.system.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 8 with LogAnnotation

use of com.jun.plugin.system.common.aop.annotation.LogAnnotation in project jun_springboot_api_service by wujun728.

the class SysJobController method getRecentTriggerTime.

@ApiOperation(value = "获取运行时间")
@LogAnnotation(title = "获取运行时间")
@PostMapping("/getRecentTriggerTime")
@RequiresPermissions("sysJob:add")
public DataResult getRecentTriggerTime(String cron) {
    List<String> list = new ArrayList<>();
    try {
        CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
        cronTriggerImpl.setCronExpression(cron);
        // 这个是重点,一行代码搞定
        List<Date> dates = TriggerUtils.computeFireTimes(cronTriggerImpl, null, 5);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (Date date : dates) {
            list.add(dateFormat.format(date));
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return DataResult.success(list);
}
Also used : ArrayList(java.util.ArrayList) CronTriggerImpl(org.quartz.impl.triggers.CronTriggerImpl) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LogAnnotation(com.jun.plugin.system.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 9 with LogAnnotation

use of com.jun.plugin.system.common.aop.annotation.LogAnnotation in project jun_springboot_api_service by wujun728.

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.jun.plugin.system.vo.req.UserRoleOperationReqVO) SysUserRole(com.jun.plugin.system.entity.SysUserRole) LogAnnotation(com.jun.plugin.system.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 10 with LogAnnotation

use of com.jun.plugin.system.common.aop.annotation.LogAnnotation in project jun_springboot_api_service by wujun728.

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.jun.plugin.system.common.utils.DataResult) LogAnnotation(com.jun.plugin.system.common.aop.annotation.LogAnnotation) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

LogAnnotation (com.jun.plugin.system.common.aop.annotation.LogAnnotation)12 ApiOperation (io.swagger.annotations.ApiOperation)11 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)10 DataResult (com.jun.plugin.system.common.utils.DataResult)3 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)2 SysLog (com.jun.plugin.system.entity.SysLog)2 SysRole (com.jun.plugin.system.entity.SysRole)2 ArrayList (java.util.ArrayList)2 BusinessException (com.jun.plugin.system.common.exception.BusinessException)1 SysDept (com.jun.plugin.system.entity.SysDept)1 SysPermission (com.jun.plugin.system.entity.SysPermission)1 SysRoleDeptEntity (com.jun.plugin.system.entity.SysRoleDeptEntity)1 SysUserRole (com.jun.plugin.system.entity.SysUserRole)1 UserRoleOperationReqVO (com.jun.plugin.system.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