QysApiTestController.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.malk.ruisi.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.malk.ruisi.service.QysApiService;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.PostMapping;
  7. import org.springframework.web.bind.annotation.RequestBody;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RestController;
  10. import java.util.Map;
  11. /***
  12. * 测试契约锁
  13. */
  14. @RestController
  15. @Slf4j
  16. @RequestMapping("/qys/")
  17. public class QysApiTestController {
  18. @Autowired
  19. private QysApiService qysApiService;
  20. @PostMapping("test")
  21. public JSONObject testJSon(@RequestBody() JSONObject param){
  22. log.info("JSON格式请求参数:{}",param);
  23. try {
  24. Map data=(Map) param.get("data");
  25. String url=String.valueOf(param.get("url"));
  26. boolean isPost=(Boolean) param.get("isPost");
  27. if(isPost){
  28. return qysApiService.sendPost(data,url);
  29. }else {
  30. return qysApiService.sendGet(data,url,false);
  31. }
  32. } catch (Exception apiException) {
  33. return new JSONObject().fluentPut("msg","失败");
  34. }
  35. }
  36. }