You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.7 KiB

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<TBook> 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 "删除成功";
}
}