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


    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 = "修改隐患排查";
          });
        },
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    调用接口

    // 接口测试调用
    export function getSelectDanger(companyid) {
      return request({
        url: '/system/uniapp/getboolWriteBack',
        method: 'get',
        params: {companyid : companyid}
      })
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    后端代码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);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    后端代码Mapper

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

    后端代码Mapper.xml

    <select id="routineWriteBack" resultType="java.lang.Integer">
           select onduty_people from ny_post_number where companyid = #{companyid} and date(create_time) = date(now())
        </select>
    
    • 1
    • 2
    • 3

    Put请求 @RequestBody

    前端代码

    handleCS(){
         let body ={
           id:12,
           nyApplyDangerdetectionId:7898994,  
           uploadStatic:2,
           auditorSign:'改我了',
           auditorDescribe:'我也改了'
         }
         getSelectDanger(body).then(response => {
         });
       },
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    调用接口

    export function getSelectDanger(data) {
      return request({
        url: '/warningrisk/dangerdetection/UpdateuploadStatic',
        method: 'put',
        data: data
      })
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    后端代码controller接收

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

    后端代码Mapper层

    Integer updateuploadStatic(NyDangerdetection nydangerdetection);
    
    • 1

    后端代码Mapper.xml

    <update id="updateuploadStatic" parameterType="NyDangerdetection">
         UPDATE ny_dangerdetection a
             INNER JOIN ny_apply_dangerdetection b ON a.ny_apply_dangerdetection_id = b.id
         <trim prefix="SET" suffixOverrides=",">
             <if test="uploadStatic != 0">a.upload_static = #{uploadStatic},</if>
             <if test="uploadStatic == 2">b.auditor_sign = #{auditorSign},</if>
             <if test="uploadStatic == 3">b.auditor_describe = #{auditorDescribe} </if>
         </trim>
         where a.ny_apply_dangerdetection_id = #{nyApplyDangerdetectionId} and b.id = #{id}
    </update>	
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  • 相关阅读:
    【Doris实战】Apache-doris-2.0.2部署帮助手册
    Linux友人帐之账号用户管理
    Android修行手册 - Android Studio去掉方法参数提示、变量类型提示、方法引用Usage提示
    spring Environment上下文环境参数变量
    15、用户web层服务(三)
    elasticsearch内存占用详细分析
    60.【C++猜数字游戏(看一眼就会)】
    自动驾驶:控制算法概述
    【信号处理】构建直接序列扩频系统模型(Matlab代码实现)
    ORB-LSAM2:ComputeKeyPointsOctTree()提取特征:maxY = iniY + hCell + 6 为怎么是+6而不是+3?
  • 原文地址:https://blog.csdn.net/xiaohua616/article/details/129704401