zoukankan      html  css  js  c++  java
  • postman中如何传数组

    方法一:

    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
        }
    }
    

      

  • 相关阅读:
    如何使用Junit
    CSS简单动画效果
    编程类软件下载地址
    常用的工具包-下载地址
    连接数据库常用工具类(二)------C3P0Utils工具类
    连接数据库时常用的工具类(一)-------C3P0XmlUtils
    浏览器输入服务器端口号来访问html网页
    使用C/S结构实现客户端上传本地文件到服务器
    冒泡排序
    一个注册界面
  • 原文地址:https://www.cnblogs.com/xww115/p/11364058.html
Copyright © 2011-2022 走看看