踩坑 - mybatispilus中saveorupdate

    @ApiOperation(value = "新增或者修改设备")
    @PostMapping("saveOrUpdateDevice")
    public void saveOrUpdateDevice (@RequestBody DeviceInfo deviceInfo){
        deviceInfoService.saveInOrUpdate(deviceInfo);
    }

使用时,出现只更新的情况

1、检查实体类主键 主键是否使用注解 @TableId
2、传递的参数中主键id 为空时。判断为新增,携带id则指定更新

posted @ 2022-09-21 14:51  东楚  阅读(260)  评论(0)    收藏  举报