Java Code Examples for org.springframework.http.MediaType#APPLICATION_JSON_UTF8_VALUE
The following examples show how to use
org.springframework.http.MediaType#APPLICATION_JSON_UTF8_VALUE .
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: UserController.java From sanshanblog with Apache License 2.0 | 6 votes |
/** * 发送邮箱验证码 * * @param type 对应的是CodyTypeEnum类型 1注册 2更改密码 */ @PostMapping(value = "/email/send", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ResponseMsgVO sendEmailCode( @RequestParam(name = "type") Integer type, @RequestParam(name = "email") String email, @RequestParam(name = "codeid") String codeid, @RequestParam(name = "code") String code) { ResponseMsgVO responseMsgVO = new ResponseMsgVO(); //验证码 String codeKey = ConstanceCacheKey.CODE_ID_PREFIX + codeid; String codeValidate = redisTemplate.opsForValue().get(codeKey); if (!code.equalsIgnoreCase(codeValidate)) { return new ResponseMsgVO().buildWithMsgAndStatus(PosCodeEnum.PARAM_ERROR, "验证码错误"); } userService.sendEmailCode(type, email, responseMsgVO); return responseMsgVO; }
Example 2
Source File: NewOldController.java From WIFIProbe with Apache License 2.0 | 5 votes |
@ApiOperation(value = "NewOld Statistic", notes = "Query new old customer statistic data", response = NewOldVo.class, responseContainer = "list",produces = "application/json;charset=UTF-8") @PostMapping(value = "/stat",produces= MediaType.APPLICATION_JSON_UTF8_VALUE) public ResultVo<List<NewOldVo>> getStatInfo(@Valid @RequestBody StatQueryJson queryJson) throws ParamException { List<NewOldVo> newOldVos = service.getNewOldStat(queryJson.getStartHour(), QueryThreshold.valueOf(queryJson.getThreshold()),queryJson.getStartRange(),queryJson.getProbeId()); return new ResultVo<>(ServerCode.SUCCESS, predictService.predictNewOldVos(newOldVos, QueryThreshold.valueOf(queryJson.getThreshold()))); }
Example 3
Source File: TomcatManageController.java From Jpom with MIT License | 5 votes |
/** * 删除文件 * * @return 操作结果 */ @RequestMapping(value = "deleteFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody @OptLog(UserOperateLogV1.OptType.Del_File_Tomcat) @Feature(method = MethodFeature.DEL_FILE) public String deleteFile() { return tomcatService.deleteFile(getNode(), getRequest()); }
Example 4
Source File: InSightDataService.java From Insights with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/db/graph", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public JsonObject addProjectMapping(@RequestParam String cypher) { if (cypher == null || !cypher.contains(":PROJECT_TEMPLATE")) { return PlatformServiceUtil.buildFailureResponse("Project template is not specified"); } Map<String, String> grafanaResponseCookies = new HashMap(); List<String> projectLabels = new ArrayList<String>(); if (!grafanaResponseCookies.isEmpty()) { String grafanaOrg = grafanaResponseCookies.get("grafanaOrg"); // String grafanaUser = grafanaResponseCookies.get("grafana_user"); ProjectMappingDAL projectMappingDAL = new ProjectMappingDAL(); List<ProjectMapping> projectMappings = projectMappingDAL .fetchProjectMappingByOrgId(Integer.valueOf(grafanaOrg)); for (ProjectMapping projectMapping : projectMappings) { projectLabels.add(projectMapping.getProjectName()); } } if (projectLabels.size() == 0) { return PlatformServiceUtil.buildFailureResponse("User is not onboarded to any project"); } StringBuffer query = new StringBuffer(); boolean isFirstDone = false; for (String projectLabel : projectLabels) { query.append("UNION "); query.append(cypher.replace("PROJECT_TEMPLATE", projectLabel)); } return null; }
Example 5
Source File: GroupAjaxController.java From spring-boot with Apache License 2.0 | 5 votes |
/** * @param search 是否是搜索请求 * @param filters 通过 jqgrid search 查询,多个查询条件时,包含查询条件为 json 格式数据。_search = false 时,jqgrid 传递过来的参数没有 filters , 此时 filters 的值为 null * @param currentPageNo 当前页码 * @param pageSize 页面可显示行数 * @param sortParameter 用于排序的列名 ,启用 groups 时,此项复杂,需要特殊解析 * @param sortDirection 排序的方式desc/asc * @return jqgrid 展示所需要的 json 结构,通过 spring 自动完成 */ @RequestMapping(value = "/jqgrid-search", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) //注意 value /jqgrid-search ,不能为 /jqgrid-search/ ,不能多加后面的斜线 @ResponseBody public JqgridPage jqgridSearch( @RequestParam("_search") Boolean search, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "page", required = true) Integer currentPageNo, @RequestParam(value = "rows", required = true) Integer pageSize, @RequestParam(value = "sidx", required = true) String sortParameter, @RequestParam(value = "sord", required = true) String sortDirection, RedirectAttributes redirectAttrs, HttpServletRequest request) { log.info("search ={},page ={},rows ={},sord={},sidx={},filters={}", search, currentPageNo, pageSize, sortDirection, sortParameter, filters); /** * 记录集 */ Page<GroupEntity> pages = JpaUtils.getJqGridPage(groupRepository, currentPageNo, pageSize, SqlUtils.createOrder(sortDirection,sortParameter), filters); if (pages.getTotalElements() == 0) return new JqgridPage(pageSize, 0, 0, new ArrayList(0)); //构造空数据集,否则返回结果集 jqgird 解析会有问题 /** * POJO to DTO * 转换原因见 service/package-info.java */ DtoUtils dtoUtils = new DtoUtils(); //用法见 DTOUtils // dtoUtils.addExcludes(MenuEntity.class, "parent"); //在整个转换过程中,无论哪个级联层次,只要遇到 TreeEntity 类,那么他的 parent 属性就不进行转换 dtoUtils.addExcludes(GroupEntity.class, "users", "roles"); JqgridPage<GroupEntity> jqPage = new JqgridPage (pages.getSize(), pages.getNumber(), (int) pages.getTotalElements(), dtoUtils.createDTOcopy(pages.getContent())); return jqPage; }
Example 6
Source File: BuildListController.java From Jpom with MIT License | 5 votes |
@RequestMapping(value = "branchList.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public String branchList( @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "仓库地址不正确")) String url, @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "登录账号")) String userName, @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "登录密码")) String userPwd) throws GitAPIException, IOException { List<String> list = GitUtil.getBranchList(url, userName, userPwd); return JsonMessage.getString(200, "ok", list); }
Example 7
Source File: AgentController.java From DrivingAgency with MIT License | 5 votes |
@PostMapping(value = "/password/reset",produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public ResponseResult<AgentBaseInfoVo> passwordReset(@RequestHeader(value = "token",required = true)String token ,@RequestParam("username")String username,@RequestParam("newPassword")String newPassword, @RequestParam("password")String password ,@RequestParam("code")String validateCode){ AgentBaseInfoVo baseInfoVo = agentService.resetPassword(token,username,newPassword,password,validateCode); if (baseInfoVo != null) { return ResponseResult.createBySuccess("密码重置成功",baseInfoVo); } return ResponseResult.createByError("密码重置失败"); }
Example 8
Source File: InstallController.java From Jpom with MIT License | 5 votes |
/** * 初始化提交 * * @param userName 系统管理员登录名 * @param userPwd 系统管理员的登录密码 * @return json */ @RequestMapping(value = "install_submit.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @NotLogin @ResponseBody public String installSubmit( @ValidatorConfig(value = { @ValidatorItem(value = ValidatorRule.NOT_EMPTY, msg = "登录名不能为空"), @ValidatorItem(value = ValidatorRule.NOT_BLANK, range = "3:20", msg = "登录名长度范围3-20"), @ValidatorItem(value = ValidatorRule.WORD, msg = "登录名不能包含汉字并且不能包含特殊字符") }) String userName, @ValidatorConfig(value = { @ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "密码不能为空") }) String userPwd) { if (!userService.userListEmpty()) { return JsonMessage.getString(100, "系统已经初始化过啦,请勿重复初始化"); } if (JpomApplication.SYSTEM_ID.equalsIgnoreCase(userName) || UserModel.SYSTEM_ADMIN.equals(userName)) { return JsonMessage.getString(400, "当前登录名已经被系统占用啦"); } // 创建用户 UserModel userModel = new UserModel(); userModel.setName(UserModel.SYSTEM_OCCUPY_NAME); userModel.setId(userName); userModel.setPassword(userPwd); userModel.setParent(UserModel.SYSTEM_ADMIN); try { userService.addItem(userModel); } catch (Exception e) { DefaultSystemLog.getLog().error("初始化用户失败", e); return JsonMessage.getString(400, "初始化失败"); } // 自动登录 setSessionAttribute(LoginInterceptor.SESSION_NAME, userModel); return JsonMessage.getString(200, "初始化成功"); }
Example 9
Source File: UploadFileController.java From erp-framework with MIT License | 5 votes |
@RequestMapping(value = "/videolist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ModelAndView list(HttpServletRequest request, HttpServletResponse response) { ModelAndView modelAndView = new ModelAndView("/upload/uploadvideo"); modelAndView.addObject("typeList", VIDEO_TYPE); modelAndView.addObject("button", "多视频上传"); return modelAndView; }
Example 10
Source File: OutGivingProjectController.java From Jpom with MIT License | 5 votes |
@RequestMapping(value = "getItemData.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public String getItemData(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "id error") String id) throws IOException { OutGivingModel outGivingServerItem = outGivingServer.getItem(id); Objects.requireNonNull(outGivingServerItem, "没有数据"); List<OutGivingNodeProject> outGivingNodeProjectList = outGivingServerItem.getOutGivingNodeProjectList(); JSONArray jsonArray = new JSONArray(); outGivingNodeProjectList.forEach(outGivingNodeProject -> { NodeModel nodeModel = nodeService.getItem(outGivingNodeProject.getNodeId()); JSONObject jsonObject = new JSONObject(); JSONObject projectInfo = null; try { projectInfo = projectInfoService.getItem(nodeModel, outGivingNodeProject.getProjectId()); } catch (Exception e) { jsonObject.put("errorMsg", "error " + e.getMessage()); } jsonObject.put("nodeId", outGivingNodeProject.getNodeId()); jsonObject.put("projectId", outGivingNodeProject.getProjectId()); jsonObject.put("nodeName", nodeModel.getName()); if (projectInfo != null) { jsonObject.put("projectName", projectInfo.getString("name")); } jsonObject.put("projectStatus", false); jsonObject.put("outGivingStatus", outGivingNodeProject.getStatusMsg()); jsonObject.put("outGivingResult", outGivingNodeProject.getResult()); jsonObject.put("lastTime", outGivingNodeProject.getLastOutGivingTime()); jsonArray.add(jsonObject); }); return JsonMessage.getString(200, "", jsonArray); }
Example 11
Source File: RoleAjaxController.java From spring-boot with Apache License 2.0 | 5 votes |
/** * 查看菜单 * * @param search 是否是搜索请求 * @param filters 通过 jqgrid search 查询,多个查询条件时,包含查询条件为 json 格式数据。_search = false 时,jqgrid 传递过来的参数没有 filters , 此时 filters 的值为 null * @param currentPageNo 当前页码 * @param pageSize 页面可显示行数 * @param parameter 用于排序的列名 ,启用 groups 时,此项复杂,需要特殊解析 * @param direction 排序的方式desc/asc * @return jqgrid 展示所需要的 json 结构,通过 spring 自动完成 */ @RequestMapping(value = "/jqgrid-search", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) //注意 value /jqgrid-search ,不能为 /jqgrid-search/ ,不能多加后面的斜线 @ResponseBody public JqgridPage jqgridSearch( @RequestParam("_search") Boolean search, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "page", required = true) Integer currentPageNo, @RequestParam(value = "rows", required = true) Integer pageSize, @RequestParam(value = "sidx", required = true) String parameter, @RequestParam(value = "sord", required = true) String direction, RedirectAttributes redirectAttrs, HttpServletRequest request) { log.info("search ={},page ={},rows ={},sord={},sidx={},filters={}", search, currentPageNo, pageSize, direction, parameter, filters); /** * 记录集 */ Page<RoleEntity> pages = JpaUtils.getJqGridPage(roleRepository, currentPageNo, pageSize, SqlUtils.createOrder(direction,parameter), filters); if (pages.getTotalElements() == 0) return new JqgridPage(pageSize, 0, 0, new ArrayList()); //构造空数据集,否则返回结果集 jqgird 解析会有问题 /** * POJO to DTO * 转换原因见 service/package-info.java */ DtoUtils dtoUtils = new DtoUtils(); //用法见 DTOUtils // dtoUtils.addExcludes(MenuEntity.class, "parent"); //在整个转换过程中,无论哪个级联层次,只要遇到 TreeEntity 类,那么他的 parent 属性就不进行转换 dtoUtils.addExcludes(RoleEntity.class, "treeNodes", "users", "groups"); JqgridPage<RoleEntity> jqPage = new JqgridPage (pages.getSize(), pages.getNumber(), (int) pages.getTotalElements(), dtoUtils.createDTOcopy(pages.getContent())); return jqPage; }
Example 12
Source File: NodeIndexController.java From Jpom with MIT License | 5 votes |
@RequestMapping(value = "node_status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody @Feature(method = MethodFeature.LIST) public String nodeStatus() { long timeMillis = System.currentTimeMillis(); JSONObject jsonObject = NodeForward.requestData(getNode(), NodeUrl.Status, getRequest(), JSONObject.class); if (jsonObject == null) { return JsonMessage.getString(500, "获取信息失败"); } JSONArray jsonArray = new JSONArray(); jsonObject.put("timeOut", System.currentTimeMillis() - timeMillis); jsonArray.add(jsonObject); return JsonMessage.getString(200, "", jsonArray); }
Example 13
Source File: RestDesformUtil.java From jeecg-cloud with Apache License 2.0 | 5 votes |
private static HttpHeaders getHeaders(String token) { HttpHeaders headers = new HttpHeaders(); String mediaType = MediaType.APPLICATION_JSON_UTF8_VALUE; headers.setContentType(MediaType.parseMediaType(mediaType)); headers.set("Accept", mediaType); headers.set("X-Access-Token", token); return headers; }
Example 14
Source File: DataDictionaryController.java From Insights with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/getToolsRelationshipAndProperties", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public JsonObject getToolsRelationshipAndProperties(@RequestParam String startLabelName, @RequestParam String startToolCategory, @RequestParam String endLabelName, @RequestParam String endToolCatergory) { return dataDictionaryService.getToolsRelationshipAndProperties(startLabelName, startToolCategory, endLabelName, endToolCatergory); }
Example 15
Source File: InsightsBulkUpload.java From Insights with Apache License 2.0 | 5 votes |
/** * entry point to get Tool Details * * @return ResponseBody */ @RequestMapping(value = "/getToolJson", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public @ResponseBody JsonObject getToolJson() { Object details = null; try { details = bulkUploadService.getToolDetailJson(); return PlatformServiceUtil.buildSuccessResponseWithData(details); } catch (InsightsCustomException e) { log.error(e.getMessage()); return PlatformServiceUtil.buildFailureResponse(e.getMessage()); } }
Example 16
Source File: NginxController.java From Jpom with MIT License | 5 votes |
@RequestMapping(value = "updateNgx", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody @OptLog(UserOperateLogV1.OptType.SaveNginx) @Feature(method = MethodFeature.EDIT) public String updateNgx() { return NodeForward.request(getNode(), getRequest(), NodeUrl.System_Nginx_updateNgx).toString(); }
Example 17
Source File: DispatcherMetaServerController.java From x-pipe with Apache License 2.0 | 4 votes |
@RequestMapping(path = META_SERVER_SERVICE.PATH.PATH_CLUSTER_CHANGE, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) public void clusterAdded(@PathVariable String clusterId, @RequestBody ClusterMeta clusterMeta, @ModelAttribute ForwardInfo forwardInfo, @ModelAttribute(MODEL_META_SERVER) MetaServer metaServer) { metaServer.clusterAdded(clusterMeta, forwardInfo.clone()); }
Example 18
Source File: BuildHistoryController.java From Jpom with MIT License | 4 votes |
@RequestMapping(value = "history_list.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody @Feature(method = MethodFeature.LOG) public String historyList(String status, @ValidatorConfig(value = { @ValidatorItem(value = ValidatorRule.POSITIVE_INTEGER, msg = "limit error") }, defaultVal = "10") int limit, @ValidatorConfig(value = { @ValidatorItem(value = ValidatorRule.POSITIVE_INTEGER, msg = "page error") }, defaultVal = "1") int page, String buildDataId) { Page pageObj = new Page(page, limit); Entity entity = Entity.create(); // this.doPage(pageObj, entity, "startTime"); BaseEnum anEnum = null; if (StrUtil.isNotEmpty(status)) { Integer integer = Convert.toInt(status); if (integer != null) { anEnum = BaseEnum.getEnum(BuildModel.Status.class, integer); } } if (anEnum != null) { entity.set("status", anEnum.getCode()); } if (StrUtil.isNotBlank(buildDataId)) { entity.set("buildDataId", buildDataId); } PageResult<BuildHistoryLog> pageResult = dbBuildHistoryLogService.listPage(entity, pageObj); List<BuildHistoryLogVo> buildHistoryLogVos = new ArrayList<>(); pageResult.forEach(buildHistoryLog -> { BuildHistoryLogVo historyLogVo = new BuildHistoryLogVo(); BeanUtil.copyProperties(buildHistoryLog, historyLogVo); String dataId = buildHistoryLog.getBuildDataId(); BuildModel item = buildService.getItem(dataId); if (item != null) { historyLogVo.setBuildName(item.getName()); } buildHistoryLogVos.add(historyLogVo); }); JSONObject jsonObject = JsonMessage.toJson(200, "获取成功", buildHistoryLogVos); jsonObject.put("total", pageResult.getTotal()); return jsonObject.toString(); }
Example 19
Source File: ActivenessController.java From WIFIProbe with Apache License 2.0 | 4 votes |
@ApiOperation(value = "Activeness Statistic Detail", notes = "Query detail activeness statistic data by id", response = ActivenessVo.class,produces = "application/json;charset=UTF-8") @GetMapping(value = "/id",produces= MediaType.APPLICATION_JSON_UTF8_VALUE) public ResultVo<ActivenessVo> getById(@RequestParam int id) throws ServerException { return new ResultVo<>(ServerCode.SUCCESS, service.findById(id)); }
Example 20
Source File: FileFeignClient.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostMapping(value = "/v1/files", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) ResponseEntity<String> uploadFile(@RequestParam("bucket_name") String bucketName, @RequestParam("file_name") String fileName, @RequestPart("file") MultipartFile multipartFile);