本文例程下载:https://files.cnblogs.com/files/xiandedanteng/gatling20200428-3.zip

接口控制器代码如下:

请求url和响应都写在了每个接口的注释上。

package com.ufo.gatling.ctrl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import com.ufo.gatling.entity.Emp;
import com.ufo.gatling.mapper.EmpMapper; @RestController
@RequestMapping("/emp")
public class EmpCtrl {
@Autowired
private EmpMapper empMapper=null; // http://localhost:8080/emp/test
// Hello Gatling
@RequestMapping("/test")
String test() {
return "Hello Gatling";
} // http://localhost:8080/emp/
// [{"id":1,"name":"Andy","salary":10000},{"id":2,"name":"Bill","salary":12000},{"id":3,"name":"Cindy","salary":16000},{"id":4,"name":"Douglas","salary":17500},{"id":5,"name":"Eliot","salary":18000},{"id":6,"name":"Felix","salary":20000}]
@RequestMapping("/")
List<Emp> findAll() {
return empMapper.findAll();
} // http://localhost:8080/emp/findbyid/5
// {"id":5,"name":"Eliot","salary":18000}
@RequestMapping("/findbyid/{id}")
Emp findById(@PathVariable("id") long id) {
return empMapper.findById(id);
} // http://localhost:8080/emp/updateById/1/gatesss/12345
// ok
@RequestMapping("/updateById/{id}/{name}/{salary}")
String updateById(@PathVariable("id") long id,
@PathVariable("name") String name,
@PathVariable("salary") int salary) { Emp emp=new Emp();
emp.setId(id);
emp.setName(name);
emp.setSalary(salary); int changedCount=empMapper.updateById(emp); return changedCount==1?"ok":"ng";
} // http://localhost:8080/emp/deleteById/1
// ok
@RequestMapping("/deleteById/{id}")
String deleteById(@PathVariable("id") long id) {
Emp emp=new Emp();
emp.setId(id);
int changedCount=empMapper.deleteById(emp);
return changedCount==1?"ok":"ng";
} // http://localhost:8080/emp/insert/1/ufo/99999
// ok
@RequestMapping("/insert/{id}/{name}/{salary}")
String insert(@PathVariable("id") long id,
@PathVariable("name") String name,
@PathVariable("salary") int salary) { Emp emp=new Emp();
emp.setId(id);
emp.setName(name);
emp.setSalary(salary); int changedCount=empMapper.insert(emp); return changedCount==1?"ok":"ng";
} // http://localhost:8080/emp/findHighLevelEmps
// [{"id":3,"name":"Cindy","salary":16000},{"id":4,"name":"Douglas","salary":17500},{"id":5,"name":"Eliot","salary":18000},{"id":6,"name":"Felix","salary":20000},{"id":1,"name":"ufo","salary":99999}]
@RequestMapping("/findHighLevelEmps")
List<Emp> findHighLevelEmps() {
return empMapper.findHighLevelEmps();
}
}

--2020-04-28--

给EmpMapper开放Restful接口的更多相关文章

  1. Swagger: 一个restful接口文档在线生成+功能测试软件

    一.什么是 Swagger? Swagger 是一款RESTFUL接口的文档在线自动生成+功能测试功能软件.Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 ...

  2. 开放数据接口 API 简介与使用场景、调用方法

    此文章对开放数据接口 API 进行了功能介绍.使用场景介绍以及调用方法的说明,供用户在使用数据接口时参考之用. 在给大家分享的一系列软件开发视频课程中,以及在我们的社区微信群聊天中,都积极地鼓励大家开 ...

  3. RESTful接口签名认证实现机制

    RESTful接口 互联网发展至今,催生出了很多丰富多彩的应用,极大地调动了人们对这些应用的使用热情.但同时也为互联网应用带来了严峻的考验.具体体现在以下几个方面: 1.     部署方式的改变:当用 ...

  4. RESTful 接口调试分享利器 restc

    这个工具来自于https://elemefe.github.io/restc/  这里对Abp进行了一次封装 1.在项目中添加nuget包 Abp.Web.Api.Restc 2.在项目Abp模块的D ...

  5. RESTful接口设计原则/最佳实践(学习笔记)

    RESTful接口设计原则/最佳实践(学习笔记) 原文地址:http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api 1 ...

  6. Apple Watch已向微信开放WatchKit接口?

    Apple Watch在北京时间凌晨1点的苹果发布会上首次对外公布了,一时间applewatch占据了各大媒体.早上也早早地看了相关新闻,其中福布斯中文网的一则消息分外引起@隔壁W叔叔的注意,“苹果同 ...

  7. Swagger+Spring mvc生成Restful接口文档

    简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

  8. [转]简单识别 RESTful 接口

         本文描述了识别一个接口是否真的是 RESTful 接口的基本方法.符合 REST 架构风格的接口,称为 RESTful 接口.本文不打算从架构风格的推导方面描述,而是从 HTTP 标准的方面 ...

  9. 运用百度开放平台接口根据ip地址获取位置

    使用百度开放平台接口根据ip地址获取位置 今天无意间发现在百度开放平台接口,就把一段代码拿了下来,有需要的可以试试看:http://opendata.baidu.com/api.php?query=5 ...

随机推荐

  1. css笔记 定位的分类

    定位:解决元素摆放的问题 使用定位可以将元素摆放到任意位置 分类 1.默认的定位 块元素垂直排列,行内元素左右排列,称之为流 流:元素有序排列而形成的队伍 特殊的定位 浮动定位:可以让块元素左右排列 ...

  2. 基于注解的DI

    目录 一.使用注解的步骤 二.@Component 三.@Value 四.@Autowired 五.@Qualifier 六.@Resource 七.XML和注解对比 通过spring的注解完成对ja ...

  3. Vue 函数式组件 functional

    函数式组件 无状态 无法实例化 内部没有任何生命周期处理函数 轻量,渲染性能高,适合只依赖于外部数据传递而变化的组件(展示组件,无逻辑和状态修改) 在template标签里标明functional 只 ...

  4. Windows下的Minio启动命令

    1.首先安装Minio到你的 Windows系统的盘符中,例如D盘 2. 打开dos命令行,进入存放minio.exe的文件夹下,输入 minio.exe server /data  命令,意味着启动 ...

  5. myBatis源码解析-类型转换篇(5)

    前言 开始分析Type包前,说明下使用场景.数据构建语句使用PreparedStatement,需要输入的是jdbc类型,但我们一般写的是java类型.同理,数据库结果集返回的是jdbc类型,而我们需 ...

  6. Pytorch_第十篇_卷积神经网络(CNN)概述

    卷积神经网络(CNN)概述 Introduce 卷积神经网络(convolutional neural networks),简称CNN.卷积神经网络相比于人工神经网络而言更适合于图像识别.语音识别等任 ...

  7. Istio Routing 实践掌握virtualservice/gateway/destinationrule/AB版本发布/金丝雀发布

    原文 在学习像 Istio 这样的新技术时,看一下示例应用程序总是一个好主意. Istio repo 有一些示例应用程序,但它们似乎有各种不足. 文档中的 BookInfo 是一个很好的示例. 但是, ...

  8. graphics.h源代码下载

    graphics.h源代码下载 /*graphics.h DefinitionsforGraphicsPackage. Copyright(c)BorlandInternational1987,198 ...

  9. onlyoffice在线编辑

    一.安装ONLYOFFICE Document Server 二.集成onlyoffice的二次开发 三.故障排除: 四.缺陷 五.总结 ONLYOFFICE Document Server提供文档协 ...

  10. 操作系统-文件系统(5)Linux文件系统管理

    主流分区机制有MBR和GPT两种 MBR分区:第一个扇区最重要,里面有:引导代码(Bootstrap code area)及分区表(partition table), 其中Bootstrap code ...