diff --git a/src/main/java/com/kwan/springbootkwan/controller/ChatbotController.java b/src/main/java/com/kwan/springbootkwan/controller/ChatbotController.java index 56819ce326ade1b46053a440a2562d1b1ef5a5fe..0f113d5d267a1542a5d756e3613a6189dd63a52b 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/ChatbotController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/ChatbotController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.kwan.springbootkwan.entity.Chatbot; import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.service.ChatbotService; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -59,12 +60,18 @@ public class ChatbotController { * @return 所有数据 */ @GetMapping("/page") - public Result selectAll(@RequestParam Integer page, @RequestParam Integer pageSize) { + public Result selectAll(@RequestParam Integer page + , @RequestParam Integer pageSize + , @RequestParam String question) { Page page1 = new Page<>(); page1.setCurrent(page); page1.setSize(pageSize); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.orderByDesc("id"); // 按照 id 字段降序排列 + wrapper.eq("is_delete", 0); // 按照 id 字段降序排列 + if (StringUtils.isNotEmpty(question)) { + wrapper.like("question", question); + } return Result.ok(this.chatbotService.page(page1, wrapper)); } @@ -111,5 +118,14 @@ public class ChatbotController { public Result delete(@RequestParam("idList") List idList) { return Result.ok(this.chatbotService.removeByIds(idList)); } + + @GetMapping("/delete") + public Result delete(@RequestParam("id") Integer id) { + Chatbot chatbot = new Chatbot(); + chatbot.setIsDelete(1); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("id", id); + return Result.ok(chatbotService.update(chatbot, wrapper)); + } } diff --git a/src/main/java/com/kwan/springbootkwan/entity/Chatbot.java b/src/main/java/com/kwan/springbootkwan/entity/Chatbot.java index efbd55a5aed32c60722c1b43bded0bbdf6ddb00f..e748c971324a325f74d4990100c059effab679cc 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/Chatbot.java +++ b/src/main/java/com/kwan/springbootkwan/entity/Chatbot.java @@ -19,4 +19,5 @@ public class Chatbot extends Model { private String question; private String response; private Date createTime; + private Integer isDelete; } \ No newline at end of file