org.springframework.web.bind.annotation.ResponseBody Java Examples
The following examples show how to use
org.springframework.web.bind.annotation.ResponseBody.
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: ConsoleUserController.java From console with Apache License 2.0 | 6 votes |
@SuppressWarnings("unused") @RequestMapping("/deleteConsoleUserByUserids") @ResponseBody public int deleteConsoleUserByUserids(HttpServletRequest request) { long startTime = System.currentTimeMillis(); int nRows = 0; String _sUserIds = request.getParameter("userIds"); String type = request.getParameter("type"); if (!StringUtils.isNull(_sUserIds)) { nRows = consoleUserService.deleteConsoleUserUserIds(_sUserIds); boolean flag = false; // define opear result if (nRows != 0) flag = true; } return nRows; }
Example #2
Source File: InterfaceCaseController.java From ATest with GNU General Public License v3.0 | 6 votes |
/** * 执行接口用例并返回断言结果 */ @RequestMapping(value = "/toRequestInterfaceCase", method = RequestMethod.POST) @ResponseBody public AssertResult toRequestInterfaceCase(Integer interfaceCaseId, Integer mockId) { if (null != interfaceCaseId) { Request request = new Request(); request = interfaceCaseService.QueryRequestByTestCaseId(interfaceCaseId); Map<String, String> bindMap = new HashMap<String, String>(); if (null != mockId) { Mock mock = mockService.QueryMockById(mockId); if (null != mock) { bindMap.putAll(mock.getBindVariableMocks()); } } DoRequest doRequest = new DoRequest(0, request, bindMap); ResponseContent responseContent = new ResponseContent(); responseContent = doRequest.toRequest(); doRequest.toUpdateVariables(responseContent); return doRequest.toAssert(responseContent); } return null; }
Example #3
Source File: BasicController.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(Exception.class) @ResponseBody ErrorResponse handleError(HttpServletRequest req, Exception ex) { logger.error("", ex); Message msg = MsgPicker.getMsg(); Throwable cause = ex; while (cause != null) { if (cause.getClass().getPackage().getName().startsWith("org.apache.hadoop.hbase")) { return new ErrorResponse(req.getRequestURL().toString(), new InternalErrorException( String.format(Locale.ROOT, msg.getHBASE_FAIL(), ex.getMessage()), ex)); } cause = cause.getCause(); } return new ErrorResponse(req.getRequestURL().toString(), ex); }
Example #4
Source File: WebAopLog.java From Jpom with MIT License | 6 votes |
@Before("webLog()") public void doBefore(JoinPoint joinPoint) { if (aopLogInterface != null) { aopLogInterface.before(joinPoint); } // 接收到请求,记录请求内容 IS_LOG.set(ExtConfigBean.getInstance().isConsoleLogReqResponse()); Signature signature = joinPoint.getSignature(); if (signature instanceof MethodSignature) { MethodSignature methodSignature = (MethodSignature) signature; ResponseBody responseBody = methodSignature.getMethod().getAnnotation(ResponseBody.class); if (responseBody == null) { RestController restController = joinPoint.getTarget().getClass().getAnnotation(RestController.class); if (restController == null) { IS_LOG.set(false); } } } }
Example #5
Source File: UserManageController.java From openzaly with Apache License 2.0 | 6 votes |
@RequestMapping(method = RequestMethod.POST, value = "delUser") @ResponseBody public String deleteUser(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (isManager(siteUserId)) { Map<String, String> reqMap = getRequestDataMap(pluginPackage); String delUserID = reqMap.get("siteUserId"); if (userService.delUser(delUserID)) { return SUCCESS; } } else { return NO_PERMISSION; } } catch (Exception e) { logger.error("del User error", e); } return ERROR; }
Example #6
Source File: VersionLockController.java From qconfig with MIT License | 6 votes |
@RequestMapping(value = "/unlock", method = RequestMethod.POST) @ResponseBody public Object upload(@RequestBody ClientFileVersionRequest clientFileVersion) { String ip = clientFileVersion.getIp().trim(); logger.info("unlock consumer version, {}", clientFileVersion); Preconditions.checkArgument(!Strings.isNullOrEmpty(ip), "ip不能为空"); ConfigMeta configMeta = transform(clientFileVersion); checkLegalMeta(configMeta); try { fixedConsumerVersionService.deleteConsumerVersion(configMeta, ip); } catch (Exception e) { logger.error("unlock consumer version error", e); return new JsonV2<>(-1, "取消锁定失败,请联系管理员!", null); } return new JsonV2<>(0, "取消锁定成功", null); }
Example #7
Source File: EmpUserController.java From frpMgr with MIT License | 6 votes |
/** * 停用用户 * @param empUser * @return */ @RequiresPermissions("sys:empUser:updateStatus") @ResponseBody @RequestMapping(value = "disable") public String disable(EmpUser empUser) { if (User.isSuperAdmin(empUser.getUserCode())) { return renderResult(Global.FALSE, "非法操作,不能够操作此用户!"); } if (!EmpUser.USER_TYPE_EMPLOYEE.equals(empUser.getUserType())){ return renderResult(Global.FALSE, "非法操作,不能够操作此用户!"); } if (empUser.getCurrentUser().getUserCode().equals(empUser.getUserCode())) { return renderResult(Global.FALSE, text("停用用户失败,不允许停用当前用户")); } empUser.setStatus(User.STATUS_DISABLE); userService.updateStatus(empUser); return renderResult(Global.TRUE, text("停用用户''{0}''成功", empUser.getUserName())); }
Example #8
Source File: ShopManagerController.java From Project with Apache License 2.0 | 6 votes |
/** * 获取店铺信息 * @return */ @RequestMapping(value = "/getShopInitInfo", method = RequestMethod.GET) @ResponseBody public Map<String,Object> getShopInitInfo(){ Map<String, Object> modelMap = new HashMap<>(); // 需要两个 List 分别接收 shopCategory 和 area 的信息 List<ShopCategory> shopCategoryList = new ArrayList<>(); List<Area> areaList = new ArrayList<>(); try{ shopCategoryList = shopCategoryService.getShopCategoryList(new ShopCategory()); areaList = areaService.getAreaList(); modelMap.put("shopCategoryList", shopCategoryList); modelMap.put("areaList", areaList); modelMap.put("success", true); }catch (Exception e){ modelMap.put("success", false); modelMap.put("errMsg", e.getMessage()); } return modelMap; }
Example #9
Source File: InterfaceController.java From ATest with GNU General Public License v3.0 | 6 votes |
@RequestMapping(value = "/toUpdateInterface", method = RequestMethod.POST) @ResponseBody public Boolean toUpdateInterface(Integer interfaceId, String name, String api, Integer environmentId, String description) { if (null != name && !"".equals(name) && null != api && !"".equals(api) && null != environmentId && null != interfaceId) { Interface interfaceObject = new Interface(); interfaceObject.setId(interfaceId); interfaceObject.setName(name); interfaceObject.setApi(api); interfaceObject.setDescription(description); interfaceObject.setEnvironmentId(environmentId); return interfaceService.UpdateInterface(interfaceObject); } return false; }
Example #10
Source File: CommonController.java From supplierShop with MIT License | 6 votes |
/** * 通用上传请求 */ @PostMapping("/common/upload") @ResponseBody public AjaxResult uploadFile(MultipartFile file) throws Exception { try { // 上传文件路径 String filePath = Global.getUploadPath(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(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()); } }
Example #11
Source File: UserController.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/{userName:.+}", method = { RequestMethod.DELETE }, produces = { "application/json" }) @ResponseBody public EnvelopeResponse delete(@PathVariable("userName") String userName) throws IOException { checkProfileEditAllowed(); if (StringUtils.equals(getPrincipal(), userName)) { throw new ForbiddenException("..."); } //delete user's project ACL accessService.revokeProjectPermission(userName, MetadataConstants.TYPE_USER); //delete user's table/row/column ACL // ACLOperationUtil.delLowLevelACL(userName, MetadataConstants.TYPE_USER); checkUserName(userName); userService.deleteUser(userName); return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, userName, ""); }
Example #12
Source File: UploadFileController.java From erp-framework with MIT License | 6 votes |
/** * 检验分片是否未上传或者未完成 * result.header.status=0是已上传完整,否则为1 * * @param request * @param response * @return * @throws Exception */ @RequestMapping(value = "/checkChunk", produces = "application/json; charset=utf-8") @ResponseBody public ResultBean checkChunk(HttpServletRequest request, HttpServletResponse response) throws Exception { //检查当前分块是否上传成功 String fileMd5 = request.getParameter("fileMd5"); String chunk = request.getParameter("chunk"); String chunkSize = request.getParameter("chunkSize"); String dir = TEMP_PATH + File.separator + fileMd5; String partName = fileMd5 + CHUNK_NAME_SPLIT + chunk + CHUNK_NAME_SPLIT; String suffix = ".part"; File checkFile = new File(dir + File.separator + partName + suffix); //检查文件是否存在,且大小是否一致 if (checkFile.exists() && checkFile.length() == Integer.parseInt(chunkSize)) { //上传过 return new ResultBean("上传过"); } else { //没有上传过 return new ResultBean(); } }
Example #13
Source File: MenuController.java From WebStack-Guns with MIT License | 6 votes |
/** * 删除菜单 */ @Permission(Const.ADMIN_NAME) @RequestMapping(value = "/remove") @BussinessLog(value = "删除菜单", key = "menuId", dict = MenuDict.class) @ResponseBody public ResponseData remove(@RequestParam Long menuId) { if (ToolUtil.isEmpty(menuId)) { throw new ServiceException(BizExceptionEnum.REQUEST_NULL); } //缓存菜单的名称 LogObjectHolder.me().set(ConstantFactory.me().getMenuName(menuId)); this.menuService.delMenuContainSubMenus(menuId); return SUCCESS_TIP; }
Example #14
Source File: AdminController.java From qconfig with MIT License | 6 votes |
@RequestMapping("/batchCopyFile") @ResponseBody public Object batchCopyFile(@RequestBody JsonNode rootNode, @RequestParam String fileType) { Preconditions.checkArgument("common".equals(fileType) || "reference".equals(fileType) || "inherit".equals(fileType), "fileType无效"); JsonNode groupsArrayNode = rootNode.get("groups"); Preconditions.checkArgument(groupsArrayNode.isArray(), "groups字段必须是array"); Iterator<JsonNode> it = groupsArrayNode.iterator(); Map<String, Map<String, String>> allGroupResult = Maps.newHashMap(); while (it.hasNext()) { JsonNode groupNode = it.next(); String group = groupNode.get("group").asText(); String srcProfile = groupNode.get("srcProfile").asText(); String destProfile = groupNode.get("destProfile").asText(); createSubEnv(group, destProfile); Map<String, String> groupResult = batchCopyWithPublish(group, srcProfile, destProfile, fileType); allGroupResult.put(group + "/" + srcProfile, groupResult); } return allGroupResult; }
Example #15
Source File: WeixinNewstemplateController.java From jeewx-boot with Apache License 2.0 | 6 votes |
/** * 保存信息 * @return */ @RequestMapping(value = "/doAdd",method ={RequestMethod.GET, RequestMethod.POST}) @ResponseBody public AjaxJson doAdd(@ModelAttribute WeixinNewstemplate weixinNewstemplate){ AjaxJson j = new AjaxJson(); try { //update-begin--Author:zhangweijian Date: 20180807 for:新增默认未上传 //'0':未上传;'1':上传中;'2':上传成功;'3':上传失败 weixinNewstemplate.setUploadType("0"); //update-end--Author:zhangweijian Date: 20180807 for:新增默认未上传 weixinNewstemplate.setTemplateType(WeixinMsgTypeEnum.wx_msg_type_news.getCode()); weixinNewstemplate.setCreateTime(new Date()); weixinNewstemplateService.doAdd(weixinNewstemplate); j.setMsg("保存成功"); } catch (Exception e) { log.error(e.getMessage()); j.setSuccess(false); j.setMsg("保存失败"); } return j; }
Example #16
Source File: CommonController.java From ruoyiplus with MIT License | 6 votes |
/** * 通用上传请求 */ @PostMapping("/common/upload") @ResponseBody public AjaxResult uploadFile(MultipartFile file) throws Exception { try { // 上传文件路径 String filePath = Global.getUploadPath(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + UPLOAD_PATH + fileName; AjaxResult ajax = AjaxResult.success(); ajax.put("fileName", fileName); ajax.put("url", url); return ajax; } catch (Exception e) { return AjaxResult.error(e.getMessage()); } }
Example #17
Source File: SysDeptController.java From supplierShop with MIT License | 5 votes |
/** * 加载角色部门(数据权限)列表树 */ @GetMapping("/roleDeptTreeData") @ResponseBody public List<Ztree> deptTreeData(SysRole role) { List<Ztree> ztrees = deptService.roleDeptTreeData(role); return ztrees; }
Example #18
Source File: WeixinNewstemplateController.java From jeewx-boot with Apache License 2.0 | 5 votes |
/** * 删除 * @return */ @RequestMapping(value="doDelete",method = RequestMethod.GET) @ResponseBody public AjaxJson doDelete(@RequestParam(required = true, value = "id" ) String id){ AjaxJson j = new AjaxJson(); try { weixinNewstemplateService.doDelete(id); j.setMsg("删除成功"); } catch (Exception e) { log.error(e.getMessage()); j.setSuccess(false); j.setMsg("删除失败"); } return j; }
Example #19
Source File: JwLinksucaiController.java From jeewx-boot with Apache License 2.0 | 5 votes |
/** * 删除 * * @return */ @RequestMapping(value = "doDelete", method = RequestMethod.GET) @ResponseBody public AjaxJson doDelete(@RequestParam(required = true, value = "id") String id) { AjaxJson j = new AjaxJson(); try { weixinLinksucaiService.doDelete(id); j.setMsg("删除成功"); } catch (Exception e) { e.printStackTrace(); j.setSuccess(false); j.setMsg("删除失败"); } return j; }
Example #20
Source File: SysMenuController.java From supplierShop with MIT License | 5 votes |
/** * 校验菜单名称 */ @PostMapping("/checkMenuNameUnique") @ResponseBody public String checkMenuNameUnique(SysMenu menu) { return menuService.checkMenuNameUnique(menu); }
Example #21
Source File: WebExceptionResolver.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Override public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { logger.error("WebExceptionResolver:{}", ex); // if json boolean isJson = false; HandlerMethod method = (HandlerMethod)handler; ResponseBody responseBody = method.getMethodAnnotation(ResponseBody.class); if (responseBody != null) { isJson = true; } // error result ReturnT<String> errorResult = new ReturnT<String>(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n", "<br/>")); // response ModelAndView mv = new ModelAndView(); if (isJson) { try { response.setContentType("application/json;charset=utf-8"); response.getWriter().print(JacksonUtil.writeValueAsString(errorResult)); } catch (IOException e) { logger.error(e.getMessage(), e); } return mv; } else { mv.addObject("exceptionMsg", errorResult.getMsg()); mv.setViewName("/common/common.exception"); return mv; } }
Example #22
Source File: SysJobController.java From supplierShop with MIT License | 5 votes |
@Log(title = "定时任务", businessType = BusinessType.DELETE) @RequiresPermissions("monitor:job:remove") @PostMapping("/remove") @ResponseBody public AjaxResult remove(String ids) throws SchedulerException { jobService.deleteJobByIds(ids); return success(); }
Example #23
Source File: ActicleController.java From admin-plus with Apache License 2.0 | 5 votes |
@PostMapping(value="/add") @ResponseBody @Permission(url = qxurl,type = PermissionType.ADD) public Object add(Acticle item) throws Exception { item.setId(null); return acticleService.add(item,this.getSession()); }
Example #24
Source File: GlobalExceptionHandler.java From MeetingFilm with Apache License 2.0 | 5 votes |
/** * 拦截jwt相关异常 */ @ExceptionHandler(JwtException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public ErrorTip jwtException(JwtException e) { return new ErrorTip(BizExceptionEnum.TOKEN_ERROR.getCode(), BizExceptionEnum.TOKEN_ERROR.getMessage()); }
Example #25
Source File: TimeLimiterApplication.java From spring-cloud-formula with Apache License 2.0 | 5 votes |
@RequestMapping("/free2") @ResponseBody public Object free(@RequestParam(value = "duration", defaultValue = "0") double duration) throws InterruptedException { Thread.sleep((long) (duration * 1000)); return "{\"duration\": " + duration + ", \"status\" : \"ok\"}"; }
Example #26
Source File: ClientLogController.java From qconfig with MIT License | 5 votes |
@RequestMapping("/view/recentClientLogs") @ResponseBody public List<ClientLog> recentClientLogs(@RequestParam("group") final String group, @RequestParam("profile") final String profile, @RequestParam("dataId") final String dataId, @RequestParam("basedVersion") final long basedVersion) { return CLIENT_LOG_ORDERING.immutableSortedCopy(clientLogDao.selectRecent(group, profile, dataId, basedVersion)); }
Example #27
Source File: UpdateLogController.java From DouBiNovel with Apache License 2.0 | 5 votes |
@RequestMapping("/listJSON") @ResponseBody @RequiresPermissions(value = {"UPDATE_LOG_VIEW", Const.role.ROLE_SUPER}, logical = Logical.OR) public MvcResult listJSON(BaseQuery query) { MvcResult result = MvcResult.create(); try { PageTemplate<UpdateLog> pageTemplate = updateLogService.getByQuery(query); result.setData(pageTemplate); } catch (Exception e) { result.setCode(-1); result.setSuccess(false); result.setMessage("获取出错," + e.getMessage()); } return result; }
Example #28
Source File: StoreGoodsTypeController.java From supplierShop with MIT License | 5 votes |
/** * 新增保存商品类型(商品模型) */ @RequiresPermissions("shop:type:add") @Log(title = "商品类型(商品模型)", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(StoreGoodsType storeGoodsType) { return toAjax(storeGoodsTypeService.insertStoreGoodsType(storeGoodsType)); }
Example #29
Source File: ClusterScaleController.java From cymbal with Apache License 2.0 | 5 votes |
/** * Create and do cluster scale. * * @param clusterId cluster id * @param clusterScaleDTO cluster scale DTO * @return http response entity */ @PostMapping("/clusters/{clusterId}/scales") @PreAuthorize("hasRole('ADMIN')") @ResponseBody public ResponseEntity<String> doScale(final @PathVariable String clusterId, final @RequestBody ClusterScaleDTO clusterScaleDTO, final @AuthenticationPrincipal Principal principal) { ClusterScale clusterScale = clusterScaleConverter.dtoToPo(clusterScaleDTO); clusterScale.setOperator(principal.getName()); try { redisClusterScaleProcessService.doScale(clusterScale); return ResponseEntity.ok().build(); } catch (NotEnoughResourcesException e) { return ResponseEntity.badRequest().build(); } }
Example #30
Source File: JwSystemAuthController.java From jeewx-boot with Apache License 2.0 | 5 votes |
/** * 得到权限树 * @return */ //@RequestMapping(value = "/getAuthTree",method ={RequestMethod.GET, RequestMethod.POST}) //@ResponseBody //public AjaxJson getAuthTree(@ModelAttribute JwSystemAuth jwSystemAuth){ // AjaxJson j = new AjaxJson(); // try { // String s1 = "{id:1, pId:0, name:\"test1\" , open:true}"; // String s2 = "{id:2, pId:1, name:\"test2\" , open:true}"; // String s3 = "{id:3, pId:1, name:\"test3\" , open:true}"; // String s4 = "{id:4, pId:2, name:\"test4\" , open:true}"; // List<String> lstTree = new ArrayList<String>(); // lstTree.add(s1); // lstTree.add(s2); // lstTree.add(s3); // lstTree.add(s4); // //利用Json插件将Array转换成Json格式 // JSONArray.fromObject(lstTree).toString(); // j.setMsg("编辑成功"); // } catch (Exception e) { // log.info(e.getMessage()); // j.setSuccess(false); // j.setMsg("获取权限失败"); // } // return j; //} @RequestMapping(value="/getAuthTree",produces="text/plain;charset=UTF-8") @ResponseBody public String getAuthTree(HttpServletRequest request, HttpServletResponse response) { String tree = ""; try { String authId = request.getParameter("authId"); //所有权限 List<MenuFunction> allAuthList = jwSystemAuthService.queryMenuAndFuncAuth(); tree = SystemUtil.listTreeToAuth(allAuthList,authId); log.info("权限树: " + tree); }catch (Exception e){ log.info(e.getMessage()); } return tree; }