Java Code Examples for com.ruoyi.common.annotation.Log

The following examples show how to use com.ruoyi.common.annotation.Log. These examples are extracted from open source projects. 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 Project: ruoyiplus   Author: kongshanxuelin   File: SysUserOnlineController.java    License: 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 #2
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysDeptController.java    License: 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 #3
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysMenuController.java    License: 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 #4
Source Project: supplierShop   Author: guchengwuyue   File: SysUserOnlineController.java    License: 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 #5
Source Project: supplierShop   Author: guchengwuyue   File: SysPostController.java    License: 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 #6
Source Project: supplierShop   Author: guchengwuyue   File: SysMenuController.java    License: 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 #7
Source Project: supplierShop   Author: guchengwuyue   File: SysRoleController.java    License: 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 #8
Source Project: supplierShop   Author: guchengwuyue   File: SysRoleController.java    License: 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 #9
Source Project: ruoyiplus   Author: kongshanxuelin   File: GenController.java    License: 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 #10
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysProfileController.java    License: 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 #11
Source Project: supplierShop   Author: guchengwuyue   File: SysUserController.java    License: 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 #12
Source Project: supplierShop   Author: guchengwuyue   File: SysUserController.java    License: 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 #13
Source Project: supplierShop   Author: guchengwuyue   File: SysProfileController.java    License: 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 #14
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysUserController.java    License: 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 #15
Source Project: supplierShop   Author: guchengwuyue   File: GenController.java    License: MIT License 5 votes vote down vote up
/**
 * 导入表结构(保存)
 */
@RequiresPermissions("tool:gen:list")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
@ResponseBody
public AjaxResult importTableSave(String tables)
{
    String[] tableNames = Convert.toStrArray(tables);
    // 查询表信息
    List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
    String operName = (String) PermissionUtils.getPrincipalProperty("loginName");
    genTableService.importGenTable(tableList, operName);
    return AjaxResult.success();
}
 
Example #16
Source Project: supplierShop   Author: guchengwuyue   File: GenController.java    License: MIT License 5 votes vote down vote up
/**
 * 修改保存代码生成业务
 */
@RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated GenTable genTable)
{
    genTableService.validateEdit(genTable);
    genTableService.updateGenTable(genTable);
    return AjaxResult.success();
}
 
Example #17
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysUserController.java    License: MIT License 5 votes vote down vote up
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
    ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
    List<SysUser> userList = util.importExcel(file.getInputStream());
    String operName = getSysUser().getLoginName();
    String message = userService.importUser(userList, updateSupport, operName);
    return AjaxResult.success(message);
}
 
Example #18
Source Project: supplierShop   Author: guchengwuyue   File: GenController.java    License: MIT License 5 votes vote down vote up
/**
 * 批量生成代码
 */
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode")
@ResponseBody
public void batchGenCode(HttpServletResponse response, String tables) throws IOException
{
    String[] tableNames = Convert.toStrArray(tables);
    byte[] data = genTableService.generatorCode(tableNames);
    genCode(response, data);
}
 
Example #19
Source Project: supplierShop   Author: guchengwuyue   File: LogAspect.java    License: 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 #20
Source Project: supplierShop   Author: guchengwuyue   File: SysJobController.java    License: MIT License 5 votes vote down vote up
/**
 * 修改保存调度
 */
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@RequiresPermissions("monitor:job:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysJob job) throws SchedulerException, TaskException
{
    return toAjax(jobService.updateJob(job));
}
 
Example #21
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysJobLogController.java    License: MIT License 5 votes vote down vote up
@Log(title = "调度日志", businessType = BusinessType.DELETE)
@RequiresPermissions("monitor:job:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    return toAjax(jobLogService.deleteJobLogByIds(ids));
}
 
Example #22
Source Project: supplierShop   Author: guchengwuyue   File: SysLogininforController.java    License: MIT License 5 votes vote down vote up
@RequiresPermissions("monitor:logininfor:remove")
@Log(title = "登陆日志", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    return toAjax(logininforService.deleteLogininforByIds(ids));
}
 
Example #23
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysConfigController.java    License: MIT License 5 votes vote down vote up
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:config:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysConfig config)
{
    List<SysConfig> list = configService.selectConfigList(config);
    ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
    return util.exportExcel(list, "参数数据");
}
 
Example #24
Source Project: supplierShop   Author: guchengwuyue   File: SysUserOnlineController.java    License: MIT License 5 votes vote down vote up
@RequiresPermissions("monitor:online:batchForceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/batchForceLogout")
@ResponseBody
public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids)
{
    for (String sessionId : ids)
    {
        SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
        if (online == null)
        {
            return error("用户已下线");
        }
        OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
        if (onlineSession == null)
        {
            return error("用户已下线");
        }
        if (sessionId.equals(ShiroUtils.getSessionId()))
        {
            return error("当前登陆用户无法强退");
        }
        onlineSession.setStatus(OnlineStatus.off_line);
        onlineSessionDAO.update(onlineSession);
        online.setStatus(OnlineStatus.off_line);
        userOnlineService.saveOnline(online);
    }
    return success();
}
 
Example #25
Source Project: supplierShop   Author: guchengwuyue   File: StoreCouponController.java    License: MIT License 5 votes vote down vote up
/**
 * 新增保存优惠券主
 */
@RequiresPermissions("shop:coupon:add")
@Log(title = "优惠券主", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreCoupon storeCoupon)
{
    return toAjax(storeCouponService.insertStoreCoupon(storeCoupon));
}
 
Example #26
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysLogininforController.java    License: MIT License 5 votes vote down vote up
@Log(title = "登陆日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:logininfor:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysLogininfor logininfor)
{
    List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
    ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
    return util.exportExcel(list, "登陆日志");
}
 
Example #27
Source Project: supplierShop   Author: guchengwuyue   File: StoreCouponController.java    License: MIT License 5 votes vote down vote up
/**
 * 删除优惠券主
 */
@RequiresPermissions("shop:coupon:remove")
@Log(title = "优惠券主", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    return toAjax(storeCouponService.deleteStoreCouponByIds(ids));
}
 
Example #28
Source Project: ruoyiplus   Author: kongshanxuelin   File: SysDictDataController.java    License: MIT License 5 votes vote down vote up
@Log(title = "字典数据", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dict:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    return toAjax(dictDataService.deleteDictDataByIds(ids));
}
 
Example #29
Source Project: supplierShop   Author: guchengwuyue   File: StoreGoodsBrandController.java    License: MIT License 5 votes vote down vote up
/**
 * 修改保存产品品牌
 */
@RequiresPermissions("shop:brand:edit")
@Log(title = "产品品牌", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreGoodsBrand storeGoodsBrand)
{
    return toAjax(storeGoodsBrandService.updateStoreGoodsBrand(storeGoodsBrand));
}
 
Example #30
Source Project: supplierShop   Author: guchengwuyue   File: StoreMemberController.java    License: MIT License 5 votes vote down vote up
/**
 * 新增保存商城会员信息
 */
@RequiresPermissions("shop:member:add")
@Log(title = "商城会员信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreMember storeMember)
{
    return toAjax(storeMemberService.insertStoreMember(storeMember));
}