emp java开发平台,给EmpMapper开放Restful接口

packagecom.ufo.gatling.ctrl;importjava.util.List;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RestController;importcom.ufo.gatling.entity.Emp;importcom.ufo.gatling.mapper.EmpMapper;

@RestController

@RequestMapping("/emp")public classEmpCtrl {

@Autowiredprivate 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("/")

ListfindAll() {returnempMapper.findAll();

}// http://localhost:8080/emp/findbyid/5//{"id":5,"name":"Eliot","salary":18000}

@RequestMapping("/findbyid/{id}")

Emp findById(@PathVariable("id") longid) {returnempMapper.findById(id);

}// http://localhost:8080/emp/updateById/1/gatesss/12345//ok

@RequestMapping("/updateById/{id}/{name}/{salary}")

String updateById(@PathVariable("id") longid,

@PathVariable("name") String name,

@PathVariable("salary") intsalary) {

Emp emp=newEmp();

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") longid) {

Emp emp=newEmp();

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") longid,

@PathVariable("name") String name,

@PathVariable("salary") intsalary) {

Emp emp=newEmp();

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")

ListfindHighLevelEmps() {returnempMapper.findHighLevelEmps();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值