Spring Boot + vue( 五 ) 2023-07-10 生活百科vue tagCreate(@RequestBody @Valid Tag tag) {int isStatus = tagService.saveTag(tag);if (isStatus == 0) {return JsonResult.error("添加公告失败");}return JsonResult.success();}/*** 批量添加标签,最多添加10个* @param tags 以字符串的方式,以英文逗号隔开 。例如:Java,C语言,Python** @return*/@ApiOperation(value = "http://www.kingceram.com/post/批量添加标签")@PostMapping("/batchCreate")public JsonResult batchCreate(@RequestBody @Valid Tag tags) {try {boolean isStatus = tagService.batchAddTag(tags.getTagName());if (!isStatus) {return JsonResult.error("批量插入失败!");}}catch (Exception e) {return JsonResult.error(e.getMessage());}return JsonResult.success();}/*** 批量删除标签* @param ids* @return*/@ApiOperation(value = "http://www.kingceram.com/post/批量添加标签")@DeleteMapping("/batchDelete")public JsonResult batchDelete(@RequestBody @Valid String ids) {boolean isDelTag = tagService.batchDelTag(ids);if (!isDelTag) {return JsonResult.error("批量删除标签失败");}return JsonResult.success();}/*** 修改标签* @return*/@ApiOperation(value = "http://www.kingceram.com/post/修改标签")@PutMapping("/update")public JsonResult tagUpdate(@RequestBody @Valid Tag tag) {int isStatus = tagService.updateTag(tag);if (isStatus == 0) {return JsonResult.error("修改标签失败");}return JsonResult.success();}/*** 删除* @return*/@ApiOperation(value = "http://www.kingceram.com/post/删除标签")@DeleteMapping("/delete/{id}")public JsonResult tagDelete(@PathVariable(value = "http://www.kingceram.com/post/id") int id) {tagService.deleteTag(id);return JsonResult.success();}} 三、测试 这里我只测一个批量添加的接口,其他的还是老规矩大家自己测测,有bug评论区见! 请求返回成功! 再测的时候,大家要测一下如果数据库中有了数据,再添加同样的数据是否重复插入了,如果没有则过滤成功了 。 四、总结 好啦!本章的标签开发也结束了,重点是批量删除和添加的功能,其实也没那么难写代码,只要思路对,顺着写就可以了 。下面我们就要开发博客的功能了,这个才是重点,里面会整合很多的东西,希望大家好好练习基础 。 接口多测一测,文档别忘了维护和代码的提交等 。 博客代码地址: 上一篇: Boot + vue- 开发个人博客项目实战教程(十二、通知公告功能实现) 【Spring Boot + vue】下一篇: Boot + vue- 开发个人博客项目实战教程(十四、文章功能实现(上)) 上一页12345下一页 盘点Spring/Boot的那些常用扩展点 三万字盘点Spring/Boot的那些常用扩展点 【独立版】智慧城市同城V4_2.2.7全开源全插件VUE版 【独立版】智慧城市同城V4_2.1.4全开源全插件VUE版 vue body的背景图片属性设置 springboot集成redis模拟手机发送验证码进行验证 Spring Cloud应用接入华为云微服务CSE 基于Spring Boot 2.0的IoT应用集成和使用CSE实践 Spring Boot 2.0集成和使用CSE Vue 不睡觉教程1-从最土开始