| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.vci.ubcs.example.entity.RequestData; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.ServletRequest; |
| | |
| | | * @author ludc |
| | | * @date 2024/2/27 20:31 |
| | | */ |
| | | @RestController("/pushIntegration") |
| | | @RestController |
| | | @RequestMapping("/pushIntegration") |
| | | public class PushIntegrationController { |
| | | |
| | | /** |
| | |
| | | * @throws IOException |
| | | */ |
| | | @PostMapping("/testByForm1") |
| | | public R test(@RequestParam String dataType, @RequestParam String dataString) throws IOException { |
| | | public String test(@RequestParam String dataType, @RequestParam String dataString) throws IOException { |
| | | // 相关逻辑处理 |
| | | System.out.println(dataType); |
| | | System.out.println(dataString); |
| | | return R.status(true); |
| | | return "成功"; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws IOException |
| | | */ |
| | | @PostMapping("/testByForm2") |
| | | public R test1(ServletRequest request) throws IOException { |
| | | public String test1(ServletRequest request) throws IOException { |
| | | HttpServletRequest request1 = (HttpServletRequest) request; |
| | | String dataString = request1.getParameter("dataString"); |
| | | ServletInputStream inputStream = request1.getInputStream(); |
| | |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | | JSONArray jsonArray = jsonObject.getJSONArray("dataString"); |
| | | |
| | | return R.data(jsonArray); |
| | | return jsonArray.toJSONString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws IOException |
| | | */ |
| | | @PostMapping("/testByAppjson") |
| | | public R test1(@RequestBody RequestData requestData) throws IOException { |
| | | public String test1(@RequestBody RequestData requestData) throws IOException { |
| | | // 拿到这个参数之后取该集合中的第一个元素,就是要json转成对象的参数 |
| | | // 如有具体转换要求,则根据编码器中的接口提供的配置而定,通常为dataType字段,如xml,json两种情况 |
| | | List<Object> dataString = requestData.getDataString(); |
| | | // JSONObject.parseObject(dataString,/*根据编码系统提供的对象属性而定义的对象*/); |
| | | List<String> dataType = requestData.getDataType(); |
| | | return R.data(dataString); |
| | | return JSONObject.toJSONString(dataString); |
| | | } |
| | | |
| | | } |