小工具知识网

当前位置: 首页 > 行业知识 > vue 前端参值后端接收的几种方式

行业知识

vue 前端参值后端接收的几种方式

2026-11-15 21:52:31 来源:互联网转载

文章目录

  • Get 请求 @Param
  • Put请求 @RequestBody

    Get 请求 @Param

    前端代码

     handleCS(){      // debugger      // let body ={      //   id:8,      //   nyApplyDangerdetectionId:8,        //   uploadStatic:2,      //   auditorSign:'改我了',      //   auditorDescribe:'我也改了'      // }      let companyid = 1      let body = {}       getSelectDanger(companyid).then(response => {        body = response;        // this.open = true;        // this.title = "修改隐患排查";      });    },

    调用接口

    // 接口测试调用export function getSelectDanger(companyid) {  return request({    url: '/system/uniapp/getboolWriteBack',    method: 'get',    params: {companyid : companyid}  })}

    后端代码controller接收

    @ApiOperation("getboolWriteBack")@GetMapping("/getboolWriteBack")public AjaxResult getboolWriteBack(Integer companyid){    Integer count = nyPostNumberService.routineWriteBack(companyid);    boolean falg = false;    if(count==null){        falg = true;    }    return AjaxResult.success(falg);}

    后端代码Mapper层

    public Integer routineWriteBack(@Param("companyid")  Integer companyid);

    后端代码Mapper.xml

           select onduty_people from ny_post_number where companyid = #{companyid} and date(create_time) = date(now())    

    Put请求 @RequestBody

    前端代码

    handleCS(){     let body ={       id:12,       nyApplyDangerdetectionId:7898994,         uploadStatic:2,       auditorSign:'改我了',       auditorDescribe:'我也改了'     }     getSelectDanger(body).then(response => {     });   },

    调用接口

    export function getSelectDanger(data) {  return request({    url: '/warningrisk/dangerdetection/UpdateuploadStatic',    method: 'put',    data: data  })}

    后端代码controller接收

    @Log(title = "隐患排查", businessType = BusinessType.UPDATE)@PutMapping("/UpdateuploadStatic")public AjaxResult UpdateuploadStatic(@RequestBody NyDangerdetection nyDangerdetection){    return toAjax(nyDangerdetectionService.updateuploadStatic(nyDangerdetection));}

    后端代码Mapper层

    Integer updateuploadStatic(NyDangerdetection nydangerdetection);

    后端代码Mapper.xml

         UPDATE ny_dangerdetection a         INNER JOIN ny_apply_dangerdetection b ON a.ny_apply_dangerdetection_id = b.id              a.upload_static = #{uploadStatic},         b.auditor_sign = #{auditorSign},         b.auditor_describe = #{auditorDescribe}           where a.ny_apply_dangerdetection_id = #{nyApplyDangerdetectionId} and b.id = #{id}

上一篇:揭秘源代码,深度解读定义与奥秘探索

下一篇:快试音任务攻略,轻松掌握接任务秘籍!