使用apifox中post方式怎么写List<Long> listArcInfoId,Integer tableName,Integer type的值
时间: 2023-07-16 17:15:13 浏览: 63
在apifox中使用post方式传递List<Long>类型的参数需要使用json格式进行传递,具体的步骤如下:
1. 在请求参数中选择“Body”,并选择“JSON”。
2. 在请求体中填写json格式的数据,例如:
```
{
"listArcInfoId": [1,2,3],
"tableName": 1,
"type": 2
}
```
其中,`listArcInfoId`是一个`List<Long>`类型的参数,可以用数组的形式进行表示。
3. 发送请求即可。
需要注意的是,使用json格式传递参数时,需要确保参数名称与后端接口约定的一致。
相关问题
@PostMapping ("/arcInfoStatus") @ApiOperation(value = "加入回收type:1 删除回收type:2 待归档type:3 归档type:4 还原:5 ") public R updateArcInfoStatus(@RequestBody List<Long> listArcInfoId, @RequestParam Integer tableName,@RequestParam Integer type) {怎么传数据能让后台接受到
你可以通过发送HTTP请求来传递数据给后台,具体操作如下:
1. 使用POST方法发送HTTP请求,请求的URL为接口地址:/arcInfoStatus
2. 在请求头中设置Content-Type为application/json,表示请求体中的数据是JSON格式的。
3. 在请求体中以JSON格式传递数据,示例如下:
```
{
"listArcInfoId": [1, 2, 3],
"tableName": 1,
"type": 4
}
```
其中,listArcInfoId表示需要操作的回收信息ID列表,tableName表示需要操作的表名,type表示操作类型。
4. 发送请求,等待后台响应。
public enum NaturalResourcesEnum { TDDLTB("td_dltb", TdDltb.class), TDGDDB("td_gddb", TdGddb.class), GDZLDJ("gd_zldj", GdZldj.class) ; private String tablename; private Class aClass; NaturalResourcesEnum(String tablename, Class aClass) { this.tablename = tablename; this.aClass = aClass; }Class<T> tableClass = NaturalResourcesEnum.getTableClass(dto.getTablename()); QueryWrapper<?> wrapper = Wrappers.query(); wrapper.likeRight("adcd",dto.getAdcd()); List<Map> map = this.baseMapper.naturalResourcesPageList(dto.getTablename(), wrapper); List<Map> transferMapList = new ArrayList<>(); //将有下划线的转驼峰 map.forEach(x ->{ Map transferMap = MapUtil.formatHumpName(x); transferMapList.add(transferMap); }); List<Map>怎么将枚举对应的实体类把List<Map>转为List<实体类>
可以使用Java的反射机制,通过枚举中存储的实体类的Class对象来进行实例化,然后再将List<Map>中的数据逐个转化为实体类对象,并添加到List<实体类>中。以下是示例代码:
```
public List<T> convertMapListToEntityList(List<Map> mapList, Class<T> entityClass) throws Exception {
List<T> entityList = new ArrayList<>();
for (Map map : mapList) {
T entity = entityClass.newInstance();
BeanUtils.populate(entity, map);
entityList.add(entity);
}
return entityList;
}
// 调用方式
NaturalResourcesEnum naturalResource = NaturalResourcesEnum.TDDLTB;
List<Map> mapList = baseMapper.naturalResourcesPageList(naturalResource.getTablename(), wrapper);
List<T> entityList = convertMapListToEntityList(mapList, naturalResource.getAClass());
```