美文网首页
vue传入数组到spring后台

vue传入数组到spring后台

作者: 尘埃里的玄 | 来源:发表于2022-01-14 18:31 被阅读0次

    1:后台使用@PathVariable

        /**
         * 删除了开关灯计划,同时也要将计划对应的回路也删除掉
         *
         * @param openClosePlanIds
         * @return
         */
        @ApiOperation("删除开关灯计划")
        @DeleteMapping("/deleteLoopPlan/{openClosePlanIds}")
        public Result deleteLoopPlan(@PathVariable List<Integer> openClosePlanIds) {
            Integer projectId = 1;
            boolean flag = true;
            for (Integer openClosePlanId : openClosePlanIds) {
                boolean b = openClosePlanService.remove(new LambdaQueryWrapper<OpenClosePlan>().eq(OpenClosePlan::getProjectId, projectId).eq(OpenClosePlan::getId, openClosePlanId));
                boolean remove = openClosePlanRelationLoopService.remove(new LambdaQueryWrapper<OpenClosePlanRelationLoop>().eq(OpenClosePlanRelationLoop::getPlanId, openClosePlanId));
                log.info("开关灯计划删除的结果:" + b + ",openClosePlanId为:" + openClosePlanId + "计划关联的回路的结果:" + remove);
                flag = flag && b;
            }
            if (flag) {
                return Result.buildSuccessMessage("删除成功");
            } else {
                return Result.buildFailedMessage("删除失败");
            }
        }
    
    image.png
    企业微信截图_16421560357676.png
    enum Api {
      DeletePlan = '/openClosePlan/deleteLoopPlan/',
    }
    
    //根据传入的计划id删除计划
    export function deletePlan(params: Array<number>) {
      return otherHttp.delete({
        url: Api.DeletePlan + params,
      });
    }
    

    2 使用@RequestParam

    参考地址:
    https://blog.csdn.net/qq_41725450/article/details/108768288?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param

    相关文章

      网友评论

          本文标题:vue传入数组到spring后台

          本文链接:https://www.haomeiwen.com/subject/ksxzcrtx.html