项目作者: volewu

项目描述 :
基于 Java 的电影聚合系统,采用 Springboot , MySQL , Thymeleaf .....(召唤完毕.....)
高级语言: Java
项目地址: git://github.com/volewu/Film.git
创建时间: 2018-04-25T09:09:27Z
项目社区:https://github.com/volewu/Film

开源协议:Apache License 2.0

关键词:
"film" "java-spring-boot" "mysql" "thymeleaf"

下载


Film

一、项目简介:

一个采用 SpringBoot 架构的电影聚合 JavaWeb 项目,适用于 SpringBoot 练手项目

二、运行环境

三、项目技术

  • Spring && Spring Boot && Spring Sectuity

  • Spring Data Jpa

  • EsayUI + Bootstrap

  • thymeleaf

  • ckeditor

  • 运行截图

    film

四、姿势点

1、 SpringSecurity 中得到登入的用户名
  1. th:text="${#httpServletRequest.remoteUser}"
2、thymeleaf 问题
  1. /*<![CDATA[*/
  2. 中不扫描该注释中的代码
  3. /*]]>*/
  4. //时间转换
  5. ${#dates.format(film.publishDate,'yyyy-MM-dd HH:mm:ss')}
3、jpa 中格式化时间 CustomDateSerializer.java
  1. @JsonSerialize(using = CustomDateSerializer.class)
  2. public Date getPublishDate() {
  3. return publishDate;
  4. }
4、jpa 中 Repository 自定义方法 WebSiteInfoRepository.java
  1. // 1 代表第一个参数
  2. @Query(value = "select * from t_info where film_id=?1", nativeQuery = true)
  3. List<WebSiteInfo> getByFilmId(Integer filmId);
5、jpa 中模糊查询拼接 FilmServiceImpl.java
  1. @Override
  2. public List<Film> list(Film film, Integer page, Integer pageSize) {
  3. Pageable pageable = new PageRequest(page, pageSize, Sort.Direction.DESC, "publishDate");
  4. Page<Film> filmPage = filmRepository.findAll((root, criteriaQuery, cb) -> {
  5. Predicate predicate = cb.conjunction();
  6. if (film != null) {
  7. if (StringUtil.isNotEmpty(film.getName()))
  8. predicate.getExpressions().add(cb.like(root.get("name"), "%" + film.getName().trim() + "%"));
  9. }
  10. return predicate;
  11. }, pageable);
  12. return filmPage.getContent();
  13. }
  14. //controller 调用时 page 参数要减一
  15. filmService.list(film, page - 1, rows);
6 、jQuery 中文档加载完毕后加载数据—模糊查询
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $('#film').combobox({
  4. mode:'remote',
  5. url:'/admin/film/comboList',
  6. valueField:'id',
  7. textField:'name',
  8. delay:100
  9. });
  10. $('#webSite').combobox({
  11. mode:'remote',
  12. url:'/admin/webSite/comboList',
  13. valueField:'id',
  14. textField:'url',
  15. delay:100
  16. });
  17. });
  18. </script>
7. SQL 语法
  1. /**
  2. * 根据 id 获取上一个数据
  3. * @param id
  4. * @return
  5. */
  6. @Query(value = "SELECT * FROM t_film where id <?1 ORDER BY id DESC limit 1", nativeQuery = true)
  7. Film getLastFilm(Integer id);
  8. /**
  9. * 根据 id 获取下一个数据
  10. * @param id
  11. * @return
  12. */
  13. @Query(value = "SELECT * FROM t_film where id >?1 ORDER BY id ASC limit 1", nativeQuery = true)
  14. Film getNextFilm(Integer id);
  15. /**
  16. * 随机取几条数据
  17. * @param n
  18. * @return
  19. */
  20. @Query(value = "SELECT * FROM t_film ORDER BY rand() limit ?1",nativeQuery = true)
  21. List<Film> randomList(Integer n);