1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.zhentao.controller;
- import com.zhentao.pojo.Rest;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.ResponseEntity;
- import org.springframework.validation.BindingResult;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import javax.validation.Valid;
- import java.util.HashMap;
- import java.util.Map;
- @RestController
- @RequestMapping("/api")
- public class ApiController {
- // @Autowired
- // DemoService demoService;
- // @PostMapping("/oder1")
- // public ResultVo add(@Validated @ReguestBody RequestDto requestDto, @RequestHeader("regld") String regld){
- // log.infoUsONObject.toJSONString(requestDto));
- // return demoService.add(requestDto,regld);
- // }
- //
- // @GetMapping("/addv2")
- // public ResultVo addv2( RequestDto requestDto, @RequestHeader("regld") String reqld){
- // log.infoUSONObiect.toJSONString(requestDto));
- // return demoService.add(requestDto,regld);
- // }
- // 接口1 - POST JSON
- @PostMapping("/v1/order")
- public String createOrder(
- @RequestHeader("reqId") String reqId,
- @Validated @RequestBody Rest request) {
- return "接口1调用成功: " + request.toString();
- }
- // 接口2 - GET Form参数
- @GetMapping("/v2/order")
- public String getOrder(
- @RequestHeader("reqId") String reqId,
- @Validated Rest request) {
- return "接口2调用成功: " + request.toString();
- }
- }
|