From ab6befb3df57a4b7996e73182ede3bcdf8cc035b Mon Sep 17 00:00:00 2001 From: pzo9jb4e6 Date: Wed, 27 Jul 2022 14:21:31 +0800 Subject: [PATCH] ADD file via upload --- BookEng.java | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 BookEng.java diff --git a/BookEng.java b/BookEng.java new file mode 100644 index 0000000..137b426 --- /dev/null +++ b/BookEng.java @@ -0,0 +1,65 @@ +package com.tbook.Controller; + +import com.tbook.entity.TBook; +import com.tbook.entity.TUser; +import com.tbook.mapper.TBookMapper; +import com.tbook.service.TBookService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@Controller +public class BookEng { + + @Autowired + private TBookService tBookService; + + @RequestMapping("/admin") + public String index(){ + return "head"; + } + @RequestMapping("/user") + public String userindex(){ + return "userhead"; + } + @RequestMapping("/book") + public String book(){ + return "index"; + } + @RequestMapping("/userbook") + public String userbook(){ + return "userbook"; + } + @GetMapping("/book/all") + @ResponseBody + public List bookall(){ + TBook book=new TBook(); + + return tBookService.select(book); + } + + @PostMapping("/book/add") + @ResponseBody + public String bookadd(HttpServletRequest request, @RequestBody TBook tBook){ + if(tBook.getBookid()!=null) { + + tBookService.updateByPrimaryKeySelective(tBook); + return "修改成功"; + }else{ + + tBookService.insertSelective(tBook); + return "添加成功"; + } + } + @PostMapping("/book/del") + @ResponseBody + public String bookdel(HttpServletRequest request, @RequestBody TBook tBook){ + + tBookService.deleteByPrimaryKey(tBook.getBookid()); + return "删除成功"; + + } +}