Springboot+Mybatis+Clickhouse+jsp 搭建單體應用項目(三)(添加增刪改查)


一、添加增加接口

1  @ApiResponses(value = {
2             @ApiResponse(code = 200, message = "接口返回成功狀態"),
3             @ApiResponse(code = 500, message = "接口返回未知錯誤,請聯系開發人員調試")
4     })
5     @ApiOperation(value = "新增數據", notes = "訪問此接口,返回hello語句,測試接口")
6     @PostMapping(value = "/insertSelective")
7     public void insertSelective(@RequestBody UserInfo userInfo) {
8         userInfoService.insertSelective(userInfo);
9     }
View Code

二、修改接口

1     @ApiResponses(value = {
2             @ApiResponse(code = 200, message = "接口返回成功狀態"),
3             @ApiResponse(code = 500, message = "接口返回未知錯誤,請聯系開發人員調試")
4     })
5     @ApiOperation(value = "修改數據", notes = "訪問此接口,返回hello語句,測試接口")
6     @PostMapping(value = "/updateByPrimaryKeySelective")
7     public void updateByPrimaryKeySelective(@RequestBody UserInfo userInfo) {
8         userInfoService.updateByPrimaryKeySelective(userInfo);
9     }
View Code

三、查詢接口

 1  @ApiResponses(value = {
 2             @ApiResponse(code = 200, message = "接口返回成功狀態"),
 3             @ApiResponse(code = 500, message = "接口返回未知錯誤,請聯系開發人員調試")
 4     })
 5     @ApiOperation(value = "按條件查詢", notes = "訪問此接口,返回hello語句,測試接口")
 6     @PostMapping(value = "/selectByStudentSelective")
 7     public List<UserInfo> selectByStudentSelective(@RequestBody UserInfo userInfo) throws ServletException, IOException {
 8 
 9         return userInfoService.selectByStudentSelective(userInfo);
10     }
View Code

四、刪除數據

1  @ApiResponses(value = {
2             @ApiResponse(code = 200, message = "接口返回成功狀態"),
3             @ApiResponse(code = 500, message = "接口返回未知錯誤,請聯系開發人員調試")
4     })
5     @ApiOperation(value = "刪除數據", notes = "訪問此接口,返回hello語句,測試接口")
6     @PostMapping(value = "/removeUser")
7     public int removeUser(@RequestBody UserInfo userInfo) {
8         return userInfoService.removeUser(userInfo);
9     }
View Code

五、注意

其中,刪除和修改的語法跟mysql和oracle略有不同,請注意

六、源碼

https://gitee.com/liuyangfirst/springboot-clickhouse.git

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM