You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
65 lines
1.8 KiB
package cc.bnblogs.provider.controller; |
|
|
|
import cc.bnblogs.provider.entity.Order; |
|
import cc.bnblogs.provider.service.IndexService; |
|
import com.alibaba.csp.sentinel.annotation.SentinelResource; |
|
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A; |
|
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
import org.springframework.beans.factory.annotation.Value; |
|
import org.springframework.web.bind.annotation.GetMapping; |
|
import org.springframework.web.bind.annotation.RequestParam; |
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import java.util.Date; |
|
|
|
@RestController |
|
public class IndexController { |
|
@Value("${server.port}") |
|
private String port; |
|
|
|
@Autowired |
|
private IndexService indexService; |
|
|
|
@GetMapping("/index") |
|
public String getPort() { |
|
return this.port; |
|
} |
|
@GetMapping("/list") |
|
public String list() { |
|
return "list"; |
|
} |
|
|
|
@GetMapping("/test1") |
|
public String test1() { |
|
return indexService.testService(); |
|
} |
|
|
|
@GetMapping("/test2") |
|
public String test2() { |
|
return indexService.testService(); |
|
} |
|
|
|
@GetMapping("/hot") |
|
@SentinelResource("hot") |
|
public String getHot(@RequestParam(value = "num1",required = false)Integer num1, |
|
@RequestParam(value = "num2",required = false) Integer num2){ |
|
return num1 + "-" + num2; |
|
} |
|
|
|
@Autowired |
|
private RocketMQTemplate rocketMQTemplate; |
|
|
|
@GetMapping("/create") |
|
public Order createOrder() { |
|
Order order = new Order( |
|
1, |
|
"tom", |
|
"123123", |
|
"shanghai", |
|
new Date() |
|
); |
|
rocketMQTemplate.convertAndSend("orderTopic",order); |
|
return order; |
|
} |
|
}
|
|
|