com.ruoyi.common.annotation.Log Java Examples

The following examples show how to use com.ruoyi.common.annotation.Log. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysMenuController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 删除菜单
 */
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}")
@ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
    if (menuService.selectCountMenuByParentId(menuId) > 0)
    {
        return AjaxResult.warn("存在子菜单,不允许删除");
    }
    if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
    {
        return AjaxResult.warn("菜单已分配,不允许删除");
    }
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(menuService.deleteMenuById(menuId));
}
 
Example #2
Source File: SysUserController.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 新增保存用户
 */
@RequiresPermissions("system:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult addSave(SysUser user)
{
    if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId()))
    {
        return error("不允许修改超级管理员用户");
    }
    user.setSalt(ShiroUtils.randomSalt());
    user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
    user.setCreateBy(ShiroUtils.getLoginName());
    return toAjax(userService.insertUser(user));
}
 
Example #3
Source File: SysProfileController.java    From supplierShop with MIT License 6 votes vote down vote up
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwd(String oldPassword, String newPassword)
{
    SysUser user = ShiroUtils.getSysUser();
    if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
    {
        user.setSalt(ShiroUtils.randomSalt());
        user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
        if (userService.resetUserPwd(user) > 0)
        {
            ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
            return success();
        }
        return error();
    }
    else
    {
        return error("修改密码失败,旧密码错误");
    }
}
 
Example #4
Source File: SysDeptController.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 删除
 */
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dept:remove")
@PostMapping("/remove/{deptId}")
@ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId)
{
    if (deptService.selectDeptCount(deptId) > 0)
    {
        return error(1, "存在下级部门,不允许删除");
    }
    if (deptService.checkDeptExistUser(deptId))
    {
        return error(1, "部门存在用户,不允许删除");
    }
    return toAjax(deptService.deleteDeptById(deptId));
}
 
Example #5
Source File: SysUserOnlineController.java    From ruoyiplus with MIT License 6 votes vote down vote up
@RequiresPermissions("monitor:online:forceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/forceLogout")
@ResponseBody
public AjaxResult forceLogout(String sessionId)
{
    SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
    if (sessionId.equals(ShiroUtils.getSessionId()))
    {
        return error("当前登陆用户无法强退");
    }
    if (online == null)
    {
        return error("用户已下线");
    }
    OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
    if (onlineSession == null)
    {
        return error("用户已下线");
    }
    onlineSession.setStatus(OnlineStatus.off_line);
    online.setStatus(OnlineStatus.off_line);
    userOnlineService.saveOnline(online);
    return success();
}
 
Example #6
Source File: SysMenuController.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 删除菜单
 */
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:menu:remove")
@PostMapping("/remove/{menuId}")
@ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
    if (menuService.selectCountMenuByParentId(menuId) > 0)
    {
        return error(1, "存在子菜单,不允许删除");
    }
    if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
    {
        return error(1, "菜单已分配,不允许删除");
    }
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(menuService.deleteMenuById(menuId));
}
 
Example #7
Source File: SysUserOnlineController.java    From supplierShop with MIT License 6 votes vote down vote up
@RequiresPermissions("monitor:online:forceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/forceLogout")
@ResponseBody
public AjaxResult forceLogout(String sessionId)
{
    SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
    if (sessionId.equals(ShiroUtils.getSessionId()))
    {
        return error("当前登陆用户无法强退");
    }
    if (online == null)
    {
        return error("用户已下线");
    }
    OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
    if (onlineSession == null)
    {
        return error("用户已下线");
    }
    onlineSession.setStatus(OnlineStatus.off_line);
    onlineSessionDAO.update(onlineSession);
    online.setStatus(OnlineStatus.off_line);
    userOnlineService.saveOnline(online);
    return success();
}
 
Example #8
Source File: SysUserController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 新增保存用户
 */
@RequiresPermissions("system:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysUser user)
{
    if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
    {
        return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
    }
    else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
    {
        return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
    }
    else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
    {
        return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
    }
    user.setSalt(ShiroUtils.randomSalt());
    user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
    user.setCreateBy(ShiroUtils.getLoginName());
    return toAjax(userService.insertUser(user));
}
 
Example #9
Source File: SysProfileController.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 修改用户
 */
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/update")
@ResponseBody
public AjaxResult update(SysUser user)
{
    SysUser currentUser = getSysUser();
    currentUser.setUserName(user.getUserName());
    currentUser.setEmail(user.getEmail());
    currentUser.setPhonenumber(user.getPhonenumber());
    currentUser.setSex(user.getSex());
    if (userService.updateUserInfo(currentUser) > 0)
    {
        setSysUser(userService.selectUserById(currentUser.getUserId()));
        return success();
    }
    return error();
}
 
Example #10
Source File: SysPostController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 新增保存岗位
 */
@RequiresPermissions("system:post:add")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysPost post)
{
    if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
    {
        return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
    }
    else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
    {
        return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
    }
    post.setCreateBy(ShiroUtils.getLoginName());
    return toAjax(postService.insertPost(post));
}
 
Example #11
Source File: SysUserController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 修改保存用户
 */
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysUser user)
{
    if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId()))
    {
        return error("不允许修改超级管理员用户");
    }
    else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
    {
        return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
    }
    else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
    {
        return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
    }
    user.setUpdateBy(ShiroUtils.getLoginName());
    return toAjax(userService.updateUser(user));
}
 
Example #12
Source File: SysRoleController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 新增保存角色
 */
@RequiresPermissions("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysRole role)
{
    if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
    {
        return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
    }
    else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
    {
        return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
    }
    role.setCreateBy(ShiroUtils.getLoginName());
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(roleService.insertRole(role));

}
 
Example #13
Source File: GenController.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 生成代码
 */
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}")
public void genCode(
        HttpServletRequest request,
        HttpServletResponse response,
        @PathVariable("tableName") String tableName)
        throws IOException {
    byte[] data = genService.generatorCode(tableName, null);
    response.reset();
    response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
    response.addHeader("Content-Length", "" + data.length);
    response.setContentType("application/octet-stream; charset=UTF-8");

    IOUtils.write(data, response.getOutputStream());
}
 
Example #14
Source File: SysRoleController.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 修改保存角色
 */
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysRole role)
{
    if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
    {
        return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
    }
    else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
    {
        return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
    }
    role.setUpdateBy(ShiroUtils.getLoginName());
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(roleService.updateRole(role));
}
 
Example #15
Source File: LogAspect.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 是否存在注解,如果存在就获取
 */
private Log getAnnotationLog(JoinPoint joinPoint) throws Exception
{
    Signature signature = joinPoint.getSignature();
    MethodSignature methodSignature = (MethodSignature) signature;
    Method method = methodSignature.getMethod();

    if (method != null)
    {
        return method.getAnnotation(Log.class);
    }
    return null;
}
 
Example #16
Source File: SysRoleController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 修改保存角色
 */
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult editSave(SysRole role)
{
    role.setUpdateBy(ShiroUtils.getLoginName());
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(roleService.updateRole(role));
}
 
Example #17
Source File: SysDictTypeController.java    From ruoyiplus with MIT License 5 votes vote down vote up
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysDictType dictType)
{

    List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
    ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
    return util.exportExcel(list, "字典类型");
}
 
Example #18
Source File: SysDeptController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 新增保存部门
 */
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDept dept)
{
    if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
    {
        return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
    }
    dept.setCreateBy(ShiroUtils.getLoginName());
    return toAjax(deptService.insertDept(dept));
}
 
Example #19
Source File: SysUserController.java    From ruoyiplus with MIT License 5 votes vote down vote up
@RequiresPermissions("system:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    try
    {
        return toAjax(userService.deleteUserByIds(ids));
    }
    catch (Exception e)
    {
        return error(e.getMessage());
    }
}
 
Example #20
Source File: SysRoleController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 批量取消授权
 */
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancelAll")
@ResponseBody
public AjaxResult cancelAuthUserAll(Long roleId, String userIds)
{
    return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
 
Example #21
Source File: SysRoleController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 新增保存角色
 */
@RequiresPermissions("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult addSave(SysRole role)
{
    role.setCreateBy(ShiroUtils.getLoginName());
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(roleService.insertRole(role));

}
 
Example #22
Source File: SysRoleController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 角色状态修改
 */
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
    return toAjax(roleService.changeStatus(role));
}
 
Example #23
Source File: SysDeptController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 保存
 */
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysDept dept)
{
    dept.setUpdateBy(ShiroUtils.getLoginName());
    return toAjax(deptService.updateDept(dept));
}
 
Example #24
Source File: SysRoleController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 保存角色分配数据权限
 */
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/authDataScope")
@ResponseBody
public AjaxResult authDataScopeSave(SysRole role)
{
    role.setUpdateBy(ShiroUtils.getLoginName());
    if (roleService.authDataScope(role) > 0)
    {
        ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
        return success();
    }
    return error();
}
 
Example #25
Source File: SysOperlogController.java    From ruoyiplus with MIT License 5 votes vote down vote up
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
    operLogService.cleanOperLog();
    return success();
}
 
Example #26
Source File: SysRoleController.java    From supplierShop with MIT License 5 votes vote down vote up
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:role:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysRole role)
{
    List<SysRole> list = roleService.selectRoleList(role);
    ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
    return util.exportExcel(list, "角色数据");
}
 
Example #27
Source File: SysDictTypeController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 新增保存字典类型
 */
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysDictType dict)
{
    dict.setCreateBy(ShiroUtils.getLoginName());
    return toAjax(dictTypeService.insertDictType(dict));
}
 
Example #28
Source File: SysMenuController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 新增保存菜单
 */
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@RequiresPermissions("system:menu:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysMenu menu)
{
    if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
    {
        return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
    }
    menu.setCreateBy(ShiroUtils.getLoginName());
    ShiroUtils.clearCachedAuthorizationInfo();
    return toAjax(menuService.insertMenu(menu));
}
 
Example #29
Source File: SysPostController.java    From supplierShop with MIT License 5 votes vote down vote up
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:post:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysPost post)
{
    List<SysPost> list = postService.selectPostList(post);
    ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
    return util.exportExcel(list, "岗位数据");
}
 
Example #30
Source File: SysDictDataController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 新增保存字典类型
 */
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDictData dict)
{
    dict.setCreateBy(ShiroUtils.getLoginName());
    return toAjax(dictDataService.insertDictData(dict));
}