diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a2a3040aa86debfd8826d9c2b5c816314c17d9fe --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/bin/.mvn/wrapper/MavenWrapperDownloader.class b/bin/.mvn/wrapper/MavenWrapperDownloader.class new file mode 100644 index 0000000000000000000000000000000000000000..ffab362825e8ae09ceeddebc96d9290920416bb7 Binary files /dev/null and b/bin/.mvn/wrapper/MavenWrapperDownloader.class differ diff --git a/bin/.mvn/wrapper/maven-wrapper.jar b/bin/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054 Binary files /dev/null and b/bin/.mvn/wrapper/maven-wrapper.jar differ diff --git a/bin/.mvn/wrapper/maven-wrapper.properties b/bin/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..642d572ce90e5085986bdd9c9204b9404f028084 --- /dev/null +++ b/bin/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/bin/pom.xml b/bin/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..5e1922682934480873198017c7c8f950d637c7f8 --- /dev/null +++ b/bin/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.13.RELEASE + + + com.example + springBoot + 0.0.1-SNAPSHOT + Resource-Statistics + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + mysql + mysql-connector-java + 5.1.38 + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/bin/src/main/java/com/syq/ResourceStatisticsApplication.class b/bin/src/main/java/com/syq/ResourceStatisticsApplication.class new file mode 100644 index 0000000000000000000000000000000000000000..60ff94a67db05daa20e66ef4c2b4bf424b3b54f0 Binary files /dev/null and b/bin/src/main/java/com/syq/ResourceStatisticsApplication.class differ diff --git a/bin/src/main/java/com/syq/config/CorsConfig.class b/bin/src/main/java/com/syq/config/CorsConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..248f4860ed915e5f56cf052d550f86ac65e2d366 Binary files /dev/null and b/bin/src/main/java/com/syq/config/CorsConfig.class differ diff --git a/bin/src/main/java/com/syq/controller/ComputersController.class b/bin/src/main/java/com/syq/controller/ComputersController.class new file mode 100644 index 0000000000000000000000000000000000000000..e30c7bf052dc4bcbf2a6e989a94488bc348267d9 Binary files /dev/null and b/bin/src/main/java/com/syq/controller/ComputersController.class differ diff --git a/bin/src/main/java/com/syq/controller/ResourcesRoomController.class b/bin/src/main/java/com/syq/controller/ResourcesRoomController.class new file mode 100644 index 0000000000000000000000000000000000000000..3aae32a8f218ea7bfb12b48496d8feea408131a2 Binary files /dev/null and b/bin/src/main/java/com/syq/controller/ResourcesRoomController.class differ diff --git a/bin/src/main/java/com/syq/controller/StudentsController.class b/bin/src/main/java/com/syq/controller/StudentsController.class new file mode 100644 index 0000000000000000000000000000000000000000..e9396837e00d091ca1e40ed52db0d487bccd1d19 Binary files /dev/null and b/bin/src/main/java/com/syq/controller/StudentsController.class differ diff --git a/bin/src/main/java/com/syq/controller/SystemController.class b/bin/src/main/java/com/syq/controller/SystemController.class new file mode 100644 index 0000000000000000000000000000000000000000..6c0a9c869bcd9a8b1d08a4b6ee9dc0d4fafa2976 Binary files /dev/null and b/bin/src/main/java/com/syq/controller/SystemController.class differ diff --git a/bin/src/main/java/com/syq/controller/loginController.class b/bin/src/main/java/com/syq/controller/loginController.class new file mode 100644 index 0000000000000000000000000000000000000000..1eee7b2a259c2696289e808864537e19fcf5e560 Binary files /dev/null and b/bin/src/main/java/com/syq/controller/loginController.class differ diff --git a/bin/src/main/java/com/syq/entity/Computers.class b/bin/src/main/java/com/syq/entity/Computers.class new file mode 100644 index 0000000000000000000000000000000000000000..a08b45aff30e027dcaf6d45fb5274cc68619701c Binary files /dev/null and b/bin/src/main/java/com/syq/entity/Computers.class differ diff --git a/bin/src/main/java/com/syq/entity/ResourcesRoom.class b/bin/src/main/java/com/syq/entity/ResourcesRoom.class new file mode 100644 index 0000000000000000000000000000000000000000..d9b337a4eec3ca3b8e729811b2f4373bf4df5969 Binary files /dev/null and b/bin/src/main/java/com/syq/entity/ResourcesRoom.class differ diff --git a/bin/src/main/java/com/syq/entity/Students.class b/bin/src/main/java/com/syq/entity/Students.class new file mode 100644 index 0000000000000000000000000000000000000000..44afd45a5e6f1fb36b90a82385d7e0af7d5b148f Binary files /dev/null and b/bin/src/main/java/com/syq/entity/Students.class differ diff --git a/bin/src/main/java/com/syq/entity/System.class b/bin/src/main/java/com/syq/entity/System.class new file mode 100644 index 0000000000000000000000000000000000000000..2426fdc3c32f9f6096fca254055df921d17b4044 Binary files /dev/null and b/bin/src/main/java/com/syq/entity/System.class differ diff --git a/bin/src/main/java/com/syq/repository/ComputersRepository.class b/bin/src/main/java/com/syq/repository/ComputersRepository.class new file mode 100644 index 0000000000000000000000000000000000000000..d54c891f0fde75737be584023b83d4038ab8b15f Binary files /dev/null and b/bin/src/main/java/com/syq/repository/ComputersRepository.class differ diff --git a/bin/src/main/java/com/syq/repository/ResourcesRoomRepository.class b/bin/src/main/java/com/syq/repository/ResourcesRoomRepository.class new file mode 100644 index 0000000000000000000000000000000000000000..88183efdfd8f45c8497814d7552c66743c8ab619 Binary files /dev/null and b/bin/src/main/java/com/syq/repository/ResourcesRoomRepository.class differ diff --git a/bin/src/main/java/com/syq/repository/StudentRepository.class b/bin/src/main/java/com/syq/repository/StudentRepository.class new file mode 100644 index 0000000000000000000000000000000000000000..783095f853a183f7b34b8c74f2a45d9e047c4ac1 Binary files /dev/null and b/bin/src/main/java/com/syq/repository/StudentRepository.class differ diff --git a/bin/src/main/java/com/syq/repository/SystemRepository.class b/bin/src/main/java/com/syq/repository/SystemRepository.class new file mode 100644 index 0000000000000000000000000000000000000000..a231e1974e6d23e4ca0873523508d1c53b0a42ea Binary files /dev/null and b/bin/src/main/java/com/syq/repository/SystemRepository.class differ diff --git a/bin/src/main/java/com/syq/service/ComputersService.class b/bin/src/main/java/com/syq/service/ComputersService.class new file mode 100644 index 0000000000000000000000000000000000000000..73fdc852c92065020c68beb141315316f23d053e Binary files /dev/null and b/bin/src/main/java/com/syq/service/ComputersService.class differ diff --git a/bin/src/main/java/com/syq/service/ResourcesRoomService.class b/bin/src/main/java/com/syq/service/ResourcesRoomService.class new file mode 100644 index 0000000000000000000000000000000000000000..27ec722b06844870b1abef27f4d9e89b2b279837 Binary files /dev/null and b/bin/src/main/java/com/syq/service/ResourcesRoomService.class differ diff --git a/bin/src/main/java/com/syq/service/StudentsService.class b/bin/src/main/java/com/syq/service/StudentsService.class new file mode 100644 index 0000000000000000000000000000000000000000..8e45613c15867dac169c655591e4948c9bc69e57 Binary files /dev/null and b/bin/src/main/java/com/syq/service/StudentsService.class differ diff --git a/bin/src/main/java/com/syq/service/SystemService.class b/bin/src/main/java/com/syq/service/SystemService.class new file mode 100644 index 0000000000000000000000000000000000000000..f147de8435040ffb7d4b70b3f1a02197ced14f55 Binary files /dev/null and b/bin/src/main/java/com/syq/service/SystemService.class differ diff --git a/bin/src/main/java/com/syq/service/impl/ComputersServiceImpl.class b/bin/src/main/java/com/syq/service/impl/ComputersServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..99f241a0274c265387a7248cad46b237f8f8bc0c Binary files /dev/null and b/bin/src/main/java/com/syq/service/impl/ComputersServiceImpl.class differ diff --git a/bin/src/main/java/com/syq/service/impl/ResourcesRoomServiceImpl.class b/bin/src/main/java/com/syq/service/impl/ResourcesRoomServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..1b776e9f1853ccd8488baca9c4451da95f4c4ac1 Binary files /dev/null and b/bin/src/main/java/com/syq/service/impl/ResourcesRoomServiceImpl.class differ diff --git a/bin/src/main/java/com/syq/service/impl/StudentsServiceImpl.class b/bin/src/main/java/com/syq/service/impl/StudentsServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..4e0361e79083ee823674008d0ce65d751066ed2c Binary files /dev/null and b/bin/src/main/java/com/syq/service/impl/StudentsServiceImpl.class differ diff --git a/bin/src/main/java/com/syq/service/impl/SystemServiceImpl.class b/bin/src/main/java/com/syq/service/impl/SystemServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..656892d2d5df3ff4262e922690f1a5d7396f96dd Binary files /dev/null and b/bin/src/main/java/com/syq/service/impl/SystemServiceImpl.class differ diff --git a/bin/src/main/java/com/syq/util/FenyeUtil.class b/bin/src/main/java/com/syq/util/FenyeUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..2c983f84d67f0f40e93f4f0704d712a98f35f431 Binary files /dev/null and b/bin/src/main/java/com/syq/util/FenyeUtil.class differ diff --git a/bin/src/main/resources/application.properties b/bin/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..e49681fe82624af1a2785ca1faa7904acf53099d --- /dev/null +++ b/bin/src/main/resources/application.properties @@ -0,0 +1,37 @@ + + +#配置数据源 +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.url=jdbc:mysql://localhost/resource-statistics?characterEncoding=utf-8&&useSSL=false +spring.datasource.username=root +spring.datasource.password=admin + +#配置SpringDataJpa +spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect +#打印SQL语句 +spring.jpa.show-sql=true +#根据实体类自动生成数据表 +#create:每次运行项目会自动创建新数据表,有则删除 +#update:每次只会更新数据表 +spring.jpa.hibernate.ddl-auto=update +#jackjson格式化日期 +spring.jackson.date-format=yyyy-MM-dd HH:mm:ss + +#jackson对日期时间格式化设置:时区设置 +spring.jackson.time-zone=GMT+8 + +#server.port=8081 + + +#集中解决各种编码问题 +#banner.charset=UTF-8 +spring.http.encoding.charset=UTF-8 +spring.http.encoding.enabled=true +spring.http.encoding.force=true +spring.messages.encoding=UTF-8 + +server.tomcat.uri-encoding=UTF-8 + + + + diff --git a/bin/src/test/java/com/syq/ResourceStatisticsApplicationTests.class b/bin/src/test/java/com/syq/ResourceStatisticsApplicationTests.class new file mode 100644 index 0000000000000000000000000000000000000000..87ffbeb1872200f9771837fce008348c6eebe3f7 Binary files /dev/null and b/bin/src/test/java/com/syq/ResourceStatisticsApplicationTests.class differ diff --git a/src/main/java/com/syq/controller/BookTypeController.java b/src/main/java/com/syq/controller/BookTypeController.java new file mode 100644 index 0000000000000000000000000000000000000000..b24f593124f86b562771bc7a42455f20875fd1e7 --- /dev/null +++ b/src/main/java/com/syq/controller/BookTypeController.java @@ -0,0 +1,27 @@ +package com.syq.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.syq.entity.BookType; +import com.syq.service.BookTypeService; + +@RestController +@RequestMapping("/bookType") +public class BookTypeController { + @Autowired + private BookTypeService bookTypeService; + + /** + * 查询图书类别 + * @return + */ + @GetMapping + public List getAllBookType() { + return bookTypeService.getAllBookType(); + } +} diff --git a/src/main/java/com/syq/controller/BooksController.java b/src/main/java/com/syq/controller/BooksController.java new file mode 100644 index 0000000000000000000000000000000000000000..4c74be7ae29437d395e5b8918e3a38da069e926e --- /dev/null +++ b/src/main/java/com/syq/controller/BooksController.java @@ -0,0 +1,32 @@ +package com.syq.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.syq.entity.Books; +import com.syq.service.BooksService; + +@RestController +@RequestMapping("/books") +public class BooksController { + @Autowired + private BooksService booksService; + + /** + * 分页查询图书 + * @param book + * @param page + * @param limit + * @return 分页工具类(layui所需要的数据格式) + */ + @GetMapping + public Object listBooksByPage(Books book,Integer page,Integer limit) { + Pageable pageable = PageRequest.of(page-1, limit); + + return booksService.listBooksByPage(book, pageable); + } +} diff --git a/src/main/java/com/syq/controller/SystemController.java b/src/main/java/com/syq/controller/SystemController.java index 3745e5494b50272a6dc0a895e9df6e83cd23dc0f..667eccb9cde77e10c077acf41c59f2954b2bea87 100644 --- a/src/main/java/com/syq/controller/SystemController.java +++ b/src/main/java/com/syq/controller/SystemController.java @@ -3,6 +3,7 @@ package com.syq.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -21,6 +22,7 @@ public class SystemController { * 创建人:孙玉全 * @return 所有系别信息 */ + @GetMapping public List getAllSysTem() { return systemService.getAllSystem(); } diff --git a/src/main/java/com/syq/entity/BookType.java b/src/main/java/com/syq/entity/BookType.java new file mode 100644 index 0000000000000000000000000000000000000000..74fbbb11e6c69a9cf6edaf89afdbdc8b719ff63d --- /dev/null +++ b/src/main/java/com/syq/entity/BookType.java @@ -0,0 +1,24 @@ +package com.syq.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "bookType") +public class BookType { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer btid; //图书类别编号 + private String btname; //类别名称 + private String remark; //备注 +} diff --git a/src/main/java/com/syq/entity/Books.java b/src/main/java/com/syq/entity/Books.java new file mode 100644 index 0000000000000000000000000000000000000000..238a7161b0d45d8bbc2b0a7978551a01d13f07b5 --- /dev/null +++ b/src/main/java/com/syq/entity/Books.java @@ -0,0 +1,40 @@ +package com.syq.entity; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "books") +public class Books { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer bid; //图书编号 + private String bname; //图书名称 + private String author; //作者 + private String press; //出版社 + private String pressTime; //出版时间 + private String price; //价格 + private String remark; //备注 + + @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER) + @JoinColumn(name = "btid") + private BookType bookType; + + @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER) + @JoinColumn(name = "rid") + private ResourcesRoom resourcesRoom; +} diff --git a/src/main/java/com/syq/repository/BookTypeRepository.java b/src/main/java/com/syq/repository/BookTypeRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..70639efe2c6786d8036933fae73d52a55b87264f --- /dev/null +++ b/src/main/java/com/syq/repository/BookTypeRepository.java @@ -0,0 +1,10 @@ +package com.syq.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +import com.syq.entity.BookType; + +public interface BookTypeRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/com/syq/repository/BooksRepository.java b/src/main/java/com/syq/repository/BooksRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..efa9388754b8944b4f58828b4dd45b91b8bb9b61 --- /dev/null +++ b/src/main/java/com/syq/repository/BooksRepository.java @@ -0,0 +1,10 @@ +package com.syq.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +import com.syq.entity.Books; + +public interface BooksRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/com/syq/service/BookTypeService.java b/src/main/java/com/syq/service/BookTypeService.java new file mode 100644 index 0000000000000000000000000000000000000000..e24b734080d4b70c8d69c50c7958cb1b64303801 --- /dev/null +++ b/src/main/java/com/syq/service/BookTypeService.java @@ -0,0 +1,9 @@ +package com.syq.service; + +import java.util.List; + +import com.syq.entity.BookType; + +public interface BookTypeService { + List getAllBookType(); +} diff --git a/src/main/java/com/syq/service/BooksService.java b/src/main/java/com/syq/service/BooksService.java new file mode 100644 index 0000000000000000000000000000000000000000..5d9c7796a525682f4e992b88d1372a020aa0210a --- /dev/null +++ b/src/main/java/com/syq/service/BooksService.java @@ -0,0 +1,10 @@ +package com.syq.service; + +import org.springframework.data.domain.Pageable; + +import com.syq.entity.Books; +import com.syq.util.FenyeUtil; + +public interface BooksService { + FenyeUtil listBooksByPage(Books book,Pageable pageable); +} diff --git a/src/main/java/com/syq/service/impl/BookTypeServiceImpl.java b/src/main/java/com/syq/service/impl/BookTypeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5141cb894ed836ecfe8b9d939635c8cc9645bd43 --- /dev/null +++ b/src/main/java/com/syq/service/impl/BookTypeServiceImpl.java @@ -0,0 +1,24 @@ +package com.syq.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.syq.entity.BookType; +import com.syq.repository.BookTypeRepository; +import com.syq.service.BookTypeService; + +@Service +public class BookTypeServiceImpl implements BookTypeService { + + @Autowired + private BookTypeRepository bookTypeRepository; + + @Override + public List getAllBookType() { + // TODO Auto-generated method stub + return bookTypeRepository.findAll(); + } + +} diff --git a/src/main/java/com/syq/service/impl/BooksServiceImpl.java b/src/main/java/com/syq/service/impl/BooksServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8dac43f4de963d84f3f213d25ee96250ee1fe56a --- /dev/null +++ b/src/main/java/com/syq/service/impl/BooksServiceImpl.java @@ -0,0 +1,55 @@ +package com.syq.service.impl; + +import java.util.List; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import com.syq.entity.Books; +import com.syq.repository.BooksRepository; +import com.syq.service.BooksService; +import com.syq.util.FenyeUtil; + +@Service +public class BooksServiceImpl implements BooksService { + + @Autowired + private BooksRepository booksRepository; + + @Override + public FenyeUtil listBooksByPage(Books book, Pageable pageable) { + // TODO Auto-generated method stub + Page books = booksRepository.findAll(get(book), pageable); + FenyeUtil fy = new FenyeUtil(); + fy.setData(books.getContent()); + fy.setCount((int)books.getTotalElements()); + return fy; + } + + private Specification get(Books book) { + // TODO Auto-generated method stub + return new Specification() { + + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { + //创建动态SQL表达式 + Predicate predicate = criteriaBuilder.conjunction(); + //创建动态SQL集合 + List> bList = predicate.getExpressions(); + + + return predicate; + } + }; + } + +}