fix:添加接口

上级 3ced4a8c
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kwan.springbootkwan.entity.Chatbot; import com.kwan.springbootkwan.entity.Chatbot;
import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.entity.Result;
import com.kwan.springbootkwan.service.ChatbotService; 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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -59,12 +60,18 @@ public class ChatbotController { ...@@ -59,12 +60,18 @@ public class ChatbotController {
* @return 所有数据 * @return 所有数据
*/ */
@GetMapping("/page") @GetMapping("/page")
public Result selectAll(@RequestParam Integer page, @RequestParam Integer pageSize) { public Result selectAll(@RequestParam Integer page
, @RequestParam Integer pageSize
, @RequestParam String question) {
Page<Chatbot> page1 = new Page<>(); Page<Chatbot> page1 = new Page<>();
page1.setCurrent(page); page1.setCurrent(page);
page1.setSize(pageSize); page1.setSize(pageSize);
QueryWrapper<Chatbot> wrapper = new QueryWrapper<>(); QueryWrapper<Chatbot> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("id"); // 按照 id 字段降序排列 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)); return Result.ok(this.chatbotService.page(page1, wrapper));
} }
...@@ -111,5 +118,14 @@ public class ChatbotController { ...@@ -111,5 +118,14 @@ public class ChatbotController {
public Result delete(@RequestParam("idList") List<Long> idList) { public Result delete(@RequestParam("idList") List<Long> idList) {
return Result.ok(this.chatbotService.removeByIds(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<Chatbot> wrapper = new QueryWrapper<>();
wrapper.eq("id", id);
return Result.ok(chatbotService.update(chatbot, wrapper));
}
} }
...@@ -19,4 +19,5 @@ public class Chatbot extends Model<Chatbot> { ...@@ -19,4 +19,5 @@ public class Chatbot extends Model<Chatbot> {
private String question; private String question;
private String response; private String response;
private Date createTime; private Date createTime;
private Integer isDelete;
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册