├── .gitignore ├── Procfile ├── README.md ├── img ├── TIM截图20180528173233.png ├── TIM截图20180528173252.png ├── TIM截图20180528173313.png ├── TIM截图20180528173322.png ├── TIM截图20180528173332.png └── TIM截图20180528173344.png ├── movie.sql ├── pom.xml └── src ├── main ├── java │ └── me │ │ └── yqiang │ │ └── movie │ │ ├── MovieApplication.java │ │ ├── config │ │ └── ComponetImport.java │ │ ├── domain │ │ ├── Audience.java │ │ ├── Movie.java │ │ ├── Rate.java │ │ └── User.java │ │ ├── enums │ │ └── ResultVoCodeEnum.java │ │ ├── exception │ │ └── LoginException.java │ │ ├── fliter │ │ └── JwtFilter.java │ │ ├── repository │ │ ├── MovieRepository.java │ │ ├── RateRepository.java │ │ └── UserRepository.java │ │ ├── service │ │ ├── MovieService.java │ │ ├── RateService.java │ │ ├── UserService.java │ │ └── impl │ │ │ ├── MovieServiceImpl.java │ │ │ ├── RateServiceImpl.java │ │ │ ├── RecommendServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ ├── utils │ │ ├── JwtHelper.java │ │ └── ResultVoUtil.java │ │ ├── vo │ │ └── ResultVo.java │ │ └── web │ │ ├── ApiTest.java │ │ ├── MovieController.java │ │ ├── RateController.java │ │ └── UserController.java └── resources │ ├── application-dev.properties │ ├── application-prod.properties │ ├── application.properties │ └── rebel.xml └── test └── java └── me └── yqiang └── movie └── MovieApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | ### STS ### 3 | .apt_generated 4 | .classpath 5 | .factorypath 6 | .project 7 | .settings 8 | .springBeans 9 | .sts4-cache 10 | 11 | ### IntelliJ IDEA ### 12 | .idea 13 | *.iws 14 | *.iml 15 | *.ipr 16 | 17 | ### NetBeans ### 18 | /nbproject/private/ 19 | /build/ 20 | /nbbuild/ 21 | /vueapp/dist/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.jar --spring.profiles.active=prod -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # movie 2 | # 电影推荐系统 3 | 4 | 在线 (https://morning-forest-54273.herokuapp.com/) 5 | - 前端 vue vuex 项目地址(https://github.com/yqxyz/movie-vue) 6 | - 后台 spring boot jpa mahout 7 | - 主页 8 | 9 | ![Alt text](https://github.com/quentinyy/movie/raw/master/img/TIM截图20180528173233.png) 10 | 11 | - 推荐 12 | 13 | ![Alt text](https://github.com/quentinyy/movie/raw/master/img/TIM截图20180528173252.png) 14 | 15 | - 评分 16 | 17 | ![Alt text](https://github.com/quentinyy/movie/raw/master/img/TIM截图20180528173344.png) 18 | -------------------------------------------------------------------------------- /img/TIM截图20180528173233.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqxyz/movie/2a9642181861650af58730ba9cc477acb20699c9/img/TIM截图20180528173233.png -------------------------------------------------------------------------------- /img/TIM截图20180528173252.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqxyz/movie/2a9642181861650af58730ba9cc477acb20699c9/img/TIM截图20180528173252.png -------------------------------------------------------------------------------- /img/TIM截图20180528173313.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqxyz/movie/2a9642181861650af58730ba9cc477acb20699c9/img/TIM截图20180528173313.png -------------------------------------------------------------------------------- /img/TIM截图20180528173322.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqxyz/movie/2a9642181861650af58730ba9cc477acb20699c9/img/TIM截图20180528173322.png -------------------------------------------------------------------------------- /img/TIM截图20180528173332.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqxyz/movie/2a9642181861650af58730ba9cc477acb20699c9/img/TIM截图20180528173332.png -------------------------------------------------------------------------------- /img/TIM截图20180528173344.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqxyz/movie/2a9642181861650af58730ba9cc477acb20699c9/img/TIM截图20180528173344.png -------------------------------------------------------------------------------- /movie.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : localhost_3306 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost:3306 8 | Source Schema : movie 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : 65001 13 | 14 | Date: 04/06/2018 23:09:18 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for movie 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `movie`; 24 | CREATE TABLE `movie` ( 25 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 26 | `ima_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 27 | `movie_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 28 | PRIMARY KEY (`id`) USING BTREE 29 | ) ENGINE = MyISAM AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 30 | 31 | -- ---------------------------- 32 | -- Records of movie 33 | -- ---------------------------- 34 | INSERT INTO `movie` VALUES (1, '1526711273653046.jpg', '哥谭 第四季 Gotham'); 35 | INSERT INTO `movie` VALUES (2, '1526726844323744.jpg', '游戏之夜'); 36 | INSERT INTO `movie` VALUES (3, '1526727108393284.jpg', '环太平洋:雷霆再起'); 37 | INSERT INTO `movie` VALUES (4, '1526727155977248.jpg', '头号玩家'); 38 | INSERT INTO `movie` VALUES (5, '1527405023383089.jpg', '良种动物'); 39 | INSERT INTO `movie` VALUES (7, '1527405918883501.jpg', '悲惨世界'); 40 | INSERT INTO `movie` VALUES (8, '1527410387608938.jpg', '猛龙怪客'); 41 | INSERT INTO `movie` VALUES (9, '1527410913000043.jpg', '绿野仙踪'); 42 | INSERT INTO `movie` VALUES (10, '1527414992530668.jpg', '苍穹浩瀚'); 43 | INSERT INTO `movie` VALUES (11, '1527415066008906.jpg', '犯罪现场调查'); 44 | INSERT INTO `movie` VALUES (12, '1527415725066605.jpg', '西部世界'); 45 | 46 | -- ---------------------------- 47 | -- Table structure for rate 48 | -- ---------------------------- 49 | DROP TABLE IF EXISTS `rate`; 50 | CREATE TABLE `rate` ( 51 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 52 | `movie_id` bigint(20) NOT NULL, 53 | `rate` double NOT NULL, 54 | `user_id` bigint(20) NOT NULL, 55 | PRIMARY KEY (`id`) USING BTREE 56 | ) ENGINE = MyISAM AUTO_INCREMENT = 34 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Fixed; 57 | 58 | -- ---------------------------- 59 | -- Records of rate 60 | -- ---------------------------- 61 | INSERT INTO `rate` VALUES (1, 1, 2.5, 1000); 62 | INSERT INTO `rate` VALUES (2, 2, 3.5, 1000); 63 | INSERT INTO `rate` VALUES (3, 3, 4.5, 1000); 64 | INSERT INTO `rate` VALUES (4, 4, 3, 1000); 65 | INSERT INTO `rate` VALUES (5, 5, 2.5, 1000); 66 | INSERT INTO `rate` VALUES (12, 1, 2, 1003); 67 | INSERT INTO `rate` VALUES (13, 2, 3, 1003); 68 | INSERT INTO `rate` VALUES (14, 3, 3, 1003); 69 | INSERT INTO `rate` VALUES (15, 4, 3, 1003); 70 | INSERT INTO `rate` VALUES (16, 5, 3, 1003); 71 | INSERT INTO `rate` VALUES (17, 7, 3, 1003); 72 | INSERT INTO `rate` VALUES (18, 8, 3.5, 1003); 73 | INSERT INTO `rate` VALUES (19, 9, 2, 1003); 74 | INSERT INTO `rate` VALUES (20, 10, 2.5, 1003); 75 | INSERT INTO `rate` VALUES (21, 11, 2.5, 1003); 76 | INSERT INTO `rate` VALUES (22, 12, 3, 1003); 77 | INSERT INTO `rate` VALUES (23, 1, 3.5, 1004); 78 | INSERT INTO `rate` VALUES (24, 2, 3.5, 1004); 79 | INSERT INTO `rate` VALUES (25, 3, 4, 1004); 80 | INSERT INTO `rate` VALUES (26, 4, 5, 1004); 81 | INSERT INTO `rate` VALUES (27, 5, 4, 1004); 82 | INSERT INTO `rate` VALUES (28, 8, 3.5, 1004); 83 | INSERT INTO `rate` VALUES (29, 9, 3.5, 1004); 84 | INSERT INTO `rate` VALUES (30, 7, 2, 1004); 85 | INSERT INTO `rate` VALUES (31, 10, 3.5, 1004); 86 | INSERT INTO `rate` VALUES (32, 11, 3.5, 1004); 87 | INSERT INTO `rate` VALUES (33, 12, 3, 1004); 88 | 89 | -- ---------------------------- 90 | -- Table structure for user 91 | -- ---------------------------- 92 | DROP TABLE IF EXISTS `user`; 93 | CREATE TABLE `user` ( 94 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 95 | `password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 96 | `user_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 97 | PRIMARY KEY (`id`) USING BTREE 98 | ) ENGINE = MyISAM AUTO_INCREMENT = 1005 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 99 | 100 | -- ---------------------------- 101 | -- Records of user 102 | -- ---------------------------- 103 | INSERT INTO `user` VALUES (1003, '12345', 'yang1'); 104 | INSERT INTO `user` VALUES (1004, '12345', 'aaa'); 105 | INSERT INTO `user` VALUES (1000, '12345', 'yang'); 106 | 107 | SET FOREIGN_KEY_CHECKS = 1; 108 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | me.yqiang 7 | movie 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | movie 12 | movie 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.2.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-jpa 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | 44 | com.alibaba 45 | druid 46 | 1.1.9 47 | 48 | 49 | 50 | mysql 51 | mysql-connector-java 52 | 53 | 54 | 55 | 56 | org.projectlombok 57 | lombok 58 | provided 59 | 60 | 61 | 62 | io.jsonwebtoken 63 | jjwt 64 | 0.9.0 65 | 66 | 67 | 68 | 69 | com.qcloud 70 | cos_api 71 | 5.4.3 72 | 73 | 74 | slf4j-log4j12 75 | org.slf4j 76 | 77 | 78 | 79 | 80 | 81 | com.github.tobato 82 | fastdfs-client 83 | 1.26.2 84 | 85 | 86 | 87 | com.cloudinary 88 | cloudinary-http44 89 | 1.18.0 90 | 91 | 92 | com.cloudinary 93 | cloudinary-taglib 94 | 1.18.0 95 | 96 | 97 | 98 | com.google.guava 99 | guava 100 | 14.0.1 101 | 102 | 103 | org.apache.mahout 104 | mahout-integration 105 | 0.13.0 106 | 107 | 108 | org.apache.hbase 109 | hbase-client 110 | 111 | 112 | org.apache.solr 113 | solr-commons-csv 114 | 115 | 116 | org.apache.hadoop 117 | hadoop-client 118 | 119 | 120 | org.apache.lucene 121 | lucene-core 122 | 123 | 124 | org.apache.lucene 125 | lucene-analyzers-common 126 | 127 | 128 | 129 | com.tdunning 130 | t-digest 131 | 132 | 133 | it.unimi.dsi 134 | fastutil 135 | 136 | 137 | com.thoughtworks.xstream 138 | xstream 139 | 140 | 141 | org.apache.commons 142 | commons-cli 143 | 144 | 145 | commons-cli 146 | commons-cli 147 | 148 | 149 | org.apache.mahout.commons 150 | commons-cli 151 | 152 | 153 | commons-io 154 | commons-io 155 | 156 | 157 | jackson-core 158 | com.fasterxml.jackson.core 159 | 160 | 161 | guava 162 | com.google.guava 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | org.springframework.boot 173 | spring-boot-maven-plugin 174 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/MovieApplication.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie; 2 | 3 | import me.yqiang.movie.fliter.JwtFilter; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | @SpringBootApplication 10 | public class MovieApplication { 11 | 12 | 13 | //过滤器 14 | @Bean 15 | public FilterRegistrationBean jwtFilter() { 16 | final FilterRegistrationBean registrationBean = new FilterRegistrationBean(); 17 | registrationBean.setFilter(new JwtFilter()); 18 | registrationBean.addUrlPatterns("/api/jwt/*"); 19 | return registrationBean; 20 | } 21 | public static void main(String[] args) { 22 | SpringApplication.run(MovieApplication.class, args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/config/ComponetImport.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.config; 2 | 3 | import com.github.tobato.fastdfs.FdfsClientConfig; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.EnableMBeanExport; 6 | import org.springframework.context.annotation.Import; 7 | import org.springframework.jmx.support.RegistrationPolicy; 8 | 9 | 10 | /** 11 | * 导入FastDFS-Client组件 12 | * 13 | * @author tobato 14 | * 15 | */ 16 | @Configuration 17 | @Import(FdfsClientConfig.class) 18 | // 解决jmx重复注册bean的问题 19 | @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) 20 | public class ComponetImport { 21 | // 导入依赖组件 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/domain/Audience.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.domain; 2 | 3 | 4 | import lombok.Data; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Data 9 | @Component 10 | public class Audience { 11 | @Value("${audience.clientId}") 12 | private String clientId; 13 | @Value("${audience.base64Secret}") 14 | private String base64Secret; 15 | @Value("${audience.name}") 16 | private String name; 17 | @Value("${audience.expiresSecond}") 18 | private int expiresSecond; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/domain/Movie.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | 6 | import javax.persistence.*; 7 | 8 | @Data 9 | @Entity 10 | @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) 11 | 12 | public class Movie { 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private Long id; 16 | @Column(name = "movie_name",nullable = false,length = 20) 17 | private String movieName; 18 | @Column(name = "ima_name",nullable = false,length = 20) 19 | private String imgName; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/domain/Rate.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.domain; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | 7 | @Data 8 | @Entity 9 | public class Rate { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | private Long id; 13 | @Column(name = "movie_id",nullable = false,length = 20) 14 | private Long movieId; 15 | @Column(name = "user_id",nullable = false,length = 20) 16 | private Long userId; 17 | @Column(name = "rate",nullable = false) 18 | private Double rate; 19 | @Transient 20 | private Integer num; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/domain/User.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.domain; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import javax.persistence.*; 7 | 8 | @Entity 9 | @Data 10 | public class User { 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private Long id; 14 | @Column(name = "user_name",nullable = false,length = 10) 15 | private String userName; 16 | @Column(name = "password",nullable = false,length = 20) 17 | private String password; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/enums/ResultVoCodeEnum.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.enums; 2 | 3 | public enum ResultVoCodeEnum { 4 | 5 | UNKONW_ERROR(-1,"未知错误"), 6 | SUCCESS(0,"成功"), 7 | LOSE(1,"失败"), 8 | PARAM_ERROR(17,"参数不正确"), 9 | ; 10 | 11 | 12 | private Integer code; 13 | 14 | private String msg; 15 | 16 | ResultVoCodeEnum(Integer code, String msg) { 17 | this.code = code; 18 | this.msg = msg; 19 | } 20 | 21 | public Integer getCode() { 22 | return code; 23 | } 24 | 25 | public String getMsg() { 26 | return msg; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/exception/LoginException.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.exception; 2 | 3 | public class LoginException extends RuntimeException{ 4 | public LoginException(){ 5 | super(); 6 | } 7 | public LoginException(String msg){ 8 | super(msg); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/fliter/JwtFilter.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.fliter; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import me.yqiang.movie.domain.Audience; 5 | import me.yqiang.movie.utils.JwtHelper; 6 | import org.springframework.beans.factory.BeanFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.context.support.WebApplicationContextUtils; 9 | import org.springframework.web.filter.GenericFilterBean; 10 | 11 | import javax.servlet.FilterChain; 12 | import javax.servlet.ServletException; 13 | import javax.servlet.ServletRequest; 14 | import javax.servlet.ServletResponse; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.IOException; 18 | 19 | 20 | public class JwtFilter extends GenericFilterBean { 21 | 22 | @Autowired 23 | private Audience audience; 24 | 25 | /** 26 | * Reserved claims(保留),它的含义就像是编程语言的保留字一样,属于JWT标准里面规定的一些claim。JWT标准里面定好的claim有: 27 | 28 | iss(Issuser):代表这个JWT的签发主体; 29 | sub(Subject):代表这个JWT的主体,即它的所有人; 30 | aud(Audience):代表这个JWT的接收对象; 31 | exp(Expiration time):是一个时间戳,代表这个JWT的过期时间; 32 | nbf(Not Before):是一个时间戳,代表这个JWT生效的开始时间,意味着在这个时间之前验证JWT是会失败的; 33 | iat(Issued at):是一个时间戳,代表这个JWT的签发时间; 34 | jti(JWT ID):是JWT的唯一标识。 35 | * @param req 36 | * @param res 37 | * @param chain 38 | * @throws IOException 39 | * @throws ServletException 40 | */ 41 | @Override 42 | public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) 43 | throws IOException, ServletException { 44 | 45 | final HttpServletRequest request = (HttpServletRequest) req; 46 | final HttpServletResponse response = (HttpServletResponse) res; 47 | //等到请求头信息authorization信息 48 | final String authHeader = request.getHeader("authorization"); 49 | 50 | // if ("OPTIONS".equals(request.getMethod())) { 51 | // response.setStatus(HttpServletResponse.SC_OK); 52 | // chain.doFilter(req, res); 53 | // } else { 54 | 55 | if (authHeader == null || !authHeader.startsWith("bearer;")) { 56 | throw new ServletException("Missing or invalid Authorization header."); 57 | } 58 | final String token = authHeader.substring(7); 59 | 60 | try { 61 | if(audience == null){ 62 | BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext()); 63 | audience = (Audience) factory.getBean("audience"); 64 | } 65 | final Claims claims = JwtHelper.parseJWT(token,audience.getBase64Secret()); 66 | if(claims == null){ 67 | throw new ServletException("parseJWT error."); 68 | } 69 | request.setAttribute("claims", claims); 70 | } catch (final Exception e) { 71 | throw new ServletException("Invalid token."); 72 | } 73 | 74 | chain.doFilter(req, res); 75 | // } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/repository/MovieRepository.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.repository; 2 | 3 | import me.yqiang.movie.domain.Movie; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface MovieRepository extends JpaRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/repository/RateRepository.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.repository; 2 | 3 | import me.yqiang.movie.domain.Rate; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | 7 | import java.util.List; 8 | 9 | public interface RateRepository extends JpaRepository { 10 | List findByUserId(Long userId); 11 | @Query(value = "SELECT rate.movie_id AS movieId ,AVG(rate.rate) AS rate,COUNT(rate.movie_id) AS num FROM rate GROUP BY rate.movie_id",nativeQuery = true) 12 | List findRateCount(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.repository; 2 | 3 | import me.yqiang.movie.domain.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserRepository extends JpaRepository { 7 | User findByUserName(String userName); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/MovieService.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service; 2 | 3 | import me.yqiang.movie.domain.Movie; 4 | import org.springframework.data.domain.Page; 5 | 6 | import java.util.List; 7 | 8 | public interface MovieService { 9 | void save(Movie movie); 10 | 11 | Page findAll(Integer page,Integer size); 12 | List findAll(); 13 | Movie getOne(Long id); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/RateService.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service; 2 | 3 | import me.yqiang.movie.domain.Rate; 4 | 5 | import java.util.List; 6 | 7 | public interface RateService { 8 | Rate save(Rate rate); 9 | List findByUserId(Long userId); 10 | List findAllGroupByMovieId(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/UserService.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service; 2 | 3 | import me.yqiang.movie.domain.User; 4 | 5 | public interface UserService { 6 | User findByUserName(String userName); 7 | 8 | User save(User user); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/impl/MovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service.impl; 2 | 3 | import me.yqiang.movie.domain.Movie; 4 | import me.yqiang.movie.repository.MovieRepository; 5 | import me.yqiang.movie.service.MovieService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.data.domain.Page; 8 | import org.springframework.data.querydsl.QPageRequest; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Service 14 | public class MovieServiceImpl implements MovieService { 15 | 16 | private MovieRepository movieRepository; 17 | @Autowired 18 | public MovieServiceImpl(MovieRepository movieRepository) { 19 | this.movieRepository = movieRepository; 20 | } 21 | 22 | @Override 23 | public void save(Movie movie) { 24 | movieRepository.save(movie); 25 | } 26 | 27 | @Override 28 | public Page findAll(Integer page,Integer size) { 29 | return movieRepository.findAll(new QPageRequest(page,size)); 30 | } 31 | 32 | @Override 33 | public List findAll() { 34 | return movieRepository.findAll(); 35 | } 36 | @Override 37 | public Movie getOne(Long id) { 38 | 39 | return movieRepository.getOne(id); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/impl/RateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service.impl; 2 | 3 | import me.yqiang.movie.domain.Rate; 4 | import me.yqiang.movie.repository.RateRepository; 5 | import me.yqiang.movie.service.RateService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class RateServiceImpl implements RateService { 13 | @Autowired 14 | public RateServiceImpl(RateRepository rateRepository) { 15 | this.rateRepository = rateRepository; 16 | } 17 | private RateRepository rateRepository; 18 | @Override 19 | public Rate save(Rate rate) { 20 | return rateRepository.save(rate); 21 | } 22 | 23 | @Override 24 | public List findByUserId(Long userId) { 25 | return rateRepository.findByUserId(userId); 26 | } 27 | 28 | @Override 29 | public List findAllGroupByMovieId() { 30 | return rateRepository.findRateCount(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/impl/RecommendServiceImpl.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service.impl; 2 | 3 | import org.apache.mahout.cf.taste.common.TasteException; 4 | import org.apache.mahout.cf.taste.impl.model.jdbc.MySQLJDBCDataModel; 5 | import org.apache.mahout.cf.taste.impl.model.jdbc.ReloadFromJDBCDataModel; 6 | import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender; 7 | import org.apache.mahout.cf.taste.impl.similarity.EuclideanDistanceSimilarity; 8 | import org.apache.mahout.cf.taste.model.JDBCDataModel; 9 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 10 | import org.apache.mahout.cf.taste.recommender.Recommender; 11 | import org.apache.mahout.cf.taste.similarity.ItemSimilarity; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | 15 | import javax.sql.DataSource; 16 | import java.util.List; 17 | @Service 18 | public class RecommendServiceImpl { 19 | @Autowired 20 | DataSource dataSource; 21 | 22 | public List recommenderItem(Long id, Integer num) throws TasteException { 23 | 24 | JDBCDataModel model = new MySQLJDBCDataModel(dataSource, "rate", 25 | "user_id", "movie_id", "rate","null"); 26 | 27 | ReloadFromJDBCDataModel dataModel = new ReloadFromJDBCDataModel(model); 28 | ItemSimilarity similarity = new EuclideanDistanceSimilarity(dataModel); 29 | Recommender r = new GenericItemBasedRecommender(dataModel, similarity); 30 | return r.recommend(id, num); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.service.impl; 2 | 3 | import me.yqiang.movie.domain.User; 4 | import me.yqiang.movie.repository.UserRepository; 5 | import me.yqiang.movie.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class UserServiceImpl implements UserService { 11 | 12 | private UserRepository userRepository; 13 | @Autowired 14 | public UserServiceImpl(UserRepository userRepository) { 15 | this.userRepository=userRepository; 16 | } 17 | 18 | @Override 19 | public User findByUserName(String userName) { 20 | return userRepository.findByUserName(userName); 21 | } 22 | 23 | @Override 24 | public User save(User user) { 25 | return userRepository.save(user); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/utils/JwtHelper.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.utils; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.JwtBuilder; 5 | import io.jsonwebtoken.Jwts; 6 | import io.jsonwebtoken.SignatureAlgorithm; 7 | 8 | import javax.crypto.spec.SecretKeySpec; 9 | import javax.xml.bind.DatatypeConverter; 10 | import java.security.Key; 11 | import java.util.Date; 12 | 13 | public class JwtHelper { 14 | 15 | /** 16 | * 解析jwt 17 | */ 18 | public static Claims parseJWT(String jsonWebToken, String base64Security){ 19 | try 20 | { 21 | Claims claims = Jwts.parser() 22 | .setSigningKey(DatatypeConverter.parseBase64Binary(base64Security)) 23 | .parseClaimsJws(jsonWebToken).getBody(); 24 | return claims; 25 | } 26 | catch(Exception ex) 27 | { 28 | return null; 29 | } 30 | } 31 | 32 | /** 33 | * 构建jwt 34 | */ 35 | public static String createJWT(String name, String userId, String role, 36 | String audience, String issuer, long TTLMillis, String base64Security) 37 | { 38 | SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; 39 | 40 | long nowMillis = System.currentTimeMillis(); 41 | Date now = new Date(nowMillis); 42 | 43 | //生成签名密钥 44 | byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(base64Security); 45 | Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName()); 46 | 47 | //添加构成JWT的参数 48 | JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JWT") 49 | .claim("role", role) 50 | .claim("unique_name", name) 51 | .claim("userid", userId) 52 | .setIssuer(issuer) 53 | .setAudience(audience) 54 | .signWith(signatureAlgorithm, signingKey); 55 | //添加Token过期时间 56 | if (TTLMillis >= 0) { 57 | long expMillis = nowMillis + TTLMillis; 58 | Date exp = new Date(expMillis); 59 | builder.setExpiration(exp).setNotBefore(now); 60 | } 61 | 62 | //生成JWT 63 | return builder.compact(); 64 | } 65 | } -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/utils/ResultVoUtil.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.utils; 2 | 3 | import me.yqiang.movie.enums.ResultVoCodeEnum; 4 | import me.yqiang.movie.vo.ResultVo; 5 | 6 | public class ResultVoUtil { 7 | 8 | public static ResultVo success(Object object){ 9 | ResultVo resultVo = new ResultVo(); 10 | resultVo.setCode(ResultVoCodeEnum.SUCCESS.getCode()); 11 | resultVo.setMsg(ResultVoCodeEnum.SUCCESS.getMsg()); 12 | resultVo.setData(object); 13 | return resultVo; 14 | } 15 | 16 | public static ResultVo success(){ 17 | return success(null); 18 | } 19 | 20 | 21 | public static ResultVo error(Integer code,String msg){ 22 | ResultVo resultVo = new ResultVo(); 23 | resultVo.setCode(code); 24 | resultVo.setMsg(msg); 25 | return resultVo; 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/vo/ResultVo.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.vo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ResultVo { 7 | 8 | //错误码 9 | private Integer code; 10 | 11 | //错误信息 12 | private String msg; 13 | 14 | //返回数据 15 | private T Data; 16 | 17 | 18 | } -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/web/ApiTest.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.web; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import me.yqiang.movie.utils.ResultVoUtil; 5 | import me.yqiang.movie.vo.ResultVo; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | 11 | @RestController 12 | public class ApiTest { 13 | 14 | @RequestMapping("/api/jwt/v.do") 15 | public ResultVo show(HttpServletRequest request){ 16 | Claims claims = (Claims) request.getAttribute("claims"); 17 | return ResultVoUtil.success(claims.get("userid")); 18 | } 19 | 20 | @RequestMapping("/ping") 21 | public String show(){ 22 | return "I`m Live"; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/web/MovieController.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.web; 2 | 3 | 4 | import com.cloudinary.Cloudinary; 5 | import com.cloudinary.Singleton; 6 | import com.cloudinary.utils.ObjectUtils; 7 | import com.github.tobato.fastdfs.domain.StorePath; 8 | import com.github.tobato.fastdfs.service.FastFileStorageClient; 9 | import com.qcloud.cos.COSClient; 10 | import com.qcloud.cos.ClientConfig; 11 | import com.qcloud.cos.auth.BasicCOSCredentials; 12 | import com.qcloud.cos.auth.COSCredentials; 13 | import com.qcloud.cos.model.PutObjectRequest; 14 | import com.qcloud.cos.model.PutObjectResult; 15 | import com.qcloud.cos.region.Region; 16 | import io.jsonwebtoken.Claims; 17 | import me.yqiang.movie.domain.Movie; 18 | import me.yqiang.movie.service.MovieService; 19 | import me.yqiang.movie.service.impl.RecommendServiceImpl; 20 | import me.yqiang.movie.utils.ResultVoUtil; 21 | import me.yqiang.movie.vo.ResultVo; 22 | import org.apache.mahout.cf.taste.common.TasteException; 23 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 24 | 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.beans.factory.annotation.Value; 27 | import org.springframework.data.domain.Page; 28 | import org.springframework.web.bind.annotation.RequestMapping; 29 | import org.springframework.web.bind.annotation.RestController; 30 | import org.springframework.web.multipart.MultipartFile; 31 | 32 | import javax.servlet.http.HttpServletRequest; 33 | import java.io.File; 34 | import java.io.IOException; 35 | import java.util.List; 36 | import java.util.Map; 37 | import java.util.Random; 38 | 39 | @RestController 40 | public class MovieController { 41 | private MovieService movieService; 42 | @Value("${qcloud.cos.secretId}") 43 | private String secretId; 44 | @Value("${qcloud.cos.secretKey}") 45 | private String secretKey; 46 | @Value("${qcloud.cos.region}") 47 | private String region; 48 | @Value("${qcloud.cos.bucketName}") 49 | private String bucketName; 50 | @Value("${cos.server}") 51 | private Boolean cosServer; 52 | @Value("${tx.server}") 53 | private Boolean txServer; 54 | @Value("${cloudinary.server}") 55 | private Boolean cloudServer; 56 | @Value("${img.address}") 57 | private String imgAddress; 58 | @Value("${cos.address}") 59 | private String cosAddress; 60 | 61 | @Value("${recommend.size}") 62 | private Integer recommendSize; 63 | private RecommendServiceImpl recommendService; 64 | private FastFileStorageClient fastFileStorageClient; 65 | @Autowired 66 | public MovieController(MovieService movieService, RecommendServiceImpl recommendService,FastFileStorageClient fastFileStorageClient) { 67 | this.movieService = movieService; 68 | this.recommendService = recommendService; 69 | this.fastFileStorageClient = fastFileStorageClient; 70 | } 71 | 72 | @RequestMapping("/api/jwt/movie/upload.do") 73 | public ResultVo upload(MultipartFile file,String movieName) throws IOException { 74 | if(file.isEmpty()){ 75 | return ResultVoUtil.error(400,"error"); 76 | } 77 | String imgName = ""; 78 | if(txServer){ 79 | String extension = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); 80 | StorePath storePath = fastFileStorageClient.uploadFile(file.getInputStream(), file.getSize(), extension, null); 81 | System.out.println(storePath.getFullPath()); 82 | imgName = imgAddress+storePath.getFullPath(); 83 | } 84 | 85 | 86 | if(cloudServer){ 87 | 88 | String suffix ="."+ file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); 89 | File tempFile = File.createTempFile("tem",suffix); 90 | file.transferTo(tempFile); 91 | Cloudinary cloudinary = Singleton.getCloudinary(); 92 | Map uploadResult = cloudinary.uploader().upload(tempFile, ObjectUtils.emptyMap()); 93 | imgName = (String) uploadResult.get("secure_url"); 94 | 95 | } 96 | if(cosServer){ 97 | long millis = System.currentTimeMillis(); 98 | //加上三位随机数 99 | Random random = new Random(); 100 | int end3 = random.nextInt(999); 101 | //如果不足三位前面补0 102 | String str = millis + String.format("%03d", end3); 103 | String suffix ="."+ file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); 104 | imgName = cosAddress+str+suffix; 105 | // 1 初始化用户身份信息(secretId, secretKey) 106 | COSCredentials cred = new BasicCOSCredentials(secretId, secretKey); 107 | // 2 设置bucket的区域, COS地域的简称请参照 https://cloud.tencent.com/document/product/436/6224 108 | ClientConfig clientConfig = new ClientConfig(new Region(region)); 109 | // 3 生成cos客户端 110 | COSClient cosclient = new COSClient(cred, clientConfig); 111 | 112 | String key = "/"+str+suffix; 113 | File tempFile = File.createTempFile(str, suffix); 114 | file.transferTo(tempFile); 115 | PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, tempFile); 116 | PutObjectResult putObjectResult = cosclient.putObject(putObjectRequest); 117 | cosclient.shutdown(); 118 | } 119 | Movie movie = new Movie(); 120 | movie.setMovieName(movieName); 121 | movie.setImgName(imgName); 122 | movieService.save(movie); 123 | return ResultVoUtil.success(imgName); 124 | 125 | } 126 | 127 | @RequestMapping("/api/movie/list.do") 128 | public ResultVo list(){ 129 | List movieList = movieService.findAll(); 130 | return ResultVoUtil.success(movieList); 131 | } 132 | @RequestMapping("/api/movie/listPage.do") 133 | public ResultVo list(Integer page,Integer size){ 134 | Page movieList = movieService.findAll(page,size); 135 | return ResultVoUtil.success(movieList); 136 | } 137 | @RequestMapping("/api/movie/info.do") 138 | public ResultVo list(Long id){ 139 | Movie movie = movieService.getOne(id); 140 | return ResultVoUtil.success(movie); 141 | } 142 | @RequestMapping("/api/jwt/movie/recommend.do") 143 | public ResultVo recommend(HttpServletRequest request) throws TasteException { 144 | Claims claims = (Claims) request.getAttribute("claims"); 145 | List recommendedItems = recommendService.recommenderItem(Long.parseLong(String.valueOf(claims.get("userid"))), recommendSize); 146 | return ResultVoUtil.success(recommendedItems); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/web/RateController.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.web; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import me.yqiang.movie.domain.Rate; 5 | import me.yqiang.movie.service.RateService; 6 | import me.yqiang.movie.utils.ResultVoUtil; 7 | import me.yqiang.movie.vo.ResultVo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import java.util.List; 14 | 15 | @RestController 16 | public class RateController { 17 | private RateService rateService; 18 | @Autowired 19 | public RateController(RateService rateService) { 20 | this.rateService = rateService; 21 | } 22 | 23 | @RequestMapping("/api/jwt/rate/save.do") 24 | public ResultVo save(Long movieId,Double rate, HttpServletRequest request){ 25 | Claims claims = (Claims) request.getAttribute("claims"); 26 | Rate rate1 = new Rate(); 27 | rate1.setMovieId(movieId); 28 | rate1.setRate(rate); 29 | rate1.setUserId(Long.parseLong(String.valueOf(claims.get("userid")))); 30 | System.out.println(rate1); 31 | Rate save = rateService.save(rate1); 32 | return ResultVoUtil.success(save); 33 | } 34 | @RequestMapping("/api/jwt/rate/list.do") 35 | public ResultVo findByUserId(HttpServletRequest request){ 36 | Claims claims = (Claims) request.getAttribute("claims"); 37 | List rateList = rateService.findByUserId(Long.parseLong(String.valueOf(claims.get("userid")))); 38 | return ResultVoUtil.success(rateList); 39 | } 40 | @RequestMapping("/api/rate/all.do") 41 | public ResultVo findAllGroupByMovieId(){ 42 | List rateList = rateService.findAllGroupByMovieId(); 43 | return ResultVoUtil.success(rateList); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/yqiang/movie/web/UserController.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie.web; 2 | 3 | import me.yqiang.movie.domain.Audience; 4 | import me.yqiang.movie.domain.User; 5 | import me.yqiang.movie.service.UserService; 6 | import me.yqiang.movie.utils.JwtHelper; 7 | import me.yqiang.movie.utils.ResultVoUtil; 8 | import me.yqiang.movie.vo.ResultVo; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | 13 | @RequestMapping 14 | @RestController 15 | public class UserController { 16 | private UserService userService; 17 | private Audience audience; 18 | @Autowired 19 | public UserController(UserService userService, Audience audience) { 20 | this.userService = userService; 21 | this.audience = audience; 22 | } 23 | 24 | @RequestMapping("/api/user/sign.do") 25 | @ResponseBody 26 | public ResultVo userAdd(User user){ 27 | System.out.println(audience.toString()); 28 | User user1 = userService.save(user); 29 | if(null!=user1 && user.getPassword().equals(user1.getPassword())){ 30 | user1.setPassword(null); 31 | 32 | String jwtToken = JwtHelper.createJWT(user1.getUserName(), 33 | String.valueOf(user1.getId()), 34 | // query_user.getRole().toString(), 35 | "", 36 | audience.getClientId(), 37 | audience.getName(), 38 | audience.getExpiresSecond()*1000, 39 | audience.getBase64Secret()); 40 | 41 | String resultStr = "bearer;" + jwtToken; 42 | return ResultVoUtil.success(resultStr); 43 | } 44 | return null; 45 | } 46 | 47 | @RequestMapping("/api/user/validate.do") 48 | @ResponseBody 49 | public boolean userValidate(String userName){ 50 | User user = userService.findByUserName(userName); 51 | return user==null; 52 | } 53 | 54 | 55 | @PostMapping("/api/user/login.do") 56 | public ResultVo login(User user) { 57 | 58 | User queryUser = userService.findByUserName(user.getUserName()); 59 | if (queryUser == null) { 60 | return ResultVoUtil.error(400, "用户名错误"); 61 | } 62 | //验证密码 63 | if(!user.getPassword().equals(queryUser.getPassword())) { 64 | return ResultVoUtil.error(400, "密码错误"); 65 | } 66 | String jwtToken = JwtHelper.createJWT(queryUser.getUserName(), 67 | String.valueOf(queryUser.getId()), 68 | // query_user.getRole().toString(), 69 | "", 70 | audience.getClientId(), 71 | audience.getName(), 72 | audience.getExpiresSecond()*1000, 73 | audience.getBase64Secret()); 74 | 75 | String resultStr = "bearer;" + jwtToken; 76 | return ResultVoUtil.success(resultStr); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql:///movie 2 | spring.datasource.username=root 3 | spring.datasource.password= 4 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver -------------------------------------------------------------------------------- /src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=${JDBC_MYSQL_URL} 2 | spring.datasource.username=${JDBC_MYSQL_USERNAME} 3 | spring.datasource.password=${JDBC_MYSQL_PASSWORD} 4 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.profiles.active=dev 2 | 3 | spring.jpa.hibernate.ddl-auto=update 4 | spring.jpa.show-sql=true 5 | cos.server=false 6 | tx.server=false 7 | cloudinary.server=true 8 | cos.address=http://images-1251510374.coshk.myqcloud.com/ 9 | img.address=http://git.yq1213.cn:8080/ 10 | fdfs.so-timeout=1501 11 | fdfs.connect-timeout=601 12 | fdfs.thumb-image.height=150 13 | fdfs.thumb-image.width=150 14 | fdfs.tracker-list[0]=${TRACKER} 15 | fdfs.pool.max-total=153 16 | fdfs.pool.max-wait-millis=102 17 | 18 | #cos 19 | qcloud.cos.secretId=${QCOLUD_COS_SECRETID} 20 | qcloud.cos.secretKey=${QCOLUD_COS_SECRETKEY} 21 | qcloud.cos.region=ap-hongkong 22 | qcloud.cos.bucketName=images-1251510374 23 | 24 | #jwt 25 | audience.clientId: 098f6bcd4621d373cade4e832627b4f6 26 | audience.base64Secret: MDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjY= 27 | audience.name: restapiuser 28 | audience.expiresSecond: 172800 29 | recommend.size=8 -------------------------------------------------------------------------------- /src/main/resources/rebel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/java/me/yqiang/movie/MovieApplicationTests.java: -------------------------------------------------------------------------------- 1 | package me.yqiang.movie; 2 | 3 | 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import java.io.IOException; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class MovieApplicationTests { 14 | 15 | @Test 16 | public void contextLoads() throws IOException { 17 | 18 | 19 | 20 | } 21 | 22 | } 23 | --------------------------------------------------------------------------------