SpringBoot Controller的参数请求方式

本文档详细介绍了针对企业债务者的RESTful API操作方法,包括通过ID删除企业债务者、加入企业债务者以及修改企业债务者信息等功能。通过示例展示了如何使用GET请求删除指定ID的企业债务者,如何使用带有参数的GET请求实现用户的加入操作,以及如何利用POST请求及请求体来修改企业债务者的信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  •  /delete/{id}  对应 @PathVariable("enterpriseId") Long enterpriseId
    @RequestMapping(value = "/delete/{Id}", method = {RequestMethod.GET})
    public ResponseEntity<Object> deleteDebtorEnterpriseByID(@PathVariable("Id") Long enterpriseId) {
        debtorEnterpriseService.deleteDebtorEnterpriseByID(new RequestContext(), enterpriseId);

        return new ResponseEntity(new HttpResponse<>(), HttpStatus.OK);
    }

  • /delete  对应 @RequestParam(value = "id", request = true) Long id
    @RequestMapping(value = "/joinenterprise", method = {RequestMethod.GET})
    public ResponseEntity<Object> joinDebtor(@RequestParam(value = "userId", required = true) Long userId,
                                             @RequestParam(value = "enterpriseId", required = true) Long enterpriseId) {

        debtorEnterpriseService.joinDebtorEnterprise(new RequestContext(), userId, enterpriseId);

        return new ResponseEntity(new HttpResponse<>(), HttpStatus.OK);
    }
  •  RequestBody
    @RequestMapping(value = "/modify", method = {RequestMethod.POST})
    public ResponseEntity<Object> modifyDebtorEnterpriseInfo(@RequestBody DebtorEnterpriseInfoRequest debtorEnterpriseInfoRequest) {
        List<DebtorPropertyValueBO> debtorPropertyValueBOList = BeanUtils.convert(debtorEnterpriseInfoRequest.getDebtorPropertyValueRequestList(),DebtorPropertyValueBO.class);
        DebtorEnterpriseInfoBO debtorEnterpriseInfoBO = BeanUtils.convert(debtorEnterpriseInfoRequest, DebtorEnterpriseInfoBO.class);
        debtorEnterpriseInfoBO.setDebtorPropertyValueListBO(debtorPropertyValueBOList);

        debtorEnterpriseService.modifyDebtorEnterpriseInfo(new RequestContext(), debtorEnterpriseInfoBO);

        return new ResponseEntity(new HttpResponse<>(), HttpStatus.OK);
    }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值