方法一:

postman的传参:

java接收:

package com.nps.base.xue.xd.groovyEngine

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.nps.common.service.NpsApplicationContextHolder
import com.nps.data_api.service.impl.NpsDataApiService import java.lang.reflect.Type /*
* @author XueWeiWei
* @date 2019/8/9 17:24
*/
class TrainMarshallingUpdateByGKEYGroovy {
private NpsDataApiService npsDataApiService = NpsApplicationContextHolder.getApplicationContext().getBean("npsDataApiService") // public List<Object> execute(Map<Object,Object> param){
// List<Object> result = new ArrayList<>()
//
// Map resultMap = new HashMap()
//
// npsDataApiService.exec(param,"train_marshalling_update_by_gkey")
//
// resultMap.put("resultCode","success")
//
// result.add(resultMap)
// return result
// } // public List<Object> execute(List<Map<Object,Object>> param){
// List<Object> result = new ArrayList<>()
//
// Map resultMap = new HashMap()
//
// for (int i = 0; i < param.size(); i++) {
// npsDataApiService.exec(param[i],"train_marshalling_update_by_gkey")
// }
//
// resultMap.put("result","success")
// resultMap.put("resultCode","2")
//
// result.add(resultMap)
// return result
// } public List<Object> execute(Map<Object,Object> param){
List<Object> result = new ArrayList<>() Map queryMap = new HashMap()
Map resultMap = new HashMap() //获取数组GKEY
String GKEYList = param.get("GKEY") //获取不为空的需要更新的字段
(param.get("PREARRIVAL_LIST_FK_GKEY1") != null) ? queryMap.put("PREARRIVAL_LIST_FK_GKEY1",param.get("PREARRIVAL_LIST_FK_GKEY1")) : 1 == 1;
(param.get("PRE_TRAIN_NUMBER") != null) ? queryMap.put("PRE_TRAIN_NUMBER",param.get("PRE_TRAIN_NUMBER")) : 1 == 1;
(param.get("TRAIN_NUM") != null) ? queryMap.put("TRAIN_NUM",param.get("TRAIN_NUM")) : 1 == 1; List<Map<Object,Object>> marshallingGKEYList
Gson gson = new Gson()
Type type = new TypeToken<List<Map>>(){}.getType()
marshallingGKEYList = gson.fromJson(GKEYList,type) //更新
for (int i = 0; i < marshallingGKEYList.size(); i++) {
Map marshallingMap;
marshallingMap = (Map)marshallingGKEYList.get(i)
queryMap.put("GKEY",marshallingMap.get("GKEY"))
npsDataApiService.exec(queryMap,"train_marshalling_update_by_gkey")
} queryMap.clear()
resultMap.put("result","success")
resultMap.put("resultCode","2") result.add(resultMap) return result
}
}

  

方法二:

postman传参方式:

java接收:

package com.nps.base.xue.xd.groovyEngine

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.nps.common.service.NpsApplicationContextHolder
import com.nps.data_api.service.impl.NpsDataApiService import java.lang.reflect.Type /*
* @author XueWeiWei
* @date 2019/8/9 17:24
*/
class TrainMarshallingUpdateByGKEYGroovy {
private NpsDataApiService npsDataApiService = NpsApplicationContextHolder.getApplicationContext().getBean("npsDataApiService") // public List<Object> execute(Map<Object,Object> param){
// List<Object> result = new ArrayList<>()
//
// Map resultMap = new HashMap()
//
// npsDataApiService.exec(param,"train_marshalling_update_by_gkey")
//
// resultMap.put("resultCode","success")
//
// result.add(resultMap)
// return result
// } // public List<Object> execute(List<Map<Object,Object>> param){
// List<Object> result = new ArrayList<>()
//
// Map resultMap = new HashMap()
//
// for (int i = 0; i < param.size(); i++) {
// npsDataApiService.exec(param[i],"train_marshalling_update_by_gkey")
// }
//
// resultMap.put("result","success")
// resultMap.put("resultCode","2")
//
// result.add(resultMap)
// return result
// } public List<Object> execute(Map<Object,Object> param){
List<Object> result = new ArrayList<>() Map queryMap = new HashMap()
Map resultMap = new HashMap() //获取数组GKEY
String GKEYList = param.get("GKEY") //获取不为空的需要更新的字段
(param.get("PREARRIVAL_LIST_FK_GKEY1") != null) ? queryMap.put("PREARRIVAL_LIST_FK_GKEY1",param.get("PREARRIVAL_LIST_FK_GKEY1")) : 1 == 1;
(param.get("PRE_TRAIN_NUMBER") != null) ? queryMap.put("PRE_TRAIN_NUMBER",param.get("PRE_TRAIN_NUMBER")) : 1 == 1;
(param.get("TRAIN_NUM") != null) ? queryMap.put("TRAIN_NUM",param.get("TRAIN_NUM")) : 1 == 1; List<Object> marshallingGKEYList
Gson gson = new Gson()
Type type = new TypeToken<List<Object>>(){}.getType()
marshallingGKEYList = gson.fromJson(GKEYList,type) //更新
for (int i = 0; i < marshallingGKEYList.size(); i++) {
queryMap.put("GKEY",marshallingGKEYList.get(i))
npsDataApiService.exec(queryMap,"train_marshalling_update_by_gkey")
} queryMap.clear()
resultMap.put("result","success")
resultMap.put("resultCode","2") result.add(resultMap) return result
}
}

  

postman中如何传数组的更多相关文章

  1. postman 中get传参数

    mybatis中: @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET, produces = & ...

  2. SSM中前台传数组。后台接受的问题

    当时写得时候,忘记考虑json的jar,做个记录. 第一步:先带入jar <dependency> <groupId>com.fasterxml.jackson.core< ...

  3. 在MyBatis中,前台传数组批量传id处理数据方式

    <update id = "dishBatchSaleOrDown"> <if test="ids != null"> <if t ...

  4. 如何使用postman传数组数据

    如何使用postman传数组数据 在我们做api接口数据调试的时候,大部分是会用到postman的,一般请求数据的参数都是字符串,但是特殊情况下我们是需要传一个数组数据的,那么为了实现这种需求,究竟该 ...

  5. Postman系列三:Postman中post接口实战(上传文件、json请求)

    一:接口测试过程中GET请求与POST请求的主要区别 从开发角度我们看get与post的主要区别是:1.Get是用来从服务器上获得数据,而Post是用来向服务器上传递数据:2.Get安全性比Post低 ...

  6. 『政善治』Postman工具 — 8、Postman中Pre-request Script的使用

    目录 1.Pre-request Script介绍 2.常用SNIPPETS(片段)说明 (1)获取变量脚本: (2)设置变量脚本: (3)清空变量脚本: (4)Send a request代码片段 ...

  7. JavaScript中常见的数组操作函数及用法

    JavaScript中常见的数组操作函数及用法 昨天写了个帖子,汇总了下常见的JavaScript中的字符串操作函数及用法.今天正好有时间,也去把JavaScript中常见的数组操作函数及用法总结一下 ...

  8. Asp.net中后台C#数组与前台Javascript数组交互

    摘自:http://blog.csdn.net/a6225301/article/details/20003305 在上一篇<asp.net中javascript与后台c#交互>中实现了前 ...

  9. C语言中的指针数组

    C语言中的指针数组是什么,像 char *a[]={"ddd","dsidd","lll"}; 这里讲一下注意如果我们使用了a也就是首元素的 ...

随机推荐

  1. 【LeetCode 9】回文数

    题目链接 [题解] 还是要注意,取反的时候,-2^31 取反的话会爆掉Int..(因为int的正数最多到2^31-1) [代码] class Solution { public: bool isPal ...

  2. 【前端技术】一篇文章搞掂:JS

    待补充 //以下等价 if(val) if(val!=null&&val!=undefined&&val!="") //以下等价 if(!val) ...

  3. linux python3 venv 虚拟环境报错 [-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.

    解决办法: 先创建没有pip的虚拟环境,然后启动虚拟环境后,再安装pip 办法一: 亲测失败了... python3 -m venv --without-pip py36env 办法二 sudo ap ...

  4. HTTP六大请求

    标准Http协议支持六种请求方法,即: 1.GET 2.POST 3.PUT 4.Delete 5.HEAD 6.Options 但其实我们大部分情况下只用到了GET和POST.如果想设计一个符合RE ...

  5. Zabbix 历史数据存储到 Elasticsearch

    Zabbix 历史数据存储到 Elasticsearch Zabbix 3.4.6 版本开始支持历史数据存储到 Elasticsearch, 早就想测试这个功能,最近有个需求需保存 zabbix 的历 ...

  6. Linux用户空间内存区域的匿名映射

    1 在调用mmap系统调用时,可以指定的标志(flag)参数: 1: #define MAP_SHARED 0x01 /* Share changes */ 2: #define MAP_PRIVAT ...

  7. JSoup安装

    要运行任何jsoup示例,需要先安装好jsoup相关Jar包.到目前为止(2017年05月),jsoup的当前版本是1.10.2.0.安装jsoup主要有三种方法: 通过Maven的pom.xml配置 ...

  8. 实用的CSS3-渐变背景色

    线性渐变背景色:     第一个参数为渐变方式,后两个参数为起始点位置和终止点位置,后两个参数为起始颜色和终止颜色,后面那个参数为背景区域padding表示包含padding的区域,content表示 ...

  9. Centos 7 技巧

    查看系统版本详细信息 lsb_release -a 更改邮件MTA alternatives --config mta

  10. 调用API接口,查询手机号码归属地(2)

    使用pymysql pip install pymysql 创建mysql测试表 CREATE TABLE `userinfo` ( `id` int(20) NOT NULL AUTO_INCREM ...