Search in sources :

Example 21 with AjaxResult

use of com.ruoyi.common.core.domain.AjaxResult in project RuoYi-Vue by yangzongzhuan.

the class RepeatSubmitInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
        if (annotation != null) {
            if (this.isRepeatSubmit(request, annotation)) {
                AjaxResult ajaxResult = AjaxResult.error(annotation.message());
                ServletUtils.renderString(response, JSON.toJSONString(ajaxResult));
                return false;
            }
        }
        return true;
    } else {
        return true;
    }
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) RepeatSubmit(com.ruoyi.common.annotation.RepeatSubmit) HandlerMethod(org.springframework.web.method.HandlerMethod)

Example 22 with AjaxResult

use of com.ruoyi.common.core.domain.AjaxResult in project hocassian-media-matrix by hokaso.

the class RepeatSubmitInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
        if (annotation != null) {
            if (this.isRepeatSubmit(request)) {
                AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
                ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
                return false;
            }
        }
        return true;
    } else {
        return super.preHandle(request, response, handler);
    }
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) RepeatSubmit(com.ruoyi.common.annotation.RepeatSubmit) HandlerMethod(org.springframework.web.method.HandlerMethod)

Example 23 with AjaxResult

use of com.ruoyi.common.core.domain.AjaxResult in project hocassian-media-matrix by hokaso.

the class CommonController method videoMatrixUploadFile.

/**
 * 「同和视频矩阵」相关上传请求
 */
@PostMapping("/common/video_matrix_upload")
public AjaxResult videoMatrixUploadFile(MultipartFile file) throws Exception {
    try {
        // 上传文件路径
        String filePath = RuoYiConfig.getVideoMatrixUploadPath();
        // 上传并返回新文件名称
        // System.out.println("到此一游");
        String fileName = FileUploadUtils.unsignedUpload(filePath, file);
        // String url = serverConfig.getUrl() + fileName;
        AjaxResult ajax = AjaxResult.success();
        ajax.put("fileName", fileName);
        // ajax.put("url", url);
        return ajax;
    } catch (Exception e) {
        return AjaxResult.error(e.getMessage());
    }
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 24 with AjaxResult

use of com.ruoyi.common.core.domain.AjaxResult in project hocassian-media-matrix by hokaso.

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
    AjaxResult ajax = AjaxResult.success();
    List<SysRole> roles = roleService.selectRoleAll();
    ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    ajax.put("posts", postService.selectPostAll());
    if (StringUtils.isNotNull(userId)) {
        ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
        ajax.put("postIds", postService.selectPostListByUserId(userId));
        ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
    }
    return ajax;
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) TokenService(com.ruoyi.framework.web.service.TokenService) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ServletUtils(com.ruoyi.common.utils.ServletUtils) AjaxResult(com.ruoyi.common.core.domain.AjaxResult) RequestBody(org.springframework.web.bind.annotation.RequestBody) StringUtils(com.ruoyi.common.utils.StringUtils) PutMapping(org.springframework.web.bind.annotation.PutMapping) SecurityUtils(com.ruoyi.common.utils.SecurityUtils) ISysRoleService(com.ruoyi.system.service.ISysRoleService) GetMapping(org.springframework.web.bind.annotation.GetMapping) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) BaseController(com.ruoyi.common.core.controller.BaseController) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) BusinessType(com.ruoyi.common.enums.BusinessType) List(java.util.List) ISysUserService(com.ruoyi.system.service.ISysUserService) UserConstants(com.ruoyi.common.constant.UserConstants) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysRole(com.ruoyi.common.core.domain.entity.SysRole) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 25 with AjaxResult

use of com.ruoyi.common.core.domain.AjaxResult in project hocassian-media-matrix by hokaso.

the class SysMenuController method roleMenuTreeselect.

/**
 * 加载对应角色菜单列表树
 */
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
    ajax.put("menus", menuService.buildMenuTreeSelect(menus));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysMenu(com.ruoyi.common.core.domain.entity.SysMenu) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

AjaxResult (com.ruoyi.common.core.domain.AjaxResult)55 GetMapping (org.springframework.web.bind.annotation.GetMapping)25 PostMapping (org.springframework.web.bind.annotation.PostMapping)16 SysUser (com.ruoyi.common.core.domain.entity.SysUser)12 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)10 Log (com.ruoyi.common.annotation.Log)8 StringUtils (com.ruoyi.common.utils.StringUtils)7 List (java.util.List)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 RestController (org.springframework.web.bind.annotation.RestController)7 MultipartFile (org.springframework.web.multipart.MultipartFile)7 SysUser (com.ruoyi.system.domain.SysUser)6 UserConstants (com.ruoyi.common.constant.UserConstants)5 BaseController (com.ruoyi.common.core.controller.BaseController)5 SysRole (com.ruoyi.common.core.domain.entity.SysRole)5 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)5 BusinessType (com.ruoyi.common.enums.BusinessType)5 SecurityUtils (com.ruoyi.common.utils.SecurityUtils)5