Springboot实现两个实体类用一个数组接收新增
程序员文章站
2022-04-30 13:59:40
...
Springboot实现两个实体类用一个数组接收新增
1.接收数组放入实体类
@PostMapping("/saveOwnNurse")
public R saveOwnNurse(@RequestBody Object[] nurse){
//用户
SysUser sysUser = new SysUser();
sysUser.setUsername(nurse[0].toString());
sysUserService.save(sysUser);
//护理员
Nurse nurse1 = new Nurse();
nurse1.setAge((Integer) nurse[1]);
nurseService.save(nurse1);
return new R();
}
2.postman接收数组传参
成功
上一篇: 图片识别