Java Code Examples for org.springframework.web.bind.annotation.RequestBody

The following are top voted examples for showing how to use org.springframework.web.bind.annotation.RequestBody. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CommonInformationSpace   File: CISCoreConnectorRestController.java   Source Code and License 7 votes vote down vote up
@RequestMapping(value = "/CISCore/postmessage/other", method = RequestMethod.POST)
public ResponseEntity<Response> testConnectorCallback(@RequestBody CISOtherContent otherpayload) {
	log.info("--> testConnectorCallback");
	Response response = new Response();
	
	log.info(otherpayload);
	
	log.info("testConnectorCallback -->");
	return new ResponseEntity<Response>(response, HttpStatus.OK);
}
 
Example 2
Project: jobManage   File: JobManageController.java   Source Code and License 7 votes vote down vote up
/**
	 * 更新当前全部记录
	 * @throws InterruptedException 
	 * @throws IOException 
	 */
	@RequestMapping(value= "/updateAllRecord", method=RequestMethod.POST)
	public String updateAllRecord(@RequestBody List<Object> updateRecordList) throws IOException, InterruptedException {
		String executeFile = getExecuteFile();
		ArrayList<Thread> threadList = new ArrayList<Thread>();
		for(int i=0; i < updateRecordList.size(); i++) {
			HashMap<String, String> allRecord = (HashMap<String, String>) updateRecordList.get(i);
//			executePy(allRecord.get("jobTable"), allRecord.get("jobPath"), allRecord.get("jobName"), 
//					allRecord.get("jobDay"), allRecord.get("jobType"), executeFile);
			Thread newThread = new Thread(new MyRunable(allRecord, executeFile));
			newThread.start();
			threadList.add(newThread);

		}
		
		for(Thread thread: threadList) {
			thread.join();
		} 
		
		System.out.println("主线程执行完毕");
		return "index";
	}
 
Example 3
Project: va-vedem-api   File: MailAPI.java   Source Code and License 7 votes vote down vote up
@ApiOperation(value = "Trimite email.", tags = {"email"})
@RequestMapping(value = {"/mail"}, method = {RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_VALUE,
        consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<String> sendEmail(@RequestBody @Valid EmailModel model) {
    logger.info("start: trimitere email");

    try {
        mailService.send(model);
    } catch (VaVedemApiException ex) {
        if (ex instanceof VaVedemEmailException) {
            logger.info(ex.getMessage());
            return new ResponseEntity("error send email", HttpStatus.BAD_REQUEST);
        }
    }

    return new ResponseEntity<String>(HttpStatus.OK);
}
 
Example 4
Project: participants1b   File: UpdateInfoController.java   Source Code and License 7 votes vote down vote up
@RequestMapping(
		value = "/changeInfo",
		method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE },
		consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ResponseEntity<ChangePasswordInfo> postHTML2(@RequestBody ChangePassword info){

	if (info.getEmail() == null || info.getPassword() == null || info.getNewPassword() == null
			|| info.getEmail().equals("") || info.getPassword().equals("") || info.getNewPassword().equals("")) {
		throw new HTTP404Exception("No se han introducido todos los datos");
	}
	
	Ciudadano ci = updateInfo.UpdateCitizen(info);
	
	if (ci == null) {
		throw new HTTP404Exception("Email o contraseña incorrectas");
	}
	
	
	return new ResponseEntity<ChangePasswordInfo>(new ChangePasswordInfo("Se ha cambiado correctamente la contraseña"),
			HttpStatus.OK);
}
 
Example 5
Project: app-auth-example   File: DirectoryWebhookController.java   Source Code and License 6 votes vote down vote up
/**
 * Create / update pod info.  This endpoint is protected by an "API key" to prevent unauthorized access which
 * could inject bogus pod information into the PodDirectory. For this implementation, the API key is just a
 * hardcoded constant.  Real implementations probably want something more secure - at least a different API key
 * for each pod. The API key is passed as an HTTP header value with name "X-API-KEY".
 *
 * @param podInfo PodInfo object containing metadata about a pod
 * @param apiKey API Key.  Comes from HTTP Header value "X-API-KEY"
 *
 * @return HTTP 401 - if API key missing or invalid<br/>
 *         HTTP 400 - if PodInfo bad or missing<br/>
 *         HTTP 200 - otherwise.
 */
@RequestMapping(method = RequestMethod.POST, path = "/podInfo")
public ResponseEntity updatePodInfo(@RequestBody PodInfo podInfo, @RequestHeader("X-API-KEY") String apiKey) {

    // Check API key
    if (StringUtils.isEmpty(apiKey) || !webhookConfiguration.getApiKey().equals(apiKey)) {
        return new ResponseEntity(HttpStatus.UNAUTHORIZED);
    }

    // Ensure pod info present and at least has company ID.
    if (StringUtils.isEmpty(podInfo.getCompanyId())) {
        return new ResponseEntity(HttpStatus.BAD_REQUEST);
    }

    // Store pod info
    podDirectory.addPodInfo(podInfo);

    return new ResponseEntity(HttpStatus.OK);

}
 
Example 6
Project: Spring-Boot-Server   File: AppUserEvaluateRestful.java   Source Code and License 6 votes vote down vote up
@RequestMapping(value = "/updateOE_HEL_SP_AI_Stars")
@ResponseBody
public PageData updateOE_HEL_SP_AI_Stars(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("OE_TYPE"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		if("1".equals(pd.getString("OE_TYPE"))){//专家
			appUserEvaluateMapper.updateHEL_STARS(pd);
		}else if("2".equals(pd.getString("OE_TYPE"))){//代理
			appUserEvaluateMapper.updateSP_STARS(pd);
		}else if("3".equals(pd.getString("OE_TYPE"))){//陪诊
			appUserEvaluateMapper.updateAI_STARS(pd);
		}
		return WebResult.requestSuccess();
	}
}
 
Example 7
Project: Spring-Boot-Server   File: AppDoctorInfoRestful.java   Source Code and License 6 votes vote down vote up
/**
 * 医生信息
 * @return
 */
@RequestMapping(value = "/get")
@ResponseBody
public PageData getDoctorInfo(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("HEL_ID"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		PageData earnestMoney = appServiceMapper.getEarestMoney();
		String searnestMoney = earnestMoney.getString("CODE");
		float f = Float.valueOf("500");
		if (StringUtils.isNotBlank(searnestMoney)) {
			f = Float.valueOf(searnestMoney);
		}
		PageData accInfo = appDoctorInfoMapper.getDoctorInfo(pd);
		accInfo.put("EARNEST_MONEY", f);
		List<PageData> videoList = appDoctorInfoMapper.getDoctorVideoList(pd);
		accInfo.put("videoList", videoList);
		List<PageData> deptVideoList = appDoctorInfoMapper.getDeptVideoList(accInfo);
		accInfo.put("deptVideoList", deptVideoList);
		return WebResult.requestSuccess(accInfo);
	}
}
 
Example 8
Project: calculator   File: CalcController.java   Source Code and License 6 votes vote down vote up
@PostMapping("history")
public ResponseEntity<?> add(@RequestBody CalcEntry entry) {
	
	try
	{
		entry = CalcWorker.getResult( entry );
	}
	catch (CalcException e)
	{
		LOGGER.error("Exception while calculation result for {}", entry.getOperation());
		// TODO: Stacktrace in logger
		
		// TODO: Error Message (not only Error Status) to Frontend?
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
	}
	
	return ResponseEntity.ok(repo.save(entry));
}
 
Example 9
Project: borabeber-api   File: AuthenticationController.java   Source Code and License 6 votes vote down vote up
/**
 * Gera e retorna um novo token JWT.
 * 
 * @param authenticationDto
 * @param result
 * @return ResponseEntity<Response<TokenDto>>
 * @throws AuthenticationException
 */
@PostMapping
public ResponseEntity<Response<TokenDto>> gerarTokenJwt(
		@Valid @RequestBody JwtAuthenticationDto authenticationDto, BindingResult result)
		throws AuthenticationException {
	Response<TokenDto> response = new Response<TokenDto>();

	if (result.hasErrors()) {
		log.error("Erro validando lançamento: {}", result.getAllErrors());
		result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
		return ResponseEntity.badRequest().body(response);
	}

	log.info("Gerando token para o email {}.", authenticationDto.getEmail());
	Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(
			authenticationDto.getEmail(), authenticationDto.getSenha()));
	SecurityContextHolder.getContext().setAuthentication(authentication);

	UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationDto.getEmail());
	String token = jwtTokenUtil.obterToken(userDetails);
	response.setData(new TokenDto(token));

	return ResponseEntity.ok(response);
}
 
Example 10
Project: cas-server-4.2.1   File: RegisteredServiceSimpleFormController.java   Source Code and License 6 votes vote down vote up
/**
 * Adds the service to the Service Registry.
 * @param request the request
 * @param response the response
 * @param result the result
 * @param service the edit bean
 */
@RequestMapping(method = RequestMethod.POST, value = {"saveService.html"})
public void saveService(final HttpServletRequest request,
                        final HttpServletResponse response,
                        @RequestBody final RegisteredServiceEditBean.ServiceData service,
                        final BindingResult result) {
    try {

        final RegisteredService svcToUse = registeredServiceFactory.createRegisteredService(service);
        final RegisteredService newSvc = this.servicesManager.save(svcToUse);
        logger.info("Saved changes to service {}", svcToUse.getId());

        final Map<String, Object> model = new HashMap<>();
        model.put("id", newSvc.getId());
        model.put("status", HttpServletResponse.SC_OK);
        JsonViewUtils.render(model, response);

    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 11
Project: NGB-master   File: BedController.java   Source Code and License 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = "/bed/track/histogram", method = RequestMethod.POST)
@ApiOperation(
        value = "Returns a histogram of BED records amount on regions of chromosome",
        notes = "It provides histogram for a BEd track with the given scale factor between the " +
                "beginning position with the first base having position 1 and ending position inclusive " +
                "in a target chromosome. All parameters are mandatory and described below:<br/><br/>" +
                "1) <b>id</b> specifies ID of a track;<br/>" +
                "2) <b>chromosomeId</b> specifies ID of a chromosome corresponded to a track;<br/>" +
                "3) <b>startIndex</b> is the most left base position for a requested window. The first base in a " +
                "chromosome always has got position 1;<br/>" +
                "4) <b>endIndex</b> is the last base position for a requested window. " +
                "It is treated inclusively;<br/>" +
                "5) <b>scaleFactor</b> specifies an inverse value to number of bases per one visible element" +
                " on a track (e.g., pixel) - IS IGNORED FOR NOW",
        produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
        value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
        })
public Result<Track<Wig>> loadHistogram(@RequestBody final TrackQuery trackQuery)
        throws HistogramReadingException {
    final Track<Wig> histogramTrack = convertToTrack(trackQuery);
    return Result.success(bedManager.loadHistogram(histogramTrack));
}
 
Example 12
Project: iBase4J   File: ScheduledController.java   Source Code and License 6 votes vote down vote up
@PostMapping
@ApiOperation(value = "新增任务")
@RequiresPermissions("sys.task.scheduled.update")
public Object updateTask(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	Assert.notNull(scheduled.getJobType(), "JOBTYPE");
	Assert.notNull(scheduled.getTaskType(), "TASKTYPE");
	Assert.notNull(scheduled.getTargetObject(), "TARGETOBJECT");
	Assert.notNull(scheduled.getTargetMethod(), "TARGETMETHOD");
	Assert.notNull(scheduled.getTaskCron(), "TASKCRON");
	Assert.notNull(scheduled.getTaskDesc(), "TASKDESC");
	if (TaskType.dubbo.equals(scheduled.getTaskType())) {
		Assert.notNull(scheduled.getTargetSystem(), "TARGETSYSTEM");
	}
	scheduledService.updateTask(scheduled);
	return setSuccessModelMap(modelMap);
}
 
Example 13
Project: SilkAppDriver   File: W3CProtocolController.java   Source Code and License 5 votes vote down vote up
/**
 * Implements the "Execute Async Script" command See
 * https://www.w3.org/TR/webdriver/#dfn-execute-async-script
 */
@RequestMapping(value = "/session/{sessionId}/execute/async", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public @ResponseBody ResponseEntity<Response> executeAsyncScript(@PathVariable String sessionId,
		@RequestBody(required = false) String body) throws Throwable {
	LOGGER.info("executeAsyncScript -->");
	LOGGER.info("  -> " + body);
	LOGGER.info("  <- ERROR: unknown command");
	LOGGER.info("executeAsyncScript <--");

	return responseFactory.error(sessionId, ProtocolError.UNKNOWN_COMMAND);
}
 
Example 14
Project: device-mqtt   File: UpdateController.java   Source Code and License 5 votes vote down vote up
public void addWatcher(@RequestBody String provisionWatcher) {
  if (provisionWatcher != null) {
    if (update.addWatcher(provisionWatcher)) {
      logger.debug("New device watcher received to add devices with provision watcher id:"
          + provisionWatcher);
    } else {
      logger.error("Received add device provision watcher request without an id attached.");
      throw new NotFoundException("provisionWatcher", provisionWatcher);
    }
  }
}
 
Example 15
Project: WeiMusicCommunity-server   File: PathController.java   Source Code and License 5 votes vote down vote up
@RequestMapping(produces = "application/json")
public ResponseEntity<HttpJson> getPathTest(@RequestBody String test) {
    HttpJson inObj = new HttpJson(test);
    HttpJson json = new HttpJson();
    UserExtend ue = new UserExtend();
    json.setClassObject(ue);
    json.setClassName(String.class.toString());

    return new ResponseEntity<HttpJson>(json, HttpStatus.ACCEPTED);
}
 
Example 16
Project: CommonInformationSpace   File: CISAdaptorConnectorRestController.java   Source Code and License 5 votes vote down vote up
@RequestMapping(value = "/CISCore/postmessage/xml", method = RequestMethod.POST)
public ResponseEntity<Response> testXMLConnectorCallback(@RequestBody CISXMLContent xmlpayload) {
	log.info("--> testXMLConnectorCallback");
	Response response = new Response();
	
	log.info(xmlpayload);
	
	log.info("testXMLConnectorCallback -->");
	return new ResponseEntity<Response>(response, HttpStatus.OK);
}
 
Example 17
Project: happy-news   File: AdminPostController.java   Source Code and License 5 votes vote down vote up
/**
 * Create or replace a post. The post will be validated using {@link PostValidator}.
 *
 * @param uuid The UUID.
 * @param post The post content.
 * @return The new state of the post.
 */
@ApiOperation("Create or replace a post")
@RequestMapping(value = "/{uuid}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Post> updatePost(@PathVariable String uuid, @Valid @RequestBody Post post) {
    post.setUuid(uuid);

    try {
        return ResponseEntity
            .ok(postRepository.save(post));
    } catch (Exception e) {
        logger.error("Could not update post.", e);
        throw new PostCreationException("Could not update post.", e);
    }
}
 
Example 18
Project: product-management-system   File: UserController.java   Source Code and License 5 votes vote down vote up
/**
 * Creating {@link User} from client form.
 */
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public UserDto createUser(@RequestBody @Valid final UserDto userDto) {
    log.info("Start createUser: {}", userDto.getUsername());
    final User user = mapper.map(userDto, User.class);
    return mapper.map(userService.create(user), UserDto.class);
}
 
Example 19
Project: SilkAppDriver   File: W3CProtocolController.java   Source Code and License 5 votes vote down vote up
/**
 * Implements the "Get Window Rect" command See
 * https://www.w3.org/TR/webdriver/#dfn-get-window-rect
 */
@RequestMapping(value = "/session/{sessionId}/window/rect", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
public @ResponseBody ResponseEntity<Response> getWindowRect(@PathVariable String sessionId,
		@RequestBody(required = false) String body) throws Throwable {
	LOGGER.info("getWindowRect -->");

	Rect result = sessionManager.getSession(sessionId).getCurrentWindowRect();

	LOGGER.info("  <- " + result);
	LOGGER.info("getWindowRect <--");

	return responseFactory.success(sessionId,
			new ElementGetRectResponse(result.getX(), result.getY(), result.getWidth(), result.getHeight()));
}
 
Example 20
Project: pinkyLam-Blog-Server   File: MemoRemindController.java   Source Code and License 5 votes vote down vote up
@RequestMapping("saveMemoRemind")
public ExecuteResult<Boolean> saveMemoRemind(@RequestBody MemoRemind memoRemind) {
	final ExecuteResult<Boolean> result = new ExecuteResult<>();
	try {
		memoRemind.setCreateTime(new Date());
		memoRemindDao.save(memoRemind);
		result.setSuccess(true);
	} catch (final Exception e) {
		logger.error("", e);
		result.setSuccess(false);
		result.setErrorCode(ErrorCode.EXCEPTION.getErrorCode());
		result.setErrorMsg(ErrorCode.EXCEPTION.getErrorMsg());
	}
	return result;
}
 
Example 21
Project: Spring-Boot-Server   File: ShareRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 查看图片信息
 * 
 * @param pd
 *            参数
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/selectPic")
public PageData selectPic(@RequestBody PageData pd) throws Exception {
	List<PageData> lists = null;
	PageData pds = pd;
	lists = shareMapper.selectPic(pds);
	pd.put("lists", lists);
	return WebResult.requestSuccess(pd);
}
 
Example 22
Project: iBase4J   File: ScheduledController.java   Source Code and License 5 votes vote down vote up
@PostMapping("/run")
@ApiOperation(value = "立即执行任务")
@RequiresPermissions("sys.task.scheduled.run")
public Object exec(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	scheduledService.execTask(scheduled);
	return setSuccessModelMap(modelMap);
}
 
Example 23
Project: oneops   File: DpmtRestController.java   Source Code and License 5 votes vote down vote up
@RequestMapping(value="/dj/simple/approvals/{approvalId}", method = RequestMethod.PUT)
@ResponseBody
public CmsDpmtApproval dpmtApprove(
		@RequestBody CmsDpmtApproval approval, @PathVariable long approvalId,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope,
		@RequestHeader(value="X-Cms-User", required = true)  String userId){
	
	approval.setUpdatedBy(userId);
	
    djManager.updateApprovalList(Arrays.asList(approval));
    return djManager.getDeploymentApproval(approval.getApprovalId());
}
 
Example 24
Project: project-template   File: ProductController.java   Source Code and License 5 votes vote down vote up
@ApiOperation(value = "Catalogue new product or update existing one")
@ApiResponses({
        @ApiResponse(code = 201, message = "Successfully catalogue product"),
        @ApiResponse(code = 428, message = "Invalid product info", response = ErrorDto.class)})
@ResponseStatus(code = HttpStatus.CREATED)
@PostMapping
public ProductDto catalogue(@ApiParam(value = "Product data", name = "Product",
        required = true) @Validated @RequestBody ProductDto productDto) {
    return productService.catalogue(productDto);
}
 
Example 25
Project: Mastering-Spring-5.0   File: TodoController.java   Source Code and License 5 votes vote down vote up
@PostMapping("/users/{name}/todos")
ResponseEntity<?> add(@PathVariable String name, @RequestBody Todo todo) {
	Todo createdTodo = todoService.addTodo(name, todo.getDesc(), todo.getTargetDate(), todo.isDone());
	if (createdTodo == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
			.buildAndExpand(createdTodo.getId()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example 26
Project: Spring-Boot-Server   File: AccompanyInfoRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 删除
 * 
 * @param pd
 *            参数
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/toDelete")
public PageData toDelete(@RequestBody PageData pd) throws Exception {
	String s_IDS = pd.getString("IDS");
	if(null != s_IDS && !"".equals(s_IDS)){
		pd.put("IDSs", s_IDS.split(","));
		accompanyInfoMapper.delete(pd);
		pd.put("msg", "success");
	}else{
		pd.put("msg", "failed");
	}
	return WebResult.requestSuccess(pd);
}
 
Example 27
Project: WeiMusicCommunity-server   File: CommityContorller.java   Source Code and License 5 votes vote down vote up
@RequestMapping("isMemIn")
public ResponseEntity<HttpJson> isExistMem(@RequestBody String jsonString) {
    return ControllerFreamwork.excecute(jsonString, CommityMember.class, "CommityMember:isMemberExist", new ControllerFreamwork.ControllerFuntion() {
        @Override
        public HttpJson thisControllerDoing(HttpJson inObj, HttpJson re) throws Exception {
            CommityMember member = (CommityMember) inObj.getClassObject();
            boolean flag = commityService.isMemExist(member);
            re.setClassObject(flag);
            return re;
        }
    });
}
 
Example 28
Project: Spring-Boot-Server   File: ConstantRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @Description: 修改系统常量保存
 * @param pd
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/saveEdit")
public Object saveEdit(@RequestBody PageData pd) throws Exception{
		Map<String, Object> msg = new HashMap<String, Object>();
		//用户id
		constantMapper.edit(pd);
		msg.put("msg", "success");
		//结果集封装
		return WebResult.requestSuccess(msg);
}
 
Example 29
Project: Spring-Boot-Server   File: AppSpRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 订单评价
 * @return
 */
@RequestMapping(value = "/getEvaluateOfSpOrder")
@ResponseBody
public PageData getEvaluateOfSpOrder(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("O_ID"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		PageData npd = appSpMapper.getEvaluateOfSpOrder(pd);
		return WebResult.requestSuccess(npd);
	}
}
 
Example 30
Project: WeiMusicCommunity-server   File: RegistContoller.java   Source Code and License 5 votes vote down vote up
@RequestMapping(value = "common",produces = "application/json;charset=UTF-8")
public ResponseEntity<HttpJson> Regist(@RequestBody String inObj){

    HttpJson re = new HttpJson(), input = new HttpJson(inObj);
    String thisFormType = input.getClassName();
    if (!thisFormType.equals("form:regist")){
        re.setStatusCode(250);
        re.setMessage("不匹配的请求");
        return new ResponseEntity<HttpJson>(re, HttpStatus.BAD_REQUEST);
    }
    String getRegistType = input.getPara("style");
    String getUserName = input.getPara("username");
    String getUserPwd = input.getPara("password");

    Login login = new Login();
    login.setUPwd(getUserPwd);
    login.setUAName(getUserName);

    String flag = "-2";
    try {
        flag = registService.registUserWithType(login,getRegistType);
    } catch (Exception e) {
        e.printStackTrace();
        re.setMessage("服务器出错");
        re.setStatusCode(202);
        re.constractJsonString();
        return new ResponseEntity<HttpJson>(re,HttpStatus.BAD_GATEWAY);
    }

    if (flag.equals("-1")){
        re.setMessage("用户已存在,请检查用户名");
        re.setStatusCode(201);
    }else if(flag.equals("-2")){
        re.setStatusCode(202);
        re.setMessage("服务器太忙,请稍后再试");
    }else{
        re.setMessage("UserUUid");
        re.setClassObject(String.class.toString());
        re.setClassObject(flag);
    }

    re.constractJsonString();

    return new ResponseEntity<HttpJson>(re,HttpStatus.ACCEPTED);
}
 
Example 31
Project: Spring-Boot-Server   File: AppUserInfoRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 用户信息
 * @return
 */
@RequestMapping(value = "/get")
@ResponseBody
public PageData getUserInfo(@RequestBody PageData pd) throws Exception {
	PageData accInfo = appUserInfoMapper.getUserInfo(pd);
	return WebResult.requestSuccess(accInfo);
}
 
Example 32
Project: WIFIProbe   File: ReceiverController.java   Source Code and License 5 votes vote down vote up
@ApiOperation(value = "Post new old statistic data", notes = "Add new old customer statistic data to server",
        response = NewOldVo.class, produces = "application/json;charset=UTF-8")
@PostMapping(value = "/newOld" ,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<NewOldVo> newOld(@RequestBody List<NewOldCustomElement> elements) {
    List<NewOldVo> resultList = Lists.newArrayList();
    for (NewOldCustomElement element: elements) {
        resultList.add(newOldService.save(element));
    }
    return resultList;
}
 
Example 33
Project: Spring-Boot-Server   File: AppUserFriendRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 查看两人之间的关系状态
 * 
 * @return
 */
@RequestMapping(value = "/getTwoPersonRelation")
@ResponseBody
public PageData getTwoPersonRelation(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("UI_ID")) || StringUtils.isBlank(pd.getString("FRIEND_ID"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		PageData res = new PageData();
		List<PageData> list = appUserFriendMapper.isFirstFriend(pd);
		if (list.size() == 0) {
			res.put("STATUS", "0"); // 不是好友
		}
		else {
			PageData temp = list.get(0);
			String ui_id = pd.getString("UI_ID"); // 用户id
			if ("0".equals(temp.getString("CONFIRM_STATE"))) {
				// 未通过验证
				if (ui_id.equals(temp.getString("SPONSOR"))) {
					res.put("STATUS", "1"); // 是好友等待对方确认
				}
				else {
					res.put("STATUS", "2"); // 是好友我方确认点击确认
					res.put("CONFIRM_MSG", temp.getString("CONFIRM_MSG")); // 发送的信息
				}
			}
			else {
				res.put("STATUS", "3"); // 双方是好友
			}
		}
		return WebResult.requestSuccess(res);
	}
}
 
Example 34
Project: SilkAppDriver   File: W3CProtocolController.java   Source Code and License 5 votes vote down vote up
/**
 * Implements the "Get Page Source" command See
 * https://www.w3.org/TR/webdriver/#dfn-get-page-source
 */
@RequestMapping(value = "/session/{sessionId}/source", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
public @ResponseBody ResponseEntity<Response> getPageSource(@PathVariable String sessionId,
		@RequestBody(required = false) String body) throws Throwable {
	LOGGER.info("getPageSource -->");
	LOGGER.info("  -> " + body);
	LOGGER.info("  <- ERROR: unknown command");
	LOGGER.info("getPageSource <--");

	return responseFactory.error(sessionId, ProtocolError.UNKNOWN_COMMAND);
}
 
Example 35
Project: device-modbus   File: UpdateController.java   Source Code and License 5 votes vote down vote up
public void addDevice(@RequestBody String deviceId) {
	if (deviceId != null) {
		if (update.addDevice(deviceId)) {
			logger.debug("Added device.  Received add device request with id:" + deviceId);
		} else {
			logger.error("Received add device request without a device id attached.");
			throw new DeviceNotFoundException("no device id provided in request.");
		}
	}
}
 
Example 36
Project: Spring-Boot-Server   File: AppUserFamilyRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 根据家庭成员ID来删除家庭成员
 * @return
 */
@RequestMapping(value = "/member/delFamilyMemberByFMID")
@ResponseBody
public PageData delFamilyMemberByFMID(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("FM_ID"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		appUserFamilyMapper.delFamilyMemberByFMID(pd);
		return WebResult.requestSuccess();
	}
}
 
Example 37
Project: Spring-Boot-Server   File: UserRestful.java   Source Code and License 5 votes vote down vote up
@RequestMapping(value = "/updateGuide")
public Object updateGuide(@RequestBody PageData pd) throws Exception{
	PageData map = new PageData();
	userMapper.updateGuide(pd);
		map.put("result", "success"); // 返回结果
		// 结果集封装
		return WebResult.requestSuccess(map);
}
 
Example 38
Project: logistimo-web-service   File: AuthControllerMV1.java   Source Code and License 5 votes vote down vote up
/**
 * This method will validate user's otp
 *
 * @param otpModel consists of user id, otp
 */
@RequestMapping(value = "/validate-otp", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void validateOtp(@RequestBody ValidateOtpModel otpModel) throws ValidationException {
  AuthenticationService as;
  as = Services.getService(AuthenticationServiceImpl.class);
  as.validateOtpMMode(otpModel.uid, otpModel.otp);
}
 
Example 39
Project: iBase4J   File: ScheduledController.java   Source Code and License 5 votes vote down vote up
@DeleteMapping
@ApiOperation(value = "删除任务")
@RequiresPermissions("sys.task.scheduled.close")
public Object delete(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	scheduledService.delTask(scheduled);
	return setSuccessModelMap(modelMap);
}
 
Example 40
Project: monarch   File: ShellCommandsController.java   Source Code and License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.POST, value = "/mbean/query")
public ResponseEntity<?> queryNames(@RequestBody final QueryParameterSource query) {
  try {
    final Set<ObjectName> objectNames =
        getMBeanServer().queryNames(query.getObjectName(), query.getQueryExpression());

    return new ResponseEntity<byte[]>(IOUtils.serializeObject(objectNames), HttpStatus.OK);
  } catch (IOException e) {
    return new ResponseEntity<String>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
  }
}
 
Example 41
Project: Spring-Boot-Server   File: ImContentRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 修改按钮
 */
@RequestMapping(value = "/saveEdit")
public Object saveEdit(@RequestBody PageData pd) throws Exception {
		imContentMapper.edit(pd);
		pd.put("msg", "success");
		return WebResult.requestSuccess(pd);
}
 
Example 42
Project: devops-cstack   File: AdministrationController.java   Source Code and License 5 votes vote down vote up
/**
 * Create a new user
 *
 * @param input
 *            : {login:johndoe; firstName:john; lastName:doe;
 *            email:[email protected]; password:xxx}
 * @return JsonResponse
 * @throws ServiceException
 * @throws CheckException
 */
@ResponseBody
@RequestMapping(value = "/user", method = RequestMethod.POST)
public JsonResponse createUser(@RequestBody JsonInputForAdmin input) throws ServiceException, CheckException {

	User user = new User(input.getLogin(), input.getFirstName(), input.getLastName(), input.getOrganization(),
			input.getEmail(), input.getPassword());

	// create a new user
	user = this.userService.create(user);

	this.userService.activationAccount(user);

	return new HttpOk();
}
 
Example 43
Project: Spring-Boot-Server   File: SmsRestful.java   Source Code and License 5 votes vote down vote up
@RequestMapping("smsPush")

	public PageData smsPush(@RequestBody PageData pd){
		/*PageData pd = this.getPageData();*/

		PageData sendMsg=new PageData();
		try {
			sendMsg = sendMsgService.sendMsg(pd);
			
		} catch (Exception e) {
			e.printStackTrace();
			
		}
		return sendMsg;
	}
 
Example 44
Project: spring-ddd-bank   File: ApplicationController.java   Source Code and License 5 votes vote down vote up
@PostMapping("/client/account")
  public ResponseEntity<AccountAccessResource> createAccount(
  		@RequestBody  final String accountName,
  		final HttpMethod method, final WebRequest request
  		){
_print(method, request);
final Client client = _findClient(request);
  	final AccountAccess r = client.createAccount(accountName);
final AccountAccessResource result = new AccountAccessResource(r);
      return new ResponseEntity<>(result, HttpStatus.CREATED);
  }
 
Example 45
Project: devops-cstack   File: GitlabController.java   Source Code and License 5 votes vote down vote up
/**
 * Print if a project is created and create a webhook for new branch in this
 * project
 *
 * @param body
 *            String
 * @return String
 * @throws IOException
 */
@RequestMapping(value = "/listen/project", method = RequestMethod.POST)
public String listenProject(@RequestBody String body) throws IOException {
	ObjectMapper mapper = new ObjectMapper();
	JsonNode actualObj = mapper.readTree(body);
	if (actualObj.has("event_name")) {
		JsonNode nodeEventName = actualObj.get("event_name");
		if (nodeEventName.get("event_name").toString().equals("project_create")) {
			System.out.println("New project added !");
			addWebhookById(nodeEventName.get("project_id").asInt());
			System.out.println("Webhook of project " + nodeEventName.get("project_id").asInt() + " created.");
		}
	}
	return "Listen project ok";
}
 
Example 46
Project: projectindoorweb   File: BuildingController.java   Source Code and License 5 votes vote down vote up
@ApiOperation(value = "Add a new building", nickname = "building/addNewBuilding",
        notes = TransmissionConstants.ADD_NEW_BUILDING_NOTE)
@RequestMapping(path = "/addNewBuilding", method = POST)
public ResponseEntity addNewBuilding(@RequestBody AddNewBuilding buildingJsonWrapper) {

    ResponseWrapper result = restTransmissionService.addNewBuilding(buildingJsonWrapper);
    return HttpResultHandler.getInstance().handleLongBuildingResult(result);
}
 
Example 47
Project: swaggy-jenkins   File: CreateItemApi.java   Source Code and License 5 votes vote down vote up
@ApiOperation(value = "", notes = "Create a new job using job configuration, or copied from an existing job", response = Void.class, authorizations = {
    @Authorization(value = "jenkins_auth")
}, tags={ "remoteAccess", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Successfully created a new job", response = Void.class),
    @ApiResponse(code = 400, message = "An error has occurred - error message is embedded inside the HTML response", response = String.class),
    @ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Void.class),
    @ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Void.class) })
@RequestMapping(value = "/createItem",
    produces = { "text/html" }, 
    method = RequestMethod.POST)
ResponseEntity<Void> postCreateItem( @[email protected](value = "Name of the new job", required = true) @RequestParam(value = "name", required = true) String name,@ApiParam(value = "Existing job to copy from") @RequestParam(value = "from", required = false) String from,@ApiParam(value = "Set to 'copy' for copying an existing job") @RequestParam(value = "mode", required = false) String mode,@ApiParam(value = "Job configuration in config.xml format"  )  @Valid @RequestBody String body,@ApiParam(value = "CSRF protection token" ) @RequestHeader(value="Jenkins-Crumb", required=false) String jenkinsCrumb,@ApiParam(value = "Content type header application/xml" ) @RequestHeader(value="Content-Type", required=false) String contentType, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
 
Example 48
Project: buenojo   File: ActivityResource.java   Source Code and License 5 votes vote down vote up
/**
 * POST  /activities -> Create a new activity.
 */
@RequestMapping(value = "/activities",
    method = RequestMethod.POST,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Activity> createActivity(@Valid @RequestBody Activity activity) throws URISyntaxException {
    log.debug("REST request to save Activity : {}", activity);
    if (activity.getId() != null) {
        return ResponseEntity.badRequest().header("Failure", "A new activity cannot already have an ID").body(null);
    }
    Activity result = activityRepository.save(activity);
    return ResponseEntity.created(new URI("/api/activities/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert("activity", result.getId().toString()))
        .body(result);
}
 
Example 49
Project: device-mqtt   File: UpdateController.java   Source Code and License 5 votes vote down vote up
public void deleteWatcher(@RequestBody String provisionWatcher) {
  if (provisionWatcher != null) {
    if (update.removeWatcher(provisionWatcher)) {
      logger.debug("Remove device provision watcher with id:" + provisionWatcher);
    } else {
      logger.error("Received remove device provision watcher request without an id attached.");
      throw new NotFoundException("provisionWatcher", provisionWatcher);
    }
  }
}
 
Example 50
Project: Spring-Boot-Server   File: ConstantRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @Description: 批量删除
 * @param pd
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/delete")
public Object delete(@RequestBody PageData pd) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		String SYSTEM_CONSTANT_IDS = pd.getString("IDS");
		if (null != SYSTEM_CONSTANT_IDS && !"".equals(SYSTEM_CONSTANT_IDS)) {
			String ArraySystemConstant_IDS[] = SYSTEM_CONSTANT_IDS.split(",");
			constantMapper.delete(ArraySystemConstant_IDS);
			map.put("msg", "ok");
		} else {
			map.put("msg", "no");
		}
		//结果集封装
		return WebResult.requestSuccess(map);
}
 
Example 51
Project: buenojo   File: ActivityResource.java   Source Code and License 5 votes vote down vote up
/**
 * PUT  /activities -> Updates an existing activity.
 */
@RequestMapping(value = "/activities",
    method = RequestMethod.PUT,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Activity> updateActivity(@Valid @RequestBody Activity activity) throws URISyntaxException {
    log.debug("REST request to update Activity : {}", activity);
    if (activity.getId() == null) {
        return createActivity(activity);
    }
    Activity result = activityRepository.save(activity);
    return ResponseEntity.ok()
        .headers(HeaderUtil.createEntityUpdateAlert("activity", activity.getId().toString()))
        .body(result);
}
 
Example 52
Project: Spring-Boot-Server   File: AppDoctorRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 获得所有有专家的城市
 * @return
 */
@RequestMapping(value = "/getTheExpertCitys")
@ResponseBody
public PageData getTheExpertCitys(@RequestBody PageData pd) throws Exception {
	PageData pdResult = new PageData();
	List<PageData> pdCitys = appDoctorMapper.getTheExpertCitys(pd);
	pdResult.put("result", pdCitys);
	return WebResult.requestSuccess(pdResult);
}
 
Example 53
Project: spring-boot-additional-validation   File: ValidationController.java   Source Code and License 5 votes vote down vote up
@RequestMapping(value = "/validation", method = RequestMethod.POST)
public ResponseEntity<?> acceptData(@Valid @RequestBody Data data, Errors errors, @RequestHeader(HttpHeaders.ACCEPT_LANGUAGE) String language) {
    stringValueValidator.validate(language, data, errors);
    if (errors.hasErrors()) {
        return new ResponseEntity<>(createErrorString(errors), HttpStatus.BAD_REQUEST);
    }
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example 54
Project: ipayquery   File: StaffManageController.java   Source Code and License 5 votes vote down vote up
/**
 * 新增角色保存操作
 *
 * @param userRole
 * @param session
 * @return
 */
@RequestMapping(value = StaffManageConst.PATH_SAVE_ROLE, method = RequestMethod.POST)
public @ResponseBody Map<String, Object> saveRole(@RequestBody UserRole userRole, HttpSession session) {

    Map<String, Object> map = new HashMap<String, Object>();
    // 判断新增角色是否已经存在
    boolean flag = true;
    // 取得员工编号对应的角色id
    List<String> list = userRoleService.selectUserId(userRole);
    for (int i = 0; i < list.size(); i++) {
        String r_id = list.get(i);
        if (userRole.getR_id().equals(r_id)) {
            flag = false;
        }
    }

    if (flag) {

        // 用户角色表主键
        String ur_id = StringUtil.getUuid();
        userRole.setUr_id(ur_id);
        // 创建时间
        userRole.setCreate_time(new Date());
        // 创建人
        User user = (User) session.getAttribute(Const.SESSION_USER);
        String create_user = user.getU_name();
        userRole.setCreate_user(create_user);
        // 系统标志
        userRole.setSystem_id(Const.SYSTEM_DIF_AIGOUMS);

        userRoleService.insertRoleData(userRole);
    } else {
        map.put(StaffManageConst.ATTRIBUTE_NAME_MSG, "此员工已经授权该角色,不得重复添加!");
    }

    // 返回处理结果
    map.put(StaffManageConst.ATTRIBUTE_NAME_RESULT, Boolean.TRUE);

    return map;
}
 
Example 55
Project: pds   File: SysOssController.java   Source Code and License 5 votes vote down vote up
/**
 * 删除
 */
@RequestMapping("/delete")
@RequiresPermissions("sys:oss:all")
public R delete(@RequestBody Long[] ids){
	sysOssService.deleteBatch(ids);

	return R.ok();
}
 
Example 56
Project: Spring-Boot-Server   File: AppUserFamilyRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 根据家庭用户ID来查询家庭用户信息
 * @return
 */
@RequestMapping(value = "/member/getFamilyMemberByID")
@ResponseBody
public PageData getFamilyMemberByID(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("FM_ID"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		PageData accinfo = appUserFamilyMapper.getFamilyByID(pd);
		return WebResult.requestSuccess(accinfo);
	}
}
 
Example 57
Project: Spring-Boot-Server   File: AppUserRecommendRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 轮播信息详情
 * @return
 */
@RequestMapping(value = "/getRotationDetail")
@ResponseBody
public PageData getRotationDetail(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("ARTICLE_ID"))) {
		return WebResult.requestFailed(10001, "参数缺失!", null);
	}
	else {
		pd = appUserRecommendMapper.getRotationDetail(pd);
		return WebResult.requestSuccess(pd);
	}
}
 
Example 58
Project: Spring-Boot-Server   File: UsefulExpressionsRestful.java   Source Code and License 5 votes vote down vote up
/**
 * 列表显示和查找
 * @param pd
 * @return
 */
@RequestMapping("pageSearch")
public PageData getPageSearch(@RequestBody PageData pd) {
    List<PageData> userList = null;
    if (pd.getPageNumber() != 0) {
        PageHelper.startPage(pd.getPageNumber(), pd.getPageSize());
    }
    userList = usefulExpressionsMapper.selectAll(pd);
    // 分页
    pd = this.getPagingPd(userList);
    // 结果集封装
    return WebResult.requestSuccess(pd);
}
 
Example 59
Project: Building-Web-Apps-with-Spring-5-and-Angular   File: UserAccountController.java   Source Code and License 5 votes vote down vote up
@PostMapping(value="/signup")
public ExecutionStatus processSignup(ModelMap model, @RequestBody User reqUser) {
	User user = null;
	try {
		user = userService.doesUserExist(reqUser.getEmail());
	} catch (UserNotFoundException e) {
	}
	if(user != null) {
		return new ExecutionStatus("USER_ACCOUNT_EXISTS", "User account with same email address exists. Please try again!");
	}
	user = new User();
	user.setEmail(reqUser.getEmail());
	user.setPassword(reqUser.getPassword());
	user.setFirstName(reqUser.getFirstname());
	user.setLastname(reqUser.getLastname());
	user.setContactNumber(reqUser.getContactNumber());
	user.setAlternateContactNumber(reqUser.getAlternateContactNumber());
	user.setCityCode(reqUser.getCityCode());
	user.setStateCode(reqUser.getStateCode());
	user.setCountryCode(reqUser.getCountryCode());
	user.setAge(reqUser.getAge());
	user.setGender(reqUser.getGender());
	user.setRole(reqUser.getRole());
	User persistedUser = userService.save(user);
	//
	// Add entry in doctor table if user is a doctor
	//
	docService.addDoctor(user);
	
	return new ExecutionStatus("USER_ACCOUNT_CREATED", "User account successfully created");
}
 
Example 60
Project: device-bacnet   File: UpdateController.java   Source Code and License 5 votes vote down vote up
public void updateProfile(@RequestBody String profileId) {
	if (profileId != null) {
		if (update.updateProfile(profileId)) {
			logger.debug("Updated profile. Received update profile request with id:" + profileId);
		} else {
			logger.error("Received update profile request without a profile id attached.");
			throw new NotFoundException("profile",profileId);
		}
	}
}