zx 5 years ago
parent 315b1cc89d
commit b0974ef94b

@ -0,0 +1,7 @@
INSERT INTO `book_list` VALUES ('9787040535358', '全国计算机等级考试二级教程', '教育部考试中心编', '高等教育出版社', '考试', '本书根据教育部考试中心最新颁布的考试大纲编写,是教育部考试中心组织编写的全国计算机等级考试系列教程之一。', 99, 43.00);
INSERT INTO `book_list` VALUES ('9787221157270', '小芳园诗草', '(清) 李绍莲著 ; 李黎点校', '贵州人民出版社', '文学', '《小芳园诗草》的价值与意义在于保存了当时底层社会真实的状况和个体在社会变迁中的心理变化。', 99, 175.00);
INSERT INTO `book_list` VALUES ('9787302527763', '计算机网络', '张曾科编著', '清华大学出版社', '教育', '本书以因特网为中心,讲述计算机网络技术。', 90, 59.00);
INSERT INTO `book_list` VALUES ('9787514859119', '别再叫我宠物猫', '刘薇编著', '中国少年儿童出版社', '小说', '不再做宠物猫的火爪加入了四大森林猫族的雷族,他获得了真正自由的生活,能摆脱人类勇敢地做自己,但是与此同时,在他面前也充满着危险和挑战。', 10, 12.50);
INSERT INTO `book_list` VALUES ('9787520160476', '社会史研究', '行龙', '社会科学文献出版社', '社会', '本刊从研究选题到资料运用,均符合学术规范,具有较高学术价值,对于推进社会史研究多有帮助。', 20, 98.00);
INSERT INTO `book_list` VALUES ('9787521315219', '学在中国', '傅佳', '外语教学与研究出版社', '历史', '本书适用于来华接受预科教育的外国留学生也适用于追求短期高效学习的语言进修生和希望快速通过HSK五级考试的考生。', 99, 68.00);
INSERT INTO `book_list` VALUES ('9787554436967', '统计热力学', '李鹤龄, 张奎', '宁夏人民教育出版社', '科学', '本书的第一版是张奎教授与作者于1999年出版完成的2001年荣获国家教学成果二等奖、自治区教学成果一等奖。', 99, 48.00);

@ -0,0 +1 @@
INSERT INTO `user_list` VALUES ('admin1', 'admin1', 1);

@ -2,3 +2,4 @@
2.写了就git add .
3.git commit -m "当前是第几次提交就写几,总次数"
4.git push origin master

@ -9,7 +9,7 @@ public class BookApplication {
public static void main(String[] args) {
SpringApplication.run(BookApplication.class, args);
System.out.println("http://127.0.0.1:8099/query?username=admin1");
System.out.println("http://127.0.0.1:8090/query?username=admin1");
}
}

@ -21,7 +21,7 @@ public class BookController {
@ResponseBody
@GetMapping("/getallbooks")
public Result getAllBooks(){
Book []books=bookMapper.getAll();
Book[] books=bookMapper.getAll();
if(books.length<=0){
res.setCode(-1);
res.setMsg("当前系统没有书籍信息");
@ -39,7 +39,7 @@ public class BookController {
@ResponseBody
@GetMapping("/getbooks")
public Result getAllBooks(@RequestParam("kind")int kind){
public Result getAllBooksByKind(@RequestParam("kind")String kind){
Book []books=bookMapper.getBooksByKind(kind);
if(books.length<=0){
res.setCode(-1);
@ -58,7 +58,7 @@ public class BookController {
@ResponseBody
@GetMapping("/searchbooks")
public Result getAllBooks(@RequestParam("bookname")String bookname){
public Result getAllBooksBySearch(@RequestParam("bookname")String bookname){
Book []books=bookMapper.searchBooks(bookname);
if(books.length<=0){
res.setCode(-1);

@ -48,7 +48,7 @@ public class UserController {
res.setMsg("密码错误");
res.data=null;
}
else if(user.getKind()==0){
else if(user.getUserstatus()==0){
res.setCode(0);
res.setMsg("用户登录");
res.data.add(user1);
@ -73,7 +73,7 @@ public class UserController {
}
else{
user1=user;
user1.setKind(0);
user1.setUserstatus(0);
if(userMapper.InsertUser(user1)>0){
res.setCode(1);
res.setMsg("注册成功");

@ -4,8 +4,13 @@ import lombok.Data;
@Data
public class Book {
private int bookid;
private String ISBN;
private String bookname;
private float bookprice;
private String bookauthor;
private String author;
private String press;
private String classify;
private String description;
private int stock;
private float price;
}

@ -8,5 +8,5 @@ import java.util.Date;
public class User {
private String username;
private String password;
private int kind;
private int userstatus;
}

@ -1,10 +1,23 @@
package com.book.demo.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import com.book.demo.entity.Book;
import java.util.List;
@Mapper
@Repository
public interface BookMapper {
@Select("select * from book_list where classify=#{classify}")
Book[] getBooksByKind(String kind);
@Select("select * from book_list")
Book[] getAll();
@Select("select * from book_list where bookname=#{bookname}")
Book[] searchBooks(String bookname);
}

@ -11,9 +11,9 @@ import org.springframework.stereotype.Repository;
public interface UserMapper {
//通过username查询用户信息
@Select("select * from user where username=#{username}")
@Select("select * from user_list where username=#{username}")
User queryUserByusername(String username);
@Insert("insert into user values(#{username},#{password},#{kind})")
@Insert("insert into user_list values(#{username},#{password},#{kind})")
int InsertUser(User user);
}

@ -1,6 +1,6 @@
server.port=8099
server.port=8090
spring.datasource.url=jdbc:mysql://localhost:3306/bookstore?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
spring.datasource.url=jdbc:mysql://localhost:3306/test02?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root

Loading…
Cancel
Save