想要post的方法以实体接收参数

        /// <summary>
        /// 更新状态
        /// </summary>
        [HttpPost("update")]
        public void UpdateStatus(AAA request)
        {
            string id = "";
            int status = 0;
            service.UpdateStatus(id, status);
        }

一种是controller打上apicontroller特性

AAA实体绑定的是请求中的body

swagger中就会以json展现请求参数,传值也是json对象传递。

POST http://localhost:8080/api/platform/v1/payment/update HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 59
Accept: application/json, text/plain, */*
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Content-Type: application/json;charset=UTF-8
Origin: http://localhost:8080
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:8080/business/afterfact-payment/nonconpayment-list
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6
Cookie: koa.sid=ej4-i3ShusQXwo2ymYZjFCsNdj-BW2_P; koa.sid.sig=gMls5FHflXF3mqhotmaqnggRlzY

{"status":"-1","id":"d990ae6f-fe71-46d3-9bd3-44a0cedc2110"}

还有一种是url中querystring传值,后端接口没有APIController特性时,默认FromQuery

AAA实体绑定的是请求中的querystring

//[FromQuery]可以省略,默认就是这个

POST http://localhost:5000/v1/payment/update?status=2&id=2 HTTP/1.1
Host: localhost:5000
Connection: keep-alive
Content-Length: 0
accept: application/json
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
current_user: eyJpZCI6IjY3REZGRERCLTA4REEtNDI3QS05RDM1LTcyODIzM0Y4OTNCMCIsIm5hbWUiOiJUZXJyeeelneeRnuWQjCIsImFjY291bnQiOiJydWkudG9uZy56aHVAc2NoaW5kbGVyLmNvbSIsImxhbmd1YWdlIjoiemgifQ==
Origin: http://localhost:5000
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:5000/swagger/index.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6
Cookie: koa.sid=ej4-i3ShusQXwo2ymYZjFCsNdj-BW2_P; koa.sid.sig=gMls5FHflXF3mqhotmaqnggRlzY
// 前端代码url传入
UpdateStatus(status: string, id: string) {
    const _url = `/api/platform/v1/payment/update?id=21334&status=2`;
    return httpHelper.post(_url, {});
  }
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="id">主键</param>
        /// <param name="status">状态值</param>
        [HttpPost("update")]
        public void UpdateStatus([FromQuery]AAA request) //[FromQuery]可以省略,默认就是这个
        {
            string id = "";
            int status = 0;
            service.UpdateStatus(id, status);
        }

写法三FromBody

 // 前端body中传入json,后端body接收
 UpdateStatus(status: string, id: string) {
    const _url = `/api/platform/v1/payment/update`;
    return httpHelper.post(_url, {status:status,id:id});
  }
    /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="id">主键</param>
        /// <param name="status">状态值</param>
        [HttpPost("update")]
        public void UpdateStatus([FromBody]AAA request)
        {
            string id = "";
            int status = 0;
            service.UpdateStatus(id, status);
        }