org.springframework.web.bind.annotation.PatchMapping Java Examples

The following examples show how to use org.springframework.web.bind.annotation.PatchMapping. 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: ViewRowEditRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
@PatchMapping
public JSONViewRow patchRow(
		@PathVariable(PARAM_WindowId) final String windowIdStr,
		@PathVariable(PARAM_ViewId) final String viewIdStr,
		@PathVariable(PARAM_RowId) final String rowIdStr,
		@RequestBody final List<JSONDocumentChangedEvent> fieldChangeRequests)
{
	userSession.assertLoggedIn();

	final ViewId viewId = ViewId.of(windowIdStr, viewIdStr);
	final DocumentId rowId = DocumentId.of(rowIdStr);

	final IEditableView view = getEditableView(viewId);
	final RowEditingContext editingCtx = createRowEditingContext(rowId);
	view.patchViewRow(editingCtx, fieldChangeRequests);

	final IViewRow row = view.getById(rowId);
	final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
	final JSONOptions jsonOpts = newJSONOptions();
	return JSONViewRow.ofRow(row, rowOverrides, jsonOpts);
}
 
Example #2
Source File: MenuRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
@PatchMapping("/node/{nodeId}")
public List<JSONMenuNode> patchNode(@PathVariable(PARAM_NodeId) final String nodeId, @RequestBody final List<JSONDocumentChangedEvent> events)
{
	userSession.assertLoggedIn();

	final JSONPatchMenuNodeRequest request = JSONPatchMenuNodeRequest.ofChangeEvents(events);

	final MenuTree menuTree = getMenuTree();
	final MenuNode node = menuTree.getNodeById(nodeId);

	final LinkedHashMap<String, MenuNode> changedMenuNodesById = new LinkedHashMap<>();

	if (request.getFavorite() != null)
	{
		menuTreeRepository.setFavorite(node, request.getFavorite());
		menuTree.streamNodesByAD_Menu_ID(node.getAD_Menu_ID())
				.forEach(changedNode -> changedMenuNodesById.put(changedNode.getId(), changedNode));
	}

	return JSONMenuNode.ofList(changedMenuNodesById.values(), menuTreeRepository);
}
 
Example #3
Source File: WindowRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
@PatchMapping("/{windowId}/{documentId}/{tabId}/{rowId}")
public List<JSONDocument> patchIncludedDocument(
		@PathVariable("windowId") final String windowIdStr //
		, @PathVariable("documentId") final String documentIdStr //
		, @PathVariable("tabId") final String detailIdStr //
		, @PathVariable("rowId") final String rowIdStr //
		, @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced //
		, @RequestBody final List<JSONDocumentChangedEvent> events)
{
	final DocumentPath documentPath = DocumentPath.builder()
			.setDocumentType(WindowId.fromJson(windowIdStr))
			.setDocumentId(documentIdStr)
			.setDetailId(detailIdStr)
			.setRowId(rowIdStr)
			.allowNewRowId()
			.build();

	return patchDocument(documentPath, advanced, events);
}
 
Example #4
Source File: WindowRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
/**
 *
 * @param windowIdStr
 * @param documentIdStr the string to identify the document to be returned. May also be {@link DocumentId#NEW_ID_STRING}, if a new record shall be created.
 * @param advanced
 * @param events
 * @return
 */
@PatchMapping("/{windowId}/{documentId}")
public List<JSONDocument> patchRootDocument(
		@PathVariable("windowId") final String windowIdStr //
		, @PathVariable("documentId") final String documentIdStr //
		, @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced //
		, @RequestBody final List<JSONDocumentChangedEvent> events)
{
	final DocumentPath documentPath = DocumentPath.builder()
			.setDocumentType(WindowId.fromJson(windowIdStr))
			.setDocumentId(documentIdStr)
			.allowNewDocumentId()
			.build();

	return patchDocument(documentPath, advanced, events);
}
 
Example #5
Source File: BoardRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
@PatchMapping("/{boardId}/card/{cardId}")
public JSONBoardCard patchCard(@PathVariable("boardId") final int boardId, @PathVariable("cardId") final int cardId, @RequestBody final List<JSONDocumentChangedEvent> changes)
{
	userSession.assertLoggedIn();

	final BoardCard card = boardsRepo.changeCard(boardId, cardId, createBoardCardChangeRequest(changes));
	return JSONBoardCard.of(card, userSession.getAD_Language());
}
 
Example #6
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEntity<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
	Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
	if (updatedStock == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID)
			.buildAndExpand(updatedStock.getSymbol()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example #7
Source File: ApiController.java    From scoold with Apache License 2.0 5 votes vote down vote up
@PatchMapping("/webhooks/{id}")
public Webhook updateWebhook(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
	Webhook webhook = pc.read(id);
	if (webhook == null) {
		res.setStatus(HttpStatus.NOT_FOUND.value());
		return null;
	}
	Map<String, Object> entity = readEntity(req);
	return pc.update(ParaObjectUtils.setAnnotatedFields(webhook, entity, Locked.class));
}
 
Example #8
Source File: ApiController.java    From scoold with Apache License 2.0 5 votes vote down vote up
@PatchMapping("/tags/{id}")
public Tag updateTag(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
	Map<String, Object> entity = readEntity(req);
	if (entity.isEmpty()) {
		badReq("Missing request body.");
	}
	Model model = new ExtendedModelMap();
	tagsController.rename(id, (String) entity.get("tag"), req, res, model);
	if (!model.containsAttribute("tag")) {
		res.setStatus(HttpStatus.NOT_FOUND.value());
		return null;
	}
	return (Tag) model.getAttribute("tag");
}
 
Example #9
Source File: ApiController.java    From scoold with Apache License 2.0 5 votes vote down vote up
@PatchMapping("/users/{id}")
public Profile updateUser(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
	Map<String, Object> entity = readEntity(req);
	if (entity.isEmpty()) {
		badReq("Missing request body.");
	}
	String name = (String) entity.get("name");
	String location = (String) entity.get("location");
	String latlng = (String) entity.get("latlng");
	String website = (String) entity.get("website");
	String aboutme = (String) entity.get("aboutme");
	String picture = (String) entity.get("picture");

	Model model = new ExtendedModelMap();
	profileController.edit(id, name, location, latlng, website, aboutme, picture, req, model);

	Profile profile = (Profile) model.getAttribute("user");
	if (profile == null) {
		res.setStatus(HttpStatus.NOT_FOUND.value());
		return null;
	}
	if (entity.containsKey("spaces")) {
		profile.setSpaces(new HashSet<>(readSpaces(((List<String>) entity.getOrDefault("spaces",
					Collections.emptyList())).toArray(new String[0]))));
		pc.update(profile);
	}
	return profile;
}
 
Example #10
Source File: ApiController.java    From scoold with Apache License 2.0 5 votes vote down vote up
@PatchMapping("/posts/{id}")
public Post updatePost(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
	Map<String, Object> entity = readEntity(req);
	if (entity.isEmpty()) {
		badReq("Missing request body.");
	}
	String editorid = (String) entity.get("lasteditby");
	if (!StringUtils.isBlank(editorid)) {
		Profile authUser = pc.read(Profile.id(editorid));
		if (authUser != null) {
			req.setAttribute(AUTH_USER_ATTRIBUTE, authUser);
		}
	}
	String space = (String) entity.get("space");
	String title = (String) entity.get("title");
	String body = (String) entity.get("body");
	String location = (String) entity.get("location");
	String latlng = (String) entity.get("latlng");
	List<String> spaces = readSpaces(space);
	space = spaces.iterator().hasNext() ? spaces.iterator().next() : null;
	Model model = new ExtendedModelMap();
	questionController.edit(id, title, body, String.join(",", (List<String>) entity.get("tags")),
			location, latlng, space, req, res, model);

	Post post = (Post) model.getAttribute("post");
	if (post == null) {
		res.setStatus(HttpStatus.NOT_FOUND.value());
	} else if (!utils.canEdit(post, utils.getAuthUser(req))) {
		badReq("Update failed - user " + editorid + " is not allowed to update post.");
	}
	return post;
}
 
Example #11
Source File: MethodMixupAnnotations.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@PatchMapping(
    path = "usingPatchMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingPatchMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
 
Example #12
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEntity<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
	Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
	if (updatedStock == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID)
			.buildAndExpand(updatedStock.getSymbol()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example #13
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEntity<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
	Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
	if (updatedStock == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID)
			.buildAndExpand(updatedStock.getSymbol()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example #14
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEntity<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
	Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
	if (updatedStock == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID)
			.buildAndExpand(updatedStock.getSymbol()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example #15
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks")
public ResponseEntity<Void> updateStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@RequestHeader(value = "x-bulk-patch") Optional<Boolean> isBulkPatch,
		@RequestBody List<Stock> stocksTobeUpdated) throws CustomHeaderNotFoundException {
	// without custom header we are not going to process this bulk operation
	if (!isBulkPatch.isPresent()) {
		throw new CustomHeaderNotFoundException("x-bulk-patch not found in your headers");
	}
	investorService.bulkUpdateOfStocksByInvestorId(investorId, stocksTobeUpdated);
	return ResponseEntity.noContent().build();
}
 
Example #16
Source File: MailRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
@PatchMapping("/{emailId}")
@ApiOperation("Changes the email")
public JSONEmail changeEmail(@PathVariable("emailId") final String emailId, @RequestBody final List<JSONDocumentChangedEvent> events)
{
	userSession.assertLoggedIn();

	final WebuiEmailChangeResult result = changeEmail(emailId, emailOld -> changeEmail(emailOld, events));
	return JSONEmail.of(result.getEmail(), userSession.getAD_Language());
}
 
Example #17
Source File: WithdrawRecordController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@RequiresPermissions("finance:withdraw-record:audit-no-pass")
@PatchMapping("/audit-no-pass")
@AccessLog(module = AdminModule.FINANCE, operation = "提现记录WithdrawRecord一键审核不通过")
public MessageResult auditNoPass(@RequestParam("ids") Long[] ids) {
    withdrawRecordService.audit(ids, FAIL);
    return success(messageSource.getMessage("AUDIT_DOES_NOT_PASS"));
}
 
Example #18
Source File: PatchMappingMethodAnnotationProcessor.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator,
    PatchMapping patchMapping) {
  doProcess(operationGenerator,
      patchMapping.path(), patchMapping.value(),
      RequestMethod.PATCH,
      patchMapping.consumes(), patchMapping.produces());
}
 
Example #19
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEntity<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
	Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
	if (updatedStock == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID)
			.buildAndExpand(updatedStock.getSymbol()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example #20
Source File: InvestorController.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEntity<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId,
		@PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
	Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
	if (updatedStock == null) {
		return ResponseEntity.noContent().build();
	}
	URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID)
			.buildAndExpand(updatedStock.getSymbol()).toUri();
	return ResponseEntity.created(location).build();
}
 
Example #21
Source File: WindowQuickInputRestController.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
@PatchMapping("/{quickInputId}")
public List<JSONDocument> processChanges(
		@PathVariable("windowId") final String windowIdStr,
		@PathVariable("documentId") final String documentIdStr,
		@PathVariable("tabId") final String tabIdStr,
		@PathVariable("quickInputId") final String quickInputIdStr,
		@RequestBody final List<JSONDocumentChangedEvent> events)
{
	userSession.assertLoggedIn();

	final QuickInputPath quickInputPath = QuickInputPath.of(windowIdStr, documentIdStr, tabIdStr, quickInputIdStr);
	return Execution.callInNewExecution("quickInput-writable-" + quickInputPath, () -> {
		final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();

		forQuickInputWritable(quickInputPath, changesCollector, quickInput -> {
			quickInput.processValueChanges(events);

			changesCollector.setPrimaryChange(quickInput.getDocumentPath());
			return null; // void
		});

		// Extract and send websocket events
		final List<JSONDocument> jsonDocumentEvents = JSONDocument.ofEvents(changesCollector, newJSONDocumentOptions());
		websocketPublisher.convertAndPublish(jsonDocumentEvents);

		return jsonDocumentEvents;
	});
}
 
Example #22
Source File: ElideControllerAutoConfiguration.java    From elide-spring-boot with Apache License 2.0 5 votes vote down vote up
/**
 * Elide [PATCH] controller.
 */
@PatchMapping(value = "/**", consumes = JSON_API_CONTENT_TYPE)
public ResponseEntity<String> elidePatch(@RequestBody String body,
    HttpServletRequest request, Principal authentication) {
  ElideResponse response = elide.patch(JSON_API_CONTENT_TYPE, JSON_API_CONTENT_TYPE,
      getJsonApiPath(request, elideProperties.getPrefix()), body, authentication);
  return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
 
Example #23
Source File: OrderApiController.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@PatchMapping(path="/{orderId}", consumes="application/json")
public Order patchOrder(@PathVariable("orderId") Long orderId,
                        @RequestBody Order patch) {
  
  Order order = repo.findById(orderId).get();
  if (patch.getDeliveryName() != null) {
    order.setDeliveryName(patch.getDeliveryName());
  }
  if (patch.getDeliveryStreet() != null) {
    order.setDeliveryStreet(patch.getDeliveryStreet());
  }
  if (patch.getDeliveryCity() != null) {
    order.setDeliveryCity(patch.getDeliveryCity());
  }
  if (patch.getDeliveryState() != null) {
    order.setDeliveryState(patch.getDeliveryState());
  }
  if (patch.getDeliveryZip() != null) {
    order.setDeliveryZip(patch.getDeliveryState());
  }
  if (patch.getCcNumber() != null) {
    order.setCcNumber(patch.getCcNumber());
  }
  if (patch.getCcExpiration() != null) {
    order.setCcExpiration(patch.getCcExpiration());
  }
  if (patch.getCcCVV() != null) {
    order.setCcCVV(patch.getCcCVV());
  }
  return repo.save(order);
}
 
Example #24
Source File: OrderApiController.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@PatchMapping(path="/{orderId}", consumes="application/json")
public Order patchOrder(@PathVariable("orderId") Long orderId,
                        @RequestBody Order patch) {

  Order order = repo.findById(orderId).get();
  if (patch.getDeliveryName() != null) {
    order.setDeliveryName(patch.getDeliveryName());
  }
  if (patch.getDeliveryStreet() != null) {
    order.setDeliveryStreet(patch.getDeliveryStreet());
  }
  if (patch.getDeliveryCity() != null) {
    order.setDeliveryCity(patch.getDeliveryCity());
  }
  if (patch.getDeliveryState() != null) {
    order.setDeliveryState(patch.getDeliveryState());
  }
  if (patch.getDeliveryZip() != null) {
    order.setDeliveryZip(patch.getDeliveryState());
  }
  if (patch.getCcNumber() != null) {
    order.setCcNumber(patch.getCcNumber());
  }
  if (patch.getCcExpiration() != null) {
    order.setCcExpiration(patch.getCcExpiration());
  }
  if (patch.getCcCVV() != null) {
    order.setCcCVV(patch.getCcCVV());
  }
  return repo.save(order);
}
 
Example #25
Source File: OrderApiController.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@PatchMapping(path="/{orderId}", consumes="application/json")
public Order patchOrder(@PathVariable("orderId") Long orderId,
                        @RequestBody Order patch) {
  
  Order order = repo.findById(orderId).get();
  if (patch.getDeliveryName() != null) {
    order.setDeliveryName(patch.getDeliveryName());
  }
  if (patch.getDeliveryStreet() != null) {
    order.setDeliveryStreet(patch.getDeliveryStreet());
  }
  if (patch.getDeliveryCity() != null) {
    order.setDeliveryCity(patch.getDeliveryCity());
  }
  if (patch.getDeliveryState() != null) {
    order.setDeliveryState(patch.getDeliveryState());
  }
  if (patch.getDeliveryZip() != null) {
    order.setDeliveryZip(patch.getDeliveryState());
  }
  if (patch.getCcNumber() != null) {
    order.setCcNumber(patch.getCcNumber());
  }
  if (patch.getCcExpiration() != null) {
    order.setCcExpiration(patch.getCcExpiration());
  }
  if (patch.getCcCVV() != null) {
    order.setCcCVV(patch.getCcCVV());
  }
  return repo.save(order);
}
 
Example #26
Source File: OrderApiController.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@PatchMapping(path="/{orderId}", consumes="application/json")
public Order patchOrder(@PathVariable("orderId") Long orderId,
                        @RequestBody Order patch) {
  
  Order order = repo.findById(orderId).get();
  if (patch.getDeliveryName() != null) {
    order.setDeliveryName(patch.getDeliveryName());
  }
  if (patch.getDeliveryStreet() != null) {
    order.setDeliveryStreet(patch.getDeliveryStreet());
  }
  if (patch.getDeliveryCity() != null) {
    order.setDeliveryCity(patch.getDeliveryCity());
  }
  if (patch.getDeliveryState() != null) {
    order.setDeliveryState(patch.getDeliveryState());
  }
  if (patch.getDeliveryZip() != null) {
    order.setDeliveryZip(patch.getDeliveryState());
  }
  if (patch.getCcNumber() != null) {
    order.setCcNumber(patch.getCcNumber());
  }
  if (patch.getCcExpiration() != null) {
    order.setCcExpiration(patch.getCcExpiration());
  }
  if (patch.getCcCVV() != null) {
    order.setCcCVV(patch.getCcCVV());
  }
  return repo.save(order);
}
 
Example #27
Source File: OrderApiController.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@PatchMapping(path="/{orderId}", consumes="application/json")
public Mono<Order> patchOrder(@PathVariable("orderId") UUID orderId,
                        @RequestBody Order patch) {

  return repo.findById(orderId)
      .map(order -> {
        if (patch.getDeliveryName() != null) {
          order.setDeliveryName(patch.getDeliveryName());
        }
        if (patch.getDeliveryStreet() != null) {
          order.setDeliveryStreet(patch.getDeliveryStreet());
        }
        if (patch.getDeliveryCity() != null) {
          order.setDeliveryCity(patch.getDeliveryCity());
        }
        if (patch.getDeliveryState() != null) {
          order.setDeliveryState(patch.getDeliveryState());
        }
        if (patch.getDeliveryZip() != null) {
          order.setDeliveryZip(patch.getDeliveryState());
        }
        if (patch.getCcNumber() != null) {
          order.setCcNumber(patch.getCcNumber());
        }
        if (patch.getCcExpiration() != null) {
          order.setCcExpiration(patch.getCcExpiration());
        }
        if (patch.getCcCVV() != null) {
          order.setCcCVV(patch.getCcCVV());
        }
        return order;
      })
      .flatMap(repo::save);
}
 
Example #28
Source File: BusinessAuthController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@RequiresPermissions("business:auth:deposit:update")
@PatchMapping("update")
public MessageResult update(
        @RequestParam("id") Long id,
        @RequestParam("amount") Double amount,
        @RequestParam("status") CommonStatus status) {
    BusinessAuthDeposit oldData = businessAuthDepositService.findById(id);
    if (amount != null) {
        /*if(businessAuthDeposit.getAmount().compareTo(oldData.getAmount())>0){
            //如果上调了保证金,所有使用当前类型保证金的已认证商家的认证状态都改为保证金不足
            ArrayList<BooleanExpression> booleanExpressions = new ArrayList<>();
            booleanExpressions.add(QDepositRecord.depositRecord.coin.eq(oldData.getCoin()));
            booleanExpressions.add(QDepositRecord.depositRecord.status.eq(DepositStatusEnum.PAY));
            Predicate predicate=PredicateUtils.getPredicate(booleanExpressions);
            List<DepositRecord> depositRecordList=depositRecordService.findAll(predicate);
            if(depositRecordList!=null){
                List<Long> idList=new ArrayList<>();
                for(DepositRecord depositRecord:depositRecordList){
                    idList.add(depositRecord.getMember().getId());
                }
                memberService.updateCertifiedBusinessStatusByIdList(idList);
            }
        }*/
        oldData.setAmount(new BigDecimal(amount));
    }
    if (status != null) {
        oldData.setStatus(status);
    }
    businessAuthDepositService.save(oldData);
    return success();
}
 
Example #29
Source File: WithdrawRecordController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 单个打款 转账成功添加流水号
 *
 * @param id
 * @param transactionNumber
 * @return
 */
@RequiresPermissions("finance:withdraw-record:add-transaction-number")
@PatchMapping("/add-transaction-number")
@AccessLog(module = AdminModule.FINANCE, operation = "添加交易流水号")
@Transactional(rollbackFor = Exception.class)
public MessageResult addNumber(
        @RequestParam("id") Long id,
        @RequestParam("transactionNumber") String transactionNumber) {
    WithdrawRecord record = withdrawRecordService.findOne(id);
    Assert.notNull(record, "该记录不存在");
    Assert.isTrue(record.getIsAuto() == BooleanEnum.IS_FALSE, "该提现单为自动审核");
    record.setTransactionNumber(transactionNumber);
    record.setStatus(WithdrawStatus.SUCCESS);
    MemberWallet memberWallet = memberWalletService.findByCoinAndMemberId(record.getCoin(), record.getMemberId());
    Assert.notNull(memberWallet, "member id " + record.getMemberId() + " 的 wallet 为 null");
    memberWallet.setFrozenBalance(memberWallet.getFrozenBalance().subtract(record.getTotalAmount()));
    memberWalletService.save(memberWallet);
    record = withdrawRecordService.save(record);

    MemberTransaction memberTransaction = new MemberTransaction();
    memberTransaction.setMemberId(record.getMemberId());
    memberTransaction.setAddress(record.getAddress());
    memberTransaction.setAmount(record.getTotalAmount());
    memberTransaction.setSymbol(record.getCoin().getUnit());
    memberTransaction.setCreateTime(record.getCreateTime());
    memberTransaction.setType(TransactionType.WITHDRAW);
    memberTransaction.setFee(record.getFee());
    memberTransaction.setRealFee(record.getFee()+"");
    memberTransaction.setDiscountFee("0");
    memberTransaction= memberTransactionService.save(memberTransaction);

    return MessageResult.success(messageSource.getMessage("SUCCESS"), record);
}
 
Example #30
Source File: OperationsTransformer.java    From spring-openapi with MIT License 5 votes vote down vote up
private void mapPatch(PatchMapping patchMapping, Method method, Map<String, PathItem> operationsMap, String controllerClassName, String baseControllerPath) {
	Operation operation = new Operation();
	operation.setOperationId(getOperationId(patchMapping.name(), method, HttpMethod.PATCH));
	operation.setSummary(StringUtils.isBlank(patchMapping.name()) ? patchMapping.name() : method.getName());
	operation.setTags(singletonList(classNameToTag(controllerClassName)));

	operation.setRequestBody(createRequestBody(method, getFirstFromArray(patchMapping.consumes())));
	operation.setResponses(createApiResponses(method, getFirstFromArray(patchMapping.produces())));
	operation.setParameters(transformParameters(method));

	String path = ObjectUtils.defaultIfNull(getFirstFromArray(patchMapping.value()), getFirstFromArray(patchMapping.path()));

	operationInterceptors.forEach(interceptor -> interceptor.intercept(method, operation));
	updateOperationsMap(prepareUrl(baseControllerPath, "/", path), operationsMap, pathItem -> pathItem.setPatch(operation));
}