mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
example annotations clearer
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.Random;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -45,7 +46,7 @@ public class AccountController {
|
||||
this.random = new Random();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/account", method = RequestMethod.POST, produces = "application/json")
|
||||
@PostMapping(value = "/account", produces = "application/json")
|
||||
public String account(String userId, int money) {
|
||||
LOGGER.info("Account Service ... xid: " + RootContext.getXID());
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -54,7 +55,7 @@ public class BusinessApplication {
|
||||
@FeignClient(value = "order", url = "http://127.0.0.1:18083")
|
||||
public interface OrderService {
|
||||
|
||||
@RequestMapping(path = "/order", method = RequestMethod.POST)
|
||||
@PostMapping(path = "/order")
|
||||
String order(@RequestParam("userId") String userId,
|
||||
@RequestParam("commodityCode") String commodityCode,
|
||||
@RequestParam("orderCount") int orderCount);
|
||||
|
@@ -24,6 +24,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -60,7 +61,7 @@ public class HomeController {
|
||||
}
|
||||
|
||||
@GlobalTransactional(timeoutMills = 300000, name = "spring-cloud-demo-tx")
|
||||
@RequestMapping(value = "/seata/rest", method = RequestMethod.GET, produces = "application/json")
|
||||
@GetMapping(value = "/seata/rest", produces = "application/json")
|
||||
public String rest() {
|
||||
|
||||
String result = restTemplate.getForObject(
|
||||
|
@@ -33,6 +33,7 @@ import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||
import org.springframework.jdbc.support.KeyHolder;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -62,7 +63,7 @@ public class OrderController {
|
||||
this.random = new Random();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/order", method = RequestMethod.POST, produces = "application/json")
|
||||
@PostMapping(value = "/order", produces = "application/json")
|
||||
public String order(String userId, String commodityCode, int orderCount) {
|
||||
LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
|
||||
|
||||
|
@@ -19,10 +19,7 @@ package com.alibaba.cloud.examples;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import io.seata.core.context.RootContext;
|
||||
|
||||
@@ -43,7 +40,7 @@ public class StorageController {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/storage/{commodityCode}/{count}", method = RequestMethod.GET, produces = "application/json")
|
||||
@GetMapping(value = "/storage/{commodityCode}/{count}", produces = "application/json")
|
||||
public String echo(@PathVariable String commodityCode, @PathVariable int count) {
|
||||
LOGGER.info("Storage Service Begin ... xid: " + RootContext.getXID());
|
||||
int result = jdbcTemplate.update(
|
||||
|
Reference in New Issue
Block a user