├── MovieRecommend └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── xqt │ │ │ └── recommend │ │ │ ├── dao │ │ │ ├── ActionMovieDao.java │ │ │ ├── ComedyMovieDao.java │ │ │ ├── CrimeMovieDao.java │ │ │ ├── FantasyMovieDao.java │ │ │ ├── HottestMovieDao.java │ │ │ ├── LocalAuthDao.java │ │ │ ├── MovieDao.java │ │ │ ├── MusicalMovieDao.java │ │ │ ├── PersonInfoDao.java │ │ │ ├── RecommendMovieDao.java │ │ │ ├── RecommendMovieRealTimeDao.java │ │ │ ├── RomanceMovieDao.java │ │ │ ├── ThrillerMovieDao.java │ │ │ ├── UserDao.java │ │ │ ├── UserMovieRecordDao.java │ │ │ ├── UserPerefenceDao.java │ │ │ ├── WarMovieDao.java │ │ │ └── WechatAuthDao.java │ │ │ ├── dto │ │ │ ├── LocalAuthExecution.java │ │ │ ├── PersonInfoExecution.java │ │ │ ├── UserAccessToken.java │ │ │ ├── WechatAuthExecution.java │ │ │ └── WechatUser.java │ │ │ ├── entity │ │ │ ├── ActionMovie.java │ │ │ ├── ComedyMovie.java │ │ │ ├── CrimeMovie.java │ │ │ ├── FantasyMovie.java │ │ │ ├── HottestMovie.java │ │ │ ├── LocalAuth.java │ │ │ ├── Movie.java │ │ │ ├── MusicalMovie.java │ │ │ ├── PersonInfo.java │ │ │ ├── RecommendMovie.java │ │ │ ├── RecommendMovieRealTime.java │ │ │ ├── RomanceMovie.java │ │ │ ├── ThrillerMovie.java │ │ │ ├── User.java │ │ │ ├── UserMovieRecord.java │ │ │ ├── UserPerefence.java │ │ │ ├── WarMovie.java │ │ │ └── WechatAuth.java │ │ │ ├── enums │ │ │ ├── LocalAuthStateEnum.java │ │ │ ├── MovieCategoryEnums.java │ │ │ ├── PersonInfoStateEnum.java │ │ │ └── WechatAuthStateEnum.java │ │ │ ├── service │ │ │ ├── ActionMovieService.java │ │ │ ├── ComedyMovieService.java │ │ │ ├── CrimeMovieService.java │ │ │ ├── FantasyMovieService.java │ │ │ ├── HottestMovieService.java │ │ │ ├── LocalAuthService.java │ │ │ ├── MovieService.java │ │ │ ├── MusicalMovieService.java │ │ │ ├── PersonInfoService.java │ │ │ ├── RecommendMovieRealTimeService.java │ │ │ ├── RecommendMovieService.java │ │ │ ├── RomanceMovieService.java │ │ │ ├── ThrillerMovieService.java │ │ │ ├── UserService.java │ │ │ ├── WarMovieService.java │ │ │ ├── WechatAuthService.java │ │ │ └── impl │ │ │ │ ├── ActionMovieServiceImpl.java │ │ │ │ ├── ComedyMovieServiceImpl.java │ │ │ │ ├── CrimeMovieServiceImpl.java │ │ │ │ ├── FantasyMovieServiceImpl.java │ │ │ │ ├── HottestMovieServiceImpl.java │ │ │ │ ├── LocalAuthServiceImpl.java │ │ │ │ ├── MovieServiceImpl.java │ │ │ │ ├── MusicalMovieServiceImpl.java │ │ │ │ ├── PersonInfoServiceImpl.java │ │ │ │ ├── RecommendMovieRealTimeServiceImpl.java │ │ │ │ ├── RecommendMovieServiceImpl.java │ │ │ │ ├── RomanceMovieServiceImpl.java │ │ │ │ ├── ThrillerMovieServiceImpl.java │ │ │ │ ├── UserServiceImpl.java │ │ │ │ ├── WarMovieServiceImpl.java │ │ │ │ └── WechatAuthServiceImpl.java │ │ │ ├── util │ │ │ ├── CodeUtil.java │ │ │ ├── HttpServletRequestUtil.java │ │ │ └── wechat │ │ │ │ ├── MyX509TrustManager.java │ │ │ │ ├── SignUtil.java │ │ │ │ ├── WechatUtil.java │ │ │ │ └── WeiXinUser.java │ │ │ └── web │ │ │ ├── index │ │ │ └── IndexController.java │ │ │ ├── local │ │ │ ├── LocalAuthController.java │ │ │ └── LocalController.java │ │ │ ├── movieadmin │ │ │ └── MovieAdminController.java │ │ │ ├── useradmin │ │ │ └── UserController.java │ │ │ └── wechat │ │ │ ├── WechatLoginController.java │ │ │ └── WeiXinController.java │ ├── resources │ │ ├── jdbc.properties │ │ └── log4j.properties │ └── webapp │ │ ├── WEB-INF │ │ └── html │ │ │ ├── frontend │ │ │ ├── index.html │ │ │ ├── moviedetail.html │ │ │ └── shoplist.html │ │ │ └── local │ │ │ ├── accountbind.html │ │ │ ├── changepsw.html │ │ │ ├── login.html │ │ │ └── register.html │ │ ├── index.jsp │ │ └── resources │ │ ├── css │ │ └── frontend │ │ │ ├── index.css │ │ │ ├── inserthtml.com.radios.css │ │ │ ├── inserthtml.com.radios.min.css │ │ │ ├── moviedetail.css │ │ │ ├── shoplist.css │ │ │ └── styles.css │ │ ├── images │ │ ├── img_action_movie.png │ │ ├── img_comedy_movie.png │ │ ├── img_crime_movie.png │ │ ├── img_fantasy_movie.png │ │ ├── img_logo.png │ │ ├── img_musical_movie.png │ │ ├── img_romance_movie.png │ │ ├── img_star_off.png │ │ ├── img_star_on.png │ │ ├── img_thriller_movie.jpg │ │ ├── img_thriller_movie.png │ │ ├── img_today_recommendation.png │ │ ├── img_war_movie.jpg │ │ └── img_war_movie.png │ │ └── js │ │ ├── common │ │ └── common.js │ │ ├── frontend │ │ ├── index.js │ │ ├── jquery.min.js │ │ ├── jquery.raty.min.js │ │ ├── moviedetail.js │ │ └── shoplist.js │ │ └── local │ │ ├── accountbind.js │ │ ├── changepsw.js │ │ ├── login.js │ │ ├── logout.js │ │ ├── modernizr.js │ │ └── register.js │ └── test │ └── java │ └── com │ └── xqt │ └── recommend │ ├── BaseTest.java │ ├── dao │ ├── ActionMovieDaoTest.java │ ├── HottestMovieDaoTest.java │ ├── MovieDaoTest.java │ ├── RecommenMovieRealTimeDaoTest.java │ ├── RecommendMovieDaoTest.java │ ├── TestUserMovieRecordDao.java │ └── UserDaoTest.java │ └── service │ ├── RecommendMovieRealTimeServiceTest.java │ ├── RecommendMovieServiceTest.java │ └── UserServiceTest.java ├── README.md ├── img ├── img001.png ├── img002.png ├── img003.png ├── img004.png ├── img005.png ├── img006.png └── logo01.png └── movieRecommendSpark └── src └── main └── scala ├── DataCleaning ├── countType.scala ├── splitDataSet.scala └── splitMovie.scala ├── Logger └── LoggerLevels.scala ├── ModelTest └── TestModel.scala ├── Off_lineRecommendation ├── RecommendForAllUsers(1).scala └── movieSimilar.scala ├── Real_timeRecommendation └── StreamingRecommender.scala └── utils ├── ConnectPoolUtil.scala └── connectDataBaseUtil.scala /MovieRecommend/src/main/java/com/xqt/recommend/dao/ActionMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface ActionMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/ComedyMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface ComedyMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/CrimeMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface CrimeMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/FantasyMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface FantasyMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/HottestMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.HottestMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface HottestMovieDao { 9 | /** 10 | * 选择hottest movie类别中top5电影 11 | * @return 12 | */ 13 | List selectTop5Movie(); 14 | 15 | /** 16 | * 根据movieId选择电影,进行电影详情的展示 17 | * @param movieId 18 | * @return 19 | */ 20 | HottestMovie selectMovieById(Integer hottestMovieId); 21 | 22 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/LocalAuthDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.xqt.recommend.entity.LocalAuth; 8 | 9 | 10 | public interface LocalAuthDao { 11 | 12 | /** 13 | * 通过用户名和密码查询用户 14 | * @param userName 15 | * @param password 16 | * @return 17 | */ 18 | LocalAuth queryLocalByUserNameAndPwd(@Param("userName") String userName, 19 | @Param("password") String password); 20 | 21 | 22 | LocalAuth queryLocalByUserName(@Param("userName") String userName); 23 | /** 24 | * 通过userId来查询用户 25 | * @param userId 26 | * @return 27 | */ 28 | LocalAuth queryLocalByUserId(@Param("userId") long userId); 29 | 30 | /** 31 | * 32 | * @param localAuth 33 | * @return 34 | */ 35 | int insertLocalAuth(LocalAuth localAuth); 36 | 37 | /** 38 | * 39 | * @param localAuth 40 | * @return 41 | */ 42 | int updateLocalAuth(@Param("userId") Long userId, 43 | @Param("userName") String userName, 44 | @Param("password") String password, 45 | @Param("newPassword") String newPassword, 46 | @Param("lastEditTime") Date lastEditTime); 47 | } 48 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/MovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.Movie; 6 | 7 | public interface MovieDao { 8 | /** 9 | * 选择综合类别中top10电影 10 | * @return 11 | */ 12 | List selectTop10Movie(); 13 | 14 | /** 15 | * 根据movieId选择电影,进行电影详情的展示 16 | * @param movieId 17 | * @return 18 | */ 19 | Movie selectMovieById(Integer movieId); 20 | 21 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/MusicalMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface MusicalMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/PersonInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | import com.xqt.recommend.entity.PersonInfo; 7 | 8 | public interface PersonInfoDao { 9 | 10 | /** 11 | * 12 | * @param personInfoCondition 13 | * @param rowIndex 14 | * @param pageSize 15 | * @return 16 | */ 17 | List queryPersonInfoList( 18 | @Param("personInfoCondition") PersonInfo personInfoCondition, 19 | @Param("rowIndex") int rowIndex, @Param("pageSize") int pageSize); 20 | 21 | /** 22 | * 23 | * @param personInfoCondition 24 | * @return 25 | */ 26 | int queryPersonInfoCount( 27 | @Param("personInfoCondition") PersonInfo personInfoCondition); 28 | 29 | /** 30 | * 31 | * @param userId 32 | * @return 33 | */ 34 | PersonInfo queryPersonInfoById(long userId); 35 | 36 | /** 37 | * 38 | * @param wechatAuth 39 | * @return 40 | */ 41 | int insertPersonInfo(PersonInfo personInfo); 42 | 43 | /** 44 | * 45 | * @param wechatAuth 46 | * @return 47 | */ 48 | int updatePersonInfo(PersonInfo personInfo); 49 | 50 | /** 51 | * 52 | * @param wechatAuth 53 | * @return 54 | */ 55 | int deletePersonInfo(long userId); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/RecommendMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | public interface RecommendMovieDao { 6 | 7 | //根据userId,从数据库中选择数据movieId 8 | List getMovieIdListByUserId(Integer userId); 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/RecommendMovieRealTimeDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.RecommendMovieRealTime; 6 | 7 | 8 | public interface RecommendMovieRealTimeDao { 9 | 10 | //根据table_inner_id选择出相应的电影条目 11 | List selectMovieByUserId(Integer UserId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/RomanceMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface RomanceMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/ThrillerMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface ThrillerMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | 4 | 5 | import java.util.List; 6 | 7 | import com.xqt.recommend.entity.User; 8 | 9 | public interface UserDao { 10 | 11 | /** 12 | * 查询所有用户 13 | * @return 14 | */ 15 | public List queryUser(); 16 | } 17 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/UserMovieRecordDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import com.xqt.recommend.entity.UserMovieRecord; 4 | 5 | import java.util.List; 6 | 7 | public interface UserMovieRecordDao { 8 | //获取表中一共有多少条数据 9 | int count(); 10 | 11 | //根据userID movieId删除一条记录 12 | int deleteByUserIdAndMovieId(Integer userId, Integer movieId); 13 | 14 | //向表中插入一条记录 15 | int insert(UserMovieRecord record); 16 | 17 | //根据userId获取数据 18 | List selectByUserId(Integer userId); 19 | 20 | //根据movieId获取数据 21 | List selectByMovieId(Integer MovieId); 22 | 23 | //根据userId movieId获取某一条数据 24 | UserMovieRecord selectByUserIdAndMovieId(Integer userId, Integer movieId); 25 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/UserPerefenceDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import com.xqt.recommend.entity.UserPerefence; 4 | 5 | public interface UserPerefenceDao { 6 | int insertUserPerefence(UserPerefence userPerefence); 7 | } 8 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/WarMovieDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | 7 | public interface WarMovieDao { 8 | 9 | //获取对应的表中条目数目 10 | int count(); 11 | 12 | //根据table_inner_id选择出相应的电影条目 13 | List selectBytableInnerId(Integer startTableInnerId); 14 | 15 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dao/WechatAuthDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import com.xqt.recommend.entity.WechatAuth; 4 | 5 | public interface WechatAuthDao { 6 | /** 7 | * 8 | * @param openId 9 | * @return 10 | */ 11 | WechatAuth queryWechatInfoByOpenId(String openId); 12 | 13 | /** 14 | * 15 | * @param wechatAuth 16 | * @return 17 | */ 18 | int insertWechatAuth(WechatAuth wechatAuth); 19 | 20 | /** 21 | * 22 | * @param wechatAuthId 23 | * @return 24 | */ 25 | int deleteWechatAuth(Long wechatAuthId); 26 | } 27 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dto/LocalAuthExecution.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.LocalAuth; 6 | import com.xqt.recommend.enums.LocalAuthStateEnum; 7 | 8 | 9 | public class LocalAuthExecution { 10 | // 缁撴灉鐘舵�� 11 | private int state; 12 | 13 | // 鐘舵�佹爣璇� 14 | private String stateInfo; 15 | 16 | private int count; 17 | 18 | private LocalAuth localAuth; 19 | 20 | private List localAuthList; 21 | 22 | public LocalAuthExecution() { 23 | } 24 | 25 | // 澶辫触鐨勬瀯閫犲櫒 26 | public LocalAuthExecution(LocalAuthStateEnum stateEnum) { 27 | this.state = stateEnum.getState(); 28 | this.stateInfo = stateEnum.getStateInfo(); 29 | } 30 | 31 | // 鎴愬姛鐨勬瀯閫犲櫒 32 | public LocalAuthExecution(LocalAuthStateEnum stateEnum, LocalAuth localAuth) { 33 | this.state = stateEnum.getState(); 34 | this.stateInfo = stateEnum.getStateInfo(); 35 | this.localAuth = localAuth; 36 | } 37 | 38 | // 鎴愬姛鐨勬瀯閫犲櫒 39 | public LocalAuthExecution(LocalAuthStateEnum stateEnum, 40 | List localAuthList) { 41 | this.state = stateEnum.getState(); 42 | this.stateInfo = stateEnum.getStateInfo(); 43 | this.localAuthList = localAuthList; 44 | } 45 | 46 | public int getState() { 47 | return state; 48 | } 49 | 50 | public void setState(int state) { 51 | this.state = state; 52 | } 53 | 54 | public String getStateInfo() { 55 | return stateInfo; 56 | } 57 | 58 | public void setStateInfo(String stateInfo) { 59 | this.stateInfo = stateInfo; 60 | } 61 | 62 | public int getCount() { 63 | return count; 64 | } 65 | 66 | public void setCount(int count) { 67 | this.count = count; 68 | } 69 | 70 | public LocalAuth getLocalAuth() { 71 | return localAuth; 72 | } 73 | 74 | public void setLocalAuth(LocalAuth localAuth) { 75 | this.localAuth = localAuth; 76 | } 77 | 78 | public List getLocalAuthList() { 79 | return localAuthList; 80 | } 81 | 82 | public void setLocalAuthList(List localAuthList) { 83 | this.localAuthList = localAuthList; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dto/PersonInfoExecution.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.PersonInfo; 6 | import com.xqt.recommend.enums.PersonInfoStateEnum; 7 | 8 | /** 9 | * 封装执行后结果 10 | */ 11 | public class PersonInfoExecution { 12 | 13 | // 结果状态 14 | private int state; 15 | 16 | // 状态标识 17 | private String stateInfo; 18 | 19 | // 店铺数量 20 | private int count; 21 | 22 | // 操作的personInfo(增删改店铺的时候用) 23 | private PersonInfo personInfo; 24 | 25 | // 获取的personInfo列表(查询店铺列表的时候用) 26 | private List personInfoList; 27 | 28 | public PersonInfoExecution() { 29 | } 30 | 31 | // 失败的构造器 32 | public PersonInfoExecution(PersonInfoStateEnum stateEnum) { 33 | this.state = stateEnum.getState(); 34 | this.stateInfo = stateEnum.getStateInfo(); 35 | } 36 | 37 | // 成功的构造器 38 | public PersonInfoExecution(PersonInfoStateEnum stateEnum, 39 | PersonInfo personInfo) { 40 | this.state = stateEnum.getState(); 41 | this.stateInfo = stateEnum.getStateInfo(); 42 | this.personInfo = personInfo; 43 | } 44 | 45 | // 成功的构造器 46 | public PersonInfoExecution(PersonInfoStateEnum stateEnum, 47 | List personInfoList) { 48 | this.state = stateEnum.getState(); 49 | this.stateInfo = stateEnum.getStateInfo(); 50 | this.personInfoList = personInfoList; 51 | } 52 | 53 | public int getState() { 54 | return state; 55 | } 56 | 57 | public void setState(int state) { 58 | this.state = state; 59 | } 60 | 61 | public String getStateInfo() { 62 | return stateInfo; 63 | } 64 | 65 | public void setStateInfo(String stateInfo) { 66 | this.stateInfo = stateInfo; 67 | } 68 | 69 | public int getCount() { 70 | return count; 71 | } 72 | 73 | public void setCount(int count) { 74 | this.count = count; 75 | } 76 | 77 | public PersonInfo getPersonInfo() { 78 | return personInfo; 79 | } 80 | 81 | public void setPersonInfo(PersonInfo personInfo) { 82 | this.personInfo = personInfo; 83 | } 84 | 85 | public List getPersonInfoList() { 86 | return personInfoList; 87 | } 88 | 89 | public void setPersonInfoList(List personInfoList) { 90 | this.personInfoList = personInfoList; 91 | } 92 | 93 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dto/UserAccessToken.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public class UserAccessToken { 6 | //收到的凭证 7 | @JsonProperty("access_token") 8 | private String accessToken; 9 | //凭证有效时间,单位:秒 10 | @JsonProperty("expires_in") 11 | private String expires_in; 12 | //表示更新令牌,用来获取下一次的访问令牌,这里没多大用处 13 | @JsonProperty("refresh_token") 14 | private String refresh_token; 15 | //该用户在此公共号下的身份标识,对于此微信号具有唯一性 16 | @JsonProperty("openid") 17 | private String openid; 18 | //表示权限范围,这里可以省略 19 | @JsonProperty("scope") 20 | private String scope; 21 | 22 | public String getAccessToken() { 23 | return accessToken; 24 | } 25 | 26 | public void setAccessToken(String accessToken) { 27 | this.accessToken = accessToken; 28 | } 29 | 30 | public String getExpires_in() { 31 | return expires_in; 32 | } 33 | 34 | public void setExpires_in(String expires_in) { 35 | this.expires_in = expires_in; 36 | } 37 | 38 | public String getRefresh_token() { 39 | return refresh_token; 40 | } 41 | 42 | public void setRefresh_token(String refresh_token) { 43 | this.refresh_token = refresh_token; 44 | } 45 | 46 | public String getOpenid() { 47 | return openid; 48 | } 49 | 50 | public void setOpenid(String openid) { 51 | this.openid = openid; 52 | } 53 | 54 | public String getScope() { 55 | return scope; 56 | } 57 | 58 | public void setScope(String scope) { 59 | this.scope = scope; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dto/WechatAuthExecution.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dto; 2 | 3 | import java.util.List; 4 | 5 | 6 | import com.xqt.recommend.entity.WechatAuth; 7 | import com.xqt.recommend.enums.WechatAuthStateEnum; 8 | 9 | 10 | 11 | public class WechatAuthExecution { 12 | // 结果状态 13 | private int state; 14 | 15 | // 状态标识 16 | private String stateInfo; 17 | 18 | private int count; 19 | 20 | private WechatAuth wechatAuth; 21 | 22 | private List wechatAuthList; 23 | 24 | public WechatAuthExecution() { 25 | } 26 | 27 | // 失败的构造器 28 | public WechatAuthExecution(WechatAuthStateEnum stateEnum) { 29 | this.state = stateEnum.getState(); 30 | this.stateInfo = stateEnum.getStateInfo(); 31 | } 32 | 33 | // 成功的构造器 34 | public WechatAuthExecution(WechatAuthStateEnum stateEnum, WechatAuth wechatAuth) { 35 | this.state = stateEnum.getState(); 36 | this.stateInfo = stateEnum.getStateInfo(); 37 | this.wechatAuth = wechatAuth; 38 | } 39 | 40 | // 成功的构造器 41 | public WechatAuthExecution(WechatAuthStateEnum stateEnum, 42 | List wechatAuthList) { 43 | this.state = stateEnum.getState(); 44 | this.stateInfo = stateEnum.getStateInfo(); 45 | this.wechatAuthList = wechatAuthList; 46 | } 47 | 48 | public int getState() { 49 | return state; 50 | } 51 | 52 | public void setState(int state) { 53 | this.state = state; 54 | } 55 | 56 | public String getStateInfo() { 57 | return stateInfo; 58 | } 59 | 60 | public void setStateInfo(String stateInfo) { 61 | this.stateInfo = stateInfo; 62 | } 63 | 64 | public int getCount() { 65 | return count; 66 | } 67 | 68 | public void setCount(int count) { 69 | this.count = count; 70 | } 71 | 72 | public WechatAuth getWechatAuth() { 73 | return wechatAuth; 74 | } 75 | 76 | public void setWechatAuth(WechatAuth wechatAuth) { 77 | this.wechatAuth = wechatAuth; 78 | } 79 | 80 | public List getWechatAuthList() { 81 | return wechatAuthList; 82 | } 83 | 84 | public void setWechatAuthList(List wechatAuthList) { 85 | this.wechatAuthList = wechatAuthList; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/dto/WechatUser.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | public class WechatUser implements Serializable{ 8 | 9 | 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | 16 | private static final long serialVersionID=-468L; 17 | 18 | @JsonProperty("openid") 19 | private String openId; 20 | 21 | @JsonProperty("nickname") 22 | private String nickName; 23 | 24 | @JsonProperty("sex") 25 | private String sex; 26 | 27 | @JsonProperty("province") 28 | private String province; 29 | 30 | @JsonProperty("city") 31 | private String city; 32 | 33 | @JsonProperty("country") 34 | private String country; 35 | 36 | @JsonProperty("headimgurl") 37 | private String headimgurl; 38 | 39 | @JsonProperty("language") 40 | private String language; 41 | 42 | @JsonProperty("privilege") 43 | private String[] privilege; 44 | 45 | public String[] getPrivilege() { 46 | return privilege; 47 | } 48 | 49 | public void setPrivilege(String[] privilege) { 50 | this.privilege = privilege; 51 | } 52 | 53 | public String getOpenId() { 54 | return openId; 55 | } 56 | 57 | public void setOpenId(String openId) { 58 | this.openId = openId; 59 | } 60 | 61 | public String getNickName() { 62 | return nickName; 63 | } 64 | 65 | public void setNickName(String nickName) { 66 | this.nickName = nickName; 67 | } 68 | 69 | public String getSex() { 70 | return sex; 71 | } 72 | 73 | public void setSex(String sex) { 74 | this.sex = sex; 75 | } 76 | 77 | public String getProvince() { 78 | return province; 79 | } 80 | 81 | public void setProvince(String province) { 82 | this.province = province; 83 | } 84 | 85 | public String getCity() { 86 | return city; 87 | } 88 | 89 | public void setCity(String city) { 90 | this.city = city; 91 | } 92 | 93 | public String getCountry() { 94 | return country; 95 | } 96 | 97 | public void setCountry(String country) { 98 | this.country = country; 99 | } 100 | 101 | public String getHeadimgurl() { 102 | return headimgurl; 103 | } 104 | 105 | public void setHeadimgurl(String headimgurl) { 106 | this.headimgurl = headimgurl; 107 | } 108 | 109 | public String getLanguage() { 110 | return language; 111 | } 112 | 113 | public void setLanguage(String language) { 114 | this.language = language; 115 | } 116 | 117 | 118 | 119 | public static long getSerialversionid() { 120 | return serialVersionID; 121 | } 122 | 123 | 124 | } 125 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/ActionMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class ActionMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/ComedyMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class ComedyMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/CrimeMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class CrimeMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/FantasyMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class FantasyMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/HottestMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class HottestMovie { 6 | 7 | //电影ID 8 | private Integer movieId; 9 | //电影名称 10 | private String movieName; 11 | //电影简介 12 | private String movieInfo; 13 | //电影海报地址 14 | private String movieImgAddr; 15 | //电影播放链接 16 | private String moviePlayUrl; 17 | //电影上映时间 18 | private String releaseTime; 19 | //更新时间 20 | private Date lastEditTime; 21 | public Integer getMovieId() { 22 | return movieId; 23 | } 24 | public void setMovieId(Integer movieId) { 25 | this.movieId = movieId; 26 | } 27 | public String getMovieName() { 28 | return movieName; 29 | } 30 | public void setMovieName(String movieName) { 31 | this.movieName = movieName; 32 | } 33 | public String getMovieInfo() { 34 | return movieInfo; 35 | } 36 | public void setMovieInfo(String movieInfo) { 37 | this.movieInfo = movieInfo; 38 | } 39 | public String getMovieImgAddr() { 40 | return movieImgAddr; 41 | } 42 | public void setMovieImgAddr(String movieImgAddr) { 43 | this.movieImgAddr = movieImgAddr; 44 | } 45 | public String getMoviePlayUrl() { 46 | return moviePlayUrl; 47 | } 48 | public void setMoviePlayUrl(String moviePlayUrl) { 49 | this.moviePlayUrl = moviePlayUrl; 50 | } 51 | public String getReleaseTime() { 52 | return releaseTime; 53 | } 54 | public void setReleaseTime(String releaseTime) { 55 | this.releaseTime = releaseTime; 56 | } 57 | public Date getLastEditTime() { 58 | return lastEditTime; 59 | } 60 | public void setLastEditTime(Date lastEditTime) { 61 | this.lastEditTime = lastEditTime; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/LocalAuth.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * 本地验证实体类,主要用来做帐号密码的登录 7 | * 8 | * 9 | */ 10 | public class LocalAuth { 11 | // 主键ID 12 | private Long localAuthId; 13 | // 帐号 14 | private String userName; 15 | // 密码 16 | private String password; 17 | // 创建时间 18 | private Date createTime; 19 | // 最近一次的更新时间 20 | private Date lastEditTime; 21 | // 个人信息,关系为一一对应 22 | private PersonInfo personInfo; 23 | 24 | 25 | public Long getLocalAuthId() { 26 | return localAuthId; 27 | } 28 | 29 | public void setLocalAuthId(Long localAuthId) { 30 | this.localAuthId = localAuthId; 31 | } 32 | 33 | public String getUsername() { 34 | return userName; 35 | } 36 | 37 | public void setUsername(String username) { 38 | this.userName = username; 39 | } 40 | 41 | public String getPassword() { 42 | return password; 43 | } 44 | 45 | public void setPassword(String password) { 46 | this.password = password; 47 | } 48 | 49 | public Date getCreateTime() { 50 | return createTime; 51 | } 52 | 53 | public void setCreateTime(Date createTime) { 54 | this.createTime = createTime; 55 | } 56 | 57 | public Date getLastEditTime() { 58 | return lastEditTime; 59 | } 60 | 61 | public void setLastEditTime(Date lastEditTime) { 62 | this.lastEditTime = lastEditTime; 63 | } 64 | 65 | public PersonInfo getPersonInfo() { 66 | return personInfo; 67 | } 68 | 69 | public void setPersonInfo(PersonInfo personInfo) { 70 | this.personInfo = personInfo; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/Movie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Movie { 6 | 7 | //电影ID 8 | private Integer movieId; 9 | //电影名称 10 | private String movieName; 11 | //电影简介 12 | private String movieInfo; 13 | //电影海报地址 14 | private String movieImgAddr; 15 | //电影播放链接 16 | private String moviePlayUrl; 17 | //电影上映时间 18 | private String releaseTime; 19 | //更新时间 20 | private Date lastEditTime; 21 | public Integer getMovieId() { 22 | return movieId; 23 | } 24 | public void setMovieId(Integer movieId) { 25 | this.movieId = movieId; 26 | } 27 | public String getMovieName() { 28 | return movieName; 29 | } 30 | public void setMovieName(String movieName) { 31 | this.movieName = movieName; 32 | } 33 | public String getMovieInfo() { 34 | return movieInfo; 35 | } 36 | public void setMovieInfo(String movieInfo) { 37 | this.movieInfo = movieInfo; 38 | } 39 | public String getMovieImgAddr() { 40 | return movieImgAddr; 41 | } 42 | public void setMovieImgAddr(String movieImgAddr) { 43 | this.movieImgAddr = movieImgAddr; 44 | } 45 | public String getMoviePlayUrl() { 46 | return moviePlayUrl; 47 | } 48 | public void setMoviePlayUrl(String moviePlayUrl) { 49 | this.moviePlayUrl = moviePlayUrl; 50 | } 51 | public String getReleaseTime() { 52 | return releaseTime; 53 | } 54 | public void setReleaseTime(String releaseTime) { 55 | this.releaseTime = releaseTime; 56 | } 57 | public Date getLastEditTime() { 58 | return lastEditTime; 59 | } 60 | public void setLastEditTime(Date lastEditTime) { 61 | this.lastEditTime = lastEditTime; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/MusicalMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class MusicalMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/PersonInfo.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | 4 | import java.util.Date; 5 | 6 | /** 7 | * 个人信息实体类 8 | * 9 | */ 10 | public class PersonInfo { 11 | // 主键ID 12 | private Long userId; 13 | // 用户名称 14 | private String name; 15 | // 用户头像 16 | private String profileImg; 17 | // 用户邮箱 18 | private String email; 19 | // 用户性别 20 | private String gender; 21 | // 可用状态:0、被禁止 1、可用 22 | private Integer enableStatus; 23 | // 1.顾客 2.店家 3.超级管理员 24 | private Integer userType; 25 | // 创建时间 26 | private Date createTime; 27 | // 最近一次的更新时间 28 | private Date lastEditTime; 29 | 30 | public Long getUserId() { 31 | return userId; 32 | } 33 | 34 | public void setUserId(Long userId) { 35 | this.userId = userId; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public String getProfileImg() { 47 | return profileImg; 48 | } 49 | 50 | public void setProfileImg(String profileImg) { 51 | this.profileImg = profileImg; 52 | } 53 | 54 | public String getEmail() { 55 | return email; 56 | } 57 | 58 | public void setEmail(String email) { 59 | this.email = email; 60 | } 61 | 62 | public String getGender() { 63 | return gender; 64 | } 65 | 66 | public void setGender(String gender) { 67 | this.gender = gender; 68 | } 69 | 70 | public Integer getEnableStatus() { 71 | return enableStatus; 72 | } 73 | 74 | public void setEnableStatus(Integer enableStatus) { 75 | this.enableStatus = enableStatus; 76 | } 77 | 78 | public Integer getUserType() { 79 | return userType; 80 | } 81 | 82 | public void setUserType(Integer userType) { 83 | this.userType = userType; 84 | } 85 | 86 | public Date getCreateTime() { 87 | return createTime; 88 | } 89 | 90 | public void setCreateTime(Date createTime) { 91 | this.createTime = createTime; 92 | } 93 | 94 | public Date getLastEditTime() { 95 | return lastEditTime; 96 | } 97 | 98 | public void setLastEditTime(Date lastEditTime) { 99 | this.lastEditTime = lastEditTime; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/RecommendMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | /** 4 | * 获取给不同id用户推荐的电影的实体类 5 | * 6 | *对应数据库中tb_recommend_movie 7 | * @author Administrator 8 | * 9 | */ 10 | public class RecommendMovie { 11 | 12 | private Integer userId; 13 | 14 | private Integer movieId; 15 | 16 | private Double rate; 17 | 18 | public RecommendMovie() { 19 | } 20 | 21 | public RecommendMovie(Integer userId, Integer movieId, Double rate) { 22 | this.userId = userId; 23 | this.movieId = movieId; 24 | this.rate = rate; 25 | } 26 | 27 | public Integer getUserId() { 28 | return userId; 29 | } 30 | 31 | public void setUserId(Integer userId) { 32 | this.userId = userId; 33 | } 34 | 35 | public Integer getMovieId() { 36 | return movieId; 37 | } 38 | 39 | public void setMovieId(Integer movieId) { 40 | this.movieId = movieId; 41 | } 42 | 43 | public Double getRate() { 44 | return rate; 45 | } 46 | 47 | public void setRate(Double rate) { 48 | this.rate = rate; 49 | } 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/RecommendMovieRealTime.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.Date; 5 | 6 | public class RecommendMovieRealTime { 7 | 8 | private Integer userId; 9 | 10 | private Integer movieId; 11 | 12 | private Double score; 13 | 14 | private Timestamp timestamp; 15 | 16 | public Timestamp getTimestamp() { 17 | return timestamp; 18 | } 19 | 20 | public void setTimestamp(Timestamp timestamp) { 21 | this.timestamp = timestamp; 22 | } 23 | 24 | public Integer getUserId() { 25 | return userId; 26 | } 27 | 28 | public void setUserId(Integer userId) { 29 | this.userId = userId; 30 | } 31 | 32 | public Integer getMovieId() { 33 | return movieId; 34 | } 35 | 36 | public void setMovieId(Integer movieId) { 37 | this.movieId = movieId; 38 | } 39 | 40 | public Double getScore() { 41 | return score; 42 | } 43 | 44 | public void setScore(Double score) { 45 | this.score = score; 46 | } 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/RomanceMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class RomanceMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/ThrillerMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class ThrillerMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | public class User { 4 | 5 | //用户ID 6 | private Integer userId; 7 | //用户姓名 8 | private String userName; 9 | //用户性别 10 | private Integer userSex; 11 | //年龄 12 | private Integer userAge; 13 | public Integer getUserId() { 14 | return userId; 15 | } 16 | public void setUserId(Integer userId) { 17 | this.userId = userId; 18 | } 19 | public String getUserName() { 20 | return userName; 21 | } 22 | public void setUserName(String userName) { 23 | this.userName = userName; 24 | } 25 | public Integer getUserSex() { 26 | return userSex; 27 | } 28 | public void setUserSex(Integer userSex) { 29 | this.userSex = userSex; 30 | } 31 | public Integer getUserAge() { 32 | return userAge; 33 | } 34 | public void setUserAge(Integer userAge) { 35 | this.userAge = userAge; 36 | } 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/UserMovieRecord.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class UserMovieRecord { 6 | 7 | private Integer userId; 8 | 9 | private Integer movieId; 10 | 11 | private Integer userMovieRate; 12 | 13 | private Date recordTimestamp; 14 | 15 | public UserMovieRecord(Integer userId, Integer movieId, Integer rate, Date date) { 16 | this.userId = userId; 17 | this.movieId = movieId; 18 | this.userMovieRate = rate; 19 | this.recordTimestamp = date; 20 | } 21 | 22 | 23 | public UserMovieRecord() { 24 | 25 | } 26 | 27 | 28 | 29 | public Integer getUserId() { 30 | return userId; 31 | } 32 | 33 | public void setUserId(Integer userId) { 34 | this.userId = userId; 35 | } 36 | 37 | public Integer getMovieId() { 38 | return movieId; 39 | } 40 | 41 | public void setMovieId(Integer movieId) { 42 | this.movieId = movieId; 43 | } 44 | 45 | public Integer getUserMovieRate() { 46 | return userMovieRate; 47 | } 48 | 49 | public void setUserMovieRate(Integer userMovieRate) { 50 | this.userMovieRate = userMovieRate; 51 | } 52 | 53 | public Date getRecordTimestamp() { 54 | return recordTimestamp; 55 | } 56 | 57 | public void setRecordTimestamp(Date recordTimestamp) { 58 | this.recordTimestamp = recordTimestamp; 59 | } 60 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/UserPerefence.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | public class UserPerefence { 4 | private Long perefenceId; 5 | //用户ID 6 | private Long userId; 7 | //喜好类型 8 | private Integer movieType; 9 | 10 | 11 | public Long getUserId() { 12 | return userId; 13 | } 14 | public void setUserId(Long userId) { 15 | this.userId = userId; 16 | } 17 | public Integer getMovieType() { 18 | return movieType; 19 | } 20 | public void setMovieType(Integer movieType) { 21 | this.movieType = movieType; 22 | } 23 | public Long getPerefenceId() { 24 | return perefenceId; 25 | } 26 | public void setPerefenceId(Long perefenceId) { 27 | this.perefenceId = perefenceId; 28 | } 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/WarMovie.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class WarMovie { 6 | private Integer tableInnerId; 7 | 8 | private Integer movieId; 9 | 10 | private String movieName; 11 | 12 | private Integer releaseTime; 13 | 14 | private String movieImgAddr; 15 | 16 | private String moviePlayUrl; 17 | 18 | private String movieInfo; 19 | 20 | private Date lastEditTime; 21 | 22 | public Integer getTableInnerId() { 23 | return tableInnerId; 24 | } 25 | 26 | public void setTableInnerId(Integer tableInnerId) { 27 | this.tableInnerId = tableInnerId; 28 | } 29 | 30 | public Integer getMovieId() { 31 | return movieId; 32 | } 33 | 34 | public void setMovieId(Integer movieId) { 35 | this.movieId = movieId; 36 | } 37 | 38 | public String getMovieName() { 39 | return movieName; 40 | } 41 | 42 | public void setMovieName(String movieName) { 43 | this.movieName = movieName == null ? null : movieName.trim(); 44 | } 45 | 46 | public String getMovieImgAddr() { 47 | return movieImgAddr; 48 | } 49 | 50 | public void setMovieImgAddr(String movieImgAddr) { 51 | this.movieImgAddr = movieImgAddr == null ? null : movieImgAddr.trim(); 52 | } 53 | 54 | public String getMovieInfo() { 55 | return movieInfo; 56 | } 57 | 58 | public void setMovieInfo(String movieInfo) { 59 | this.movieInfo = movieInfo == null ? null : movieInfo.trim(); 60 | } 61 | 62 | public String getMoviePlayUrl() { 63 | return moviePlayUrl; 64 | } 65 | 66 | public void setMoviePlayUrl(String moviePlayUrl) { 67 | this.moviePlayUrl = moviePlayUrl == null ? null : moviePlayUrl.trim(); 68 | } 69 | 70 | public Integer getReleaseTime() { 71 | return releaseTime; 72 | } 73 | 74 | public void setReleaseTime(Integer releaseTime) { 75 | this.releaseTime = releaseTime; 76 | } 77 | 78 | public Date getLastEditTime() { 79 | return lastEditTime; 80 | } 81 | 82 | public void setLastEditTime(Date lastEditTime) { 83 | this.lastEditTime = lastEditTime; 84 | } 85 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/entity/WechatAuth.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * 微信登录实体类 7 | * 8 | * 9 | */ 10 | public class WechatAuth { 11 | // 主键ID 12 | private Long wechatAuthId; 13 | // 微信获取用户信息的凭证,对于某个公众号具有唯一性 14 | private String openId; 15 | // 创建时间 16 | private Date createTime; 17 | // 用户信息 18 | private PersonInfo personInfo; 19 | 20 | public Long getWechatAuthId() { 21 | return wechatAuthId; 22 | } 23 | 24 | public void setWechatAuthId(Long wechatAuthId) { 25 | this.wechatAuthId = wechatAuthId; 26 | } 27 | 28 | public String getOpenId() { 29 | return openId; 30 | } 31 | 32 | public void setOpenId(String openId) { 33 | this.openId = openId; 34 | } 35 | 36 | public Date getCreateTime() { 37 | return createTime; 38 | } 39 | 40 | public void setCreateTime(Date createTime) { 41 | this.createTime = createTime; 42 | } 43 | 44 | public PersonInfo getPersonInfo() { 45 | return personInfo; 46 | } 47 | 48 | public void setPersonInfo(PersonInfo personInfo) { 49 | this.personInfo = personInfo; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/enums/LocalAuthStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.enums; 2 | 3 | public enum LocalAuthStateEnum { 4 | LOGINFAIL(-1, "密码或帐号输入有误"), SUCCESS(0, "操作成功"), NULL_AUTH_INFO(-1006, 5 | "注册信息为空"), ONLY_ONE_ACCOUNT(-1007,"最多只能绑定一个本地帐号"); 6 | 7 | private int state; 8 | 9 | private String stateInfo; 10 | 11 | private LocalAuthStateEnum(int state, String stateInfo) { 12 | this.state = state; 13 | this.stateInfo = stateInfo; 14 | } 15 | 16 | public int getState() { 17 | return state; 18 | } 19 | 20 | public String getStateInfo() { 21 | return stateInfo; 22 | } 23 | 24 | public static LocalAuthStateEnum stateOf(int index) { 25 | for (LocalAuthStateEnum state : values()) { 26 | if (state.getState() == index) { 27 | return state; 28 | } 29 | } 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/enums/MovieCategoryEnums.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.enums; 2 | 3 | public enum MovieCategoryEnums { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/enums/PersonInfoStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.enums; 2 | 3 | /** 4 | * 使用枚举表述常量数据字典 5 | */ 6 | public enum PersonInfoStateEnum { 7 | 8 | SUCCESS(0, "创建成功"), INNER_ERROR(-1001, "操作失败"), EMPTY(-1002, "用户信息为空"); 9 | 10 | private int state; 11 | 12 | private String stateInfo; 13 | 14 | private PersonInfoStateEnum(int state, String stateInfo) { 15 | this.state = state; 16 | this.stateInfo = stateInfo; 17 | } 18 | 19 | public int getState() { 20 | return state; 21 | } 22 | 23 | public String getStateInfo() { 24 | return stateInfo; 25 | } 26 | 27 | public static PersonInfoStateEnum stateOf(int index) { 28 | for (PersonInfoStateEnum state : values()) { 29 | if (state.getState() == index) { 30 | return state; 31 | } 32 | } 33 | return null; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/enums/WechatAuthStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.enums; 2 | 3 | public enum WechatAuthStateEnum { 4 | LOGINFAIL(-1, "openId输入有误"), SUCCESS(0, "操作成功"), NULL_AUTH_INFO(-1006, 5 | "注册信息为空"); 6 | 7 | private int state; 8 | 9 | private String stateInfo; 10 | 11 | private WechatAuthStateEnum(int state, String stateInfo) { 12 | this.state = state; 13 | this.stateInfo = stateInfo; 14 | } 15 | 16 | public int getState() { 17 | return state; 18 | } 19 | 20 | public String getStateInfo() { 21 | return stateInfo; 22 | } 23 | 24 | public static WechatAuthStateEnum stateOf(int index) { 25 | for (WechatAuthStateEnum state : values()) { 26 | if (state.getState() == index) { 27 | return state; 28 | } 29 | } 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/ActionMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface ActionMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/ComedyMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface ComedyMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/CrimeMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface CrimeMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/FantasyMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface FantasyMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/HottestMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.HottestMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface HottestMovieService { 9 | 10 | /** 11 | * 获取top5 12 | * @return 13 | */ 14 | List getTop5Movie(); 15 | 16 | /** 17 | * 根据movieId选择电影 18 | * @param movieId 19 | * @return 20 | */ 21 | HottestMovie selectMovieById(Integer hottestMovieId); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/LocalAuthService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import org.springframework.web.multipart.commons.CommonsMultipartFile; 4 | 5 | import com.xqt.recommend.dto.LocalAuthExecution; 6 | import com.xqt.recommend.entity.LocalAuth; 7 | 8 | 9 | 10 | public interface LocalAuthService { 11 | /** 12 | * 13 | * @param userName 14 | * @return 15 | */ 16 | LocalAuth getLocalAuthByUserNameAndPwd(String userName, String password); 17 | 18 | /** 19 | * 20 | * @param userId 21 | * @return 22 | */ 23 | LocalAuth getLocalAuthByUserId(long userId); 24 | 25 | 26 | LocalAuth getLocalAuthByUserName(String userName); 27 | /** 28 | * 29 | * @param localAuth 30 | * @param profileImg 31 | * @return 32 | * @throws RuntimeException 33 | */ 34 | LocalAuthExecution register(LocalAuth localAuth, 35 | CommonsMultipartFile profileImg,Integer[] perefence) throws RuntimeException; 36 | 37 | /** 38 | * 39 | * @param localAuth 40 | * @return 41 | * @throws RuntimeException 42 | */ 43 | LocalAuthExecution bindLocalAuth(LocalAuth localAuth) 44 | throws RuntimeException; 45 | 46 | /** 47 | * 48 | * @param localAuthId 49 | * @param userName 50 | * @param password 51 | * @param newPassword 52 | * @param lastEditTime 53 | * @return 54 | */ 55 | LocalAuthExecution modifyLocalAuth(Long userId, String userName, 56 | String password, String newPassword); 57 | } 58 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/MovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | 7 | import com.xqt.recommend.dao.MovieDao; 8 | import com.xqt.recommend.entity.Movie; 9 | 10 | public interface MovieService { 11 | 12 | /** 13 | * 获取top10 14 | * @return 15 | */ 16 | List getTop10Movie(); 17 | 18 | /** 19 | * 根据movieId选择电影 20 | * @param movieId 21 | * @return 22 | */ 23 | Movie selectMovieById(Integer movieId); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/MusicalMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface MusicalMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/PersonInfoService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import com.xqt.recommend.entity.PersonInfo; 4 | 5 | public interface PersonInfoService { 6 | 7 | /** 8 | * 9 | * @param userId 10 | * @return 11 | */ 12 | PersonInfo getPersonInfoById(Long userId); 13 | 14 | /** 15 | * 16 | * @param personInfoCondition 17 | * @param pageIndex 18 | * @param pageSize 19 | * @return 20 | */ 21 | /* PersonInfoExecution getPersonInfoList(PersonInfo personInfoCondition, 22 | int pageIndex, int pageSize);*/ 23 | 24 | /** 25 | * 26 | * @param personInfo 27 | * @return 28 | */ 29 | /*PersonInfoExecution addPersonInfo(PersonInfo personInfo);*/ 30 | 31 | /** 32 | * 33 | * @param personInfo 34 | * @return 35 | */ 36 | /*PersonInfoExecution modifyPersonInfo(PersonInfo personInfo); 37 | */ 38 | } 39 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/RecommendMovieRealTimeService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.Movie; 6 | 7 | public interface RecommendMovieRealTimeService { 8 | 9 | /** 10 | * 根据userId,获取实时推荐的movieId 11 | * 然后根据movieId获取每一部电影信息 12 | * @param userId 13 | * @return 14 | */ 15 | List getMovieInfoRealTime(Integer userId); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/RecommendMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.Movie; 6 | 7 | public interface RecommendMovieService { 8 | 9 | //根据userId选择出来的10个movieId,将movie从数据库中读取出来 10 | List getMovieByUserId(Integer userId); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/RomanceMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface RomanceMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/ThrillerMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface ThrillerMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.User; 6 | 7 | public interface UserService { 8 | 9 | List getUserList(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/WarMovieService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import com.xqt.recommend.entity.ActionMovie; 6 | import com.xqt.recommend.entity.Movie; 7 | 8 | public interface WarMovieService { 9 | 10 | /** 11 | * 从数据库中随机选择出10部电影 12 | * @return 13 | */ 14 | List get10ActionMovie(); 15 | 16 | /** 17 | * 根据movieId从数据库中获取到某一部电影的详细信息 18 | * @param movieId 19 | * @return 20 | */ 21 | ActionMovie selectActionMovieById(Integer movieId); 22 | } 23 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/WechatAuthService.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import org.springframework.web.multipart.commons.CommonsMultipartFile; 4 | 5 | import com.xqt.recommend.dto.WechatAuthExecution; 6 | import com.xqt.recommend.entity.WechatAuth; 7 | 8 | 9 | 10 | public interface WechatAuthService { 11 | 12 | /** 13 | * 14 | * @param openId 15 | * @return 16 | */ 17 | WechatAuth getWechatAuthByOpenId(String openId); 18 | 19 | /** 20 | * 21 | * @param wechatAuth 22 | * @param profileImg 23 | * @return 24 | * @throws RuntimeException 25 | */ 26 | WechatAuthExecution register(WechatAuth wechatAuth) throws RuntimeException; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/ActionMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.ActionMovieService; 14 | 15 | @Service 16 | public class ActionMovieServiceImpl implements ActionMovieService{ 17 | 18 | @Autowired 19 | private ActionMovieDao actionMovieDao; 20 | 21 | @Autowired 22 | private MovieDao movieDao; 23 | 24 | @Override 25 | /** 26 | * 产生一个随机数,向后选取10部电影 27 | */ 28 | public List get10ActionMovie() { 29 | Integer tableCount = getTableCount(); 30 | //产生一个在1--tableCount中的随机数 31 | int x=1+(int)(Math.random()*tableCount); 32 | //如果x过大,就无法取到10条数据, 33 | //此处确保能取到10条数据 34 | if (x >= tableCount-10) { 35 | x -= 10; 36 | } 37 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 38 | List movieList = new ArrayList<>(); 39 | 40 | for(ActionMovie actionMovie:actionMovieList) { 41 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 42 | } 43 | 44 | return movieList; 45 | } 46 | 47 | /** 48 | * 得到表中的条目总数 49 | */ 50 | private Integer getTableCount() { 51 | return actionMovieDao.count(); 52 | } 53 | 54 | @Override 55 | public ActionMovie selectActionMovieById(Integer movieId) { 56 | // TODO Auto-generated method stub 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/ComedyMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.ComedyMovieService; 14 | 15 | @Service 16 | public class ComedyMovieServiceImpl implements ComedyMovieService{ 17 | 18 | @Autowired 19 | private ActionMovieDao actionMovieDao; 20 | 21 | @Autowired 22 | private MovieDao movieDao; 23 | 24 | @Override 25 | /** 26 | * 产生一个随机数,向后选取10部电影 27 | */ 28 | public List get10ActionMovie() { 29 | Integer tableCount = getTableCount(); 30 | //产生一个在1--tableCount中的随机数 31 | int x=1+(int)(Math.random()*tableCount); 32 | //如果x过大,就无法取到10条数据, 33 | //此处确保能取到10条数据 34 | if (x >= tableCount-10) { 35 | x -= 10; 36 | } 37 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 38 | List movieList = new ArrayList<>(); 39 | 40 | for(ActionMovie actionMovie:actionMovieList) { 41 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 42 | } 43 | 44 | return movieList; 45 | } 46 | 47 | /** 48 | * 得到表中的条目总数 49 | */ 50 | private Integer getTableCount() { 51 | return actionMovieDao.count(); 52 | } 53 | 54 | @Override 55 | public ActionMovie selectActionMovieById(Integer movieId) { 56 | // TODO Auto-generated method stub 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/CrimeMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.CrimeMovieService; 14 | 15 | @Service 16 | public class CrimeMovieServiceImpl implements CrimeMovieService{ 17 | 18 | @Autowired 19 | private ActionMovieDao actionMovieDao; 20 | 21 | @Autowired 22 | private MovieDao movieDao; 23 | 24 | @Override 25 | /** 26 | * 产生一个随机数,向后选取10部电影 27 | */ 28 | public List get10ActionMovie() { 29 | Integer tableCount = getTableCount(); 30 | //产生一个在1--tableCount中的随机数 31 | int x=1+(int)(Math.random()*tableCount); 32 | //如果x过大,就无法取到10条数据, 33 | //此处确保能取到10条数据 34 | if (x >= tableCount-10) { 35 | x -= 10; 36 | } 37 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 38 | List movieList = new ArrayList<>(); 39 | 40 | for(ActionMovie actionMovie:actionMovieList) { 41 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 42 | } 43 | 44 | return movieList; 45 | } 46 | 47 | /** 48 | * 得到表中的条目总数 49 | */ 50 | private Integer getTableCount() { 51 | return actionMovieDao.count(); 52 | } 53 | 54 | @Override 55 | public ActionMovie selectActionMovieById(Integer movieId) { 56 | // TODO Auto-generated method stub 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/FantasyMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.ActionMovieService; 14 | import com.xqt.recommend.service.FantasyMovieService; 15 | 16 | @Service 17 | public class FantasyMovieServiceImpl implements FantasyMovieService{ 18 | 19 | @Autowired 20 | private ActionMovieDao actionMovieDao; 21 | 22 | @Autowired 23 | private MovieDao movieDao; 24 | 25 | @Override 26 | /** 27 | * 产生一个随机数,向后选取10部电影 28 | */ 29 | public List get10ActionMovie() { 30 | Integer tableCount = getTableCount(); 31 | //产生一个在1--tableCount中的随机数 32 | int x=1+(int)(Math.random()*tableCount); 33 | //如果x过大,就无法取到10条数据, 34 | //此处确保能取到10条数据 35 | if (x >= tableCount-10) { 36 | x -= 10; 37 | } 38 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 39 | List movieList = new ArrayList<>(); 40 | 41 | for(ActionMovie actionMovie:actionMovieList) { 42 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 43 | } 44 | 45 | return movieList; 46 | } 47 | 48 | /** 49 | * 得到表中的条目总数 50 | */ 51 | private Integer getTableCount() { 52 | return actionMovieDao.count(); 53 | } 54 | 55 | @Override 56 | public ActionMovie selectActionMovieById(Integer movieId) { 57 | // TODO Auto-generated method stub 58 | return null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/HottestMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.xqt.recommend.dao.HottestMovieDao; 9 | import com.xqt.recommend.entity.HottestMovie; 10 | import com.xqt.recommend.service.HottestMovieService; 11 | 12 | @Service 13 | public class HottestMovieServiceImpl implements HottestMovieService{ 14 | 15 | @Autowired 16 | private HottestMovieDao hottestMovieDao; 17 | 18 | @Override 19 | public List getTop5Movie() { 20 | return hottestMovieDao.selectTop5Movie(); 21 | } 22 | 23 | @Override 24 | public HottestMovie selectMovieById(Integer hottestMovieId) { 25 | return hottestMovieDao.selectMovieById(hottestMovieId); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/LocalAuthServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | import org.springframework.web.multipart.commons.CommonsMultipartFile; 9 | 10 | import com.xqt.recommend.dao.LocalAuthDao; 11 | import com.xqt.recommend.dao.PersonInfoDao; 12 | import com.xqt.recommend.dao.UserPerefenceDao; 13 | import com.xqt.recommend.dto.LocalAuthExecution; 14 | import com.xqt.recommend.entity.LocalAuth; 15 | import com.xqt.recommend.entity.PersonInfo; 16 | import com.xqt.recommend.entity.UserPerefence; 17 | import com.xqt.recommend.enums.LocalAuthStateEnum; 18 | import com.xqt.recommend.service.LocalAuthService; 19 | //import com.xqt.recommend.util.FileUtil; 20 | //import com.xqt.recommend.util.ImageUtil; 21 | 22 | 23 | 24 | 25 | 26 | @Service 27 | public class LocalAuthServiceImpl implements LocalAuthService { 28 | 29 | @Autowired 30 | private LocalAuthDao localAuthDao; 31 | @Autowired 32 | private PersonInfoDao personInfoDao; 33 | @Autowired 34 | private UserPerefenceDao userPerefenceDao; 35 | 36 | @Override 37 | public LocalAuth getLocalAuthByUserNameAndPwd(String userName, 38 | String password) { 39 | return localAuthDao.queryLocalByUserNameAndPwd(userName, password); 40 | } 41 | 42 | @Override 43 | public LocalAuth getLocalAuthByUserId(long userId) { 44 | return localAuthDao.queryLocalByUserId(userId); 45 | } 46 | 47 | @Override 48 | public LocalAuth getLocalAuthByUserName(String userName) { 49 | return localAuthDao.queryLocalByUserName(userName); 50 | } 51 | 52 | @Override 53 | @Transactional 54 | public LocalAuthExecution register(LocalAuth localAuth, 55 | CommonsMultipartFile profileImg,Integer[] perefence) throws RuntimeException { 56 | if (localAuth == null || localAuth.getPassword() == null 57 | || localAuth.getUsername() == null) { 58 | return new LocalAuthExecution(LocalAuthStateEnum.NULL_AUTH_INFO); 59 | } 60 | try { 61 | localAuth.setCreateTime(new Date()); 62 | localAuth.setLastEditTime(new Date()); 63 | localAuth.setPassword(localAuth.getPassword()); 64 | if (localAuth.getPersonInfo() != null 65 | && localAuth.getPersonInfo().getUserId() == null) { 66 | if (profileImg != null) { 67 | localAuth.getPersonInfo().setCreateTime(new Date()); 68 | localAuth.getPersonInfo().setLastEditTime(new Date()); 69 | localAuth.getPersonInfo().setEnableStatus(1); 70 | try { 71 | // addProfileImg(localAuth, profileImg); 72 | } catch (Exception e) { 73 | throw new RuntimeException("addUserProfileImg error: " 74 | + e.getMessage()); 75 | } 76 | } 77 | try { 78 | PersonInfo personInfo = localAuth.getPersonInfo(); 79 | int effectedNum = personInfoDao.insertPersonInfo(personInfo); 80 | //localAuth.setUserId(personInfo.getUserId()); 81 | if (effectedNum <= 0) { 82 | throw new RuntimeException("添加用户信息失败"); 83 | } 84 | } catch (Exception e) { 85 | throw new RuntimeException("insertPersonInfo error: " 86 | + e.getMessage()); 87 | } 88 | } 89 | 90 | 91 | int effectedNum = localAuthDao.insertLocalAuth(localAuth); 92 | if (effectedNum <= 0) { 93 | throw new RuntimeException("帐号创建失败"); 94 | } else { 95 | 96 | 97 | for(int i=0;i getTop10Movie() { 20 | return movieDao.selectTop10Movie(); 21 | } 22 | 23 | @Override 24 | public Movie selectMovieById(Integer movieId) { 25 | return movieDao.selectMovieById(movieId); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/MusicalMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.ActionMovieService; 14 | import com.xqt.recommend.service.MusicalMovieService; 15 | 16 | @Service 17 | public class MusicalMovieServiceImpl implements MusicalMovieService{ 18 | 19 | @Autowired 20 | private ActionMovieDao actionMovieDao; 21 | 22 | @Autowired 23 | private MovieDao movieDao; 24 | 25 | @Override 26 | /** 27 | * 产生一个随机数,向后选取10部电影 28 | */ 29 | public List get10ActionMovie() { 30 | Integer tableCount = getTableCount(); 31 | //产生一个在1--tableCount中的随机数 32 | int x=1+(int)(Math.random()*tableCount); 33 | //如果x过大,就无法取到10条数据, 34 | //此处确保能取到10条数据 35 | if (x >= tableCount-10) { 36 | x -= 10; 37 | } 38 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 39 | List movieList = new ArrayList<>(); 40 | 41 | for(ActionMovie actionMovie:actionMovieList) { 42 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 43 | } 44 | 45 | return movieList; 46 | } 47 | 48 | /** 49 | * 得到表中的条目总数 50 | */ 51 | private Integer getTableCount() { 52 | return actionMovieDao.count(); 53 | } 54 | 55 | @Override 56 | public ActionMovie selectActionMovieById(Integer movieId) { 57 | // TODO Auto-generated method stub 58 | return null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/PersonInfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | import com.xqt.recommend.dao.PersonInfoDao; 10 | import com.xqt.recommend.entity.PersonInfo; 11 | import com.xqt.recommend.service.PersonInfoService; 12 | 13 | 14 | @Service 15 | public class PersonInfoServiceImpl implements PersonInfoService { 16 | @Autowired 17 | private PersonInfoDao personInfoDao; 18 | 19 | @Override 20 | public PersonInfo getPersonInfoById(Long userId) { 21 | return personInfoDao.queryPersonInfoById(userId); 22 | } 23 | 24 | /*@Override 25 | public PersonInfoExecution getPersonInfoList( 26 | PersonInfo personInfoCondition, int pageIndex, int pageSize) { 27 | int rowIndex = PageCalculator.calculateRowIndex(pageIndex, pageSize); 28 | List personInfoList = personInfoDao.queryPersonInfoList( 29 | personInfoCondition, rowIndex, pageSize); 30 | int count = personInfoDao.queryPersonInfoCount(personInfoCondition); 31 | PersonInfoExecution se = new PersonInfoExecution(); 32 | if (personInfoList != null) { 33 | se.setPersonInfoList(personInfoList); 34 | se.setCount(count); 35 | } else { 36 | se.setState(PersonInfoStateEnum.INNER_ERROR.getState()); 37 | } 38 | return se; 39 | } 40 | 41 | @Override 42 | @Transactional 43 | public PersonInfoExecution addPersonInfo(PersonInfo personInfo) { 44 | if (personInfo == null) { 45 | return new PersonInfoExecution(PersonInfoStateEnum.EMPTY); 46 | } else { 47 | try { 48 | int effectedNum = personInfoDao.insertPersonInfo(personInfo); 49 | if (effectedNum <= 0) { 50 | return new PersonInfoExecution( 51 | PersonInfoStateEnum.INNER_ERROR); 52 | } else {// 创建成功 53 | personInfo = personInfoDao.queryPersonInfoById(personInfo 54 | .getUserId()); 55 | return new PersonInfoExecution(PersonInfoStateEnum.SUCCESS, 56 | personInfo); 57 | } 58 | } catch (Exception e) { 59 | throw new RuntimeException("addPersonInfo error: " 60 | + e.getMessage()); 61 | } 62 | } 63 | } 64 | 65 | @Override 66 | @Transactional 67 | public PersonInfoExecution modifyPersonInfo(PersonInfo personInfo) { 68 | if (personInfo == null || personInfo.getUserId() == null) { 69 | return new PersonInfoExecution(PersonInfoStateEnum.EMPTY); 70 | } else { 71 | try { 72 | int effectedNum = personInfoDao.updatePersonInfo(personInfo); 73 | if (effectedNum <= 0) { 74 | return new PersonInfoExecution( 75 | PersonInfoStateEnum.INNER_ERROR); 76 | } else {// 创建成功 77 | personInfo = personInfoDao.queryPersonInfoById(personInfo 78 | .getUserId()); 79 | return new PersonInfoExecution(PersonInfoStateEnum.SUCCESS, 80 | personInfo); 81 | } 82 | } catch (Exception e) { 83 | throw new RuntimeException("updatePersonInfo error: " 84 | + e.getMessage()); 85 | } 86 | } 87 | }*/ 88 | 89 | } 90 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/RecommendMovieRealTimeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.MovieDao; 10 | import com.xqt.recommend.dao.RecommendMovieRealTimeDao; 11 | import com.xqt.recommend.entity.Movie; 12 | import com.xqt.recommend.entity.RecommendMovieRealTime; 13 | import com.xqt.recommend.service.RecommendMovieRealTimeService; 14 | 15 | @Service 16 | public class RecommendMovieRealTimeServiceImpl implements RecommendMovieRealTimeService{ 17 | 18 | @Autowired 19 | private RecommendMovieRealTimeDao recommendMovieRealTimeDao; 20 | 21 | @Autowired 22 | private MovieDao movieDao; 23 | 24 | @Override 25 | public List getMovieInfoRealTime(Integer userId) { 26 | List movieList = new ArrayList<>(); 27 | //获取实时推荐的电影--5部 28 | List realTimeMovieList = recommendMovieRealTimeDao.selectMovieByUserId(userId); 29 | 30 | for(RecommendMovieRealTime movie:realTimeMovieList) { 31 | movieList.add(movieDao.selectMovieById(movie.getMovieId())); 32 | } 33 | 34 | return movieList; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/RecommendMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.MovieDao; 10 | import com.xqt.recommend.dao.RecommendMovieDao; 11 | import com.xqt.recommend.entity.Movie; 12 | import com.xqt.recommend.service.RecommendMovieService; 13 | 14 | @Service 15 | public class RecommendMovieServiceImpl implements RecommendMovieService{ 16 | 17 | @Autowired 18 | private RecommendMovieDao recommendMovieDao; 19 | 20 | @Autowired 21 | private MovieDao movieDao; 22 | 23 | /** 24 | * 传入userId, 从数据库中读取为该用户推荐的电影的movieId 25 | */ 26 | @Override 27 | public List getMovieByUserId(Integer userId) { 28 | List movieList = new ArrayList<>(); 29 | //获取每部电影的movieId 30 | List movieIdList = recommendMovieDao.getMovieIdListByUserId(userId); 31 | //通过每部电影movieId将movie信息获取出来 32 | for(Integer movieId:movieIdList) { 33 | movieList.add(movieDao.selectMovieById(movieId)); 34 | } 35 | 36 | return movieList; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/RomanceMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.ActionMovieService; 14 | import com.xqt.recommend.service.RomanceMovieService; 15 | 16 | @Service 17 | public class RomanceMovieServiceImpl implements RomanceMovieService{ 18 | 19 | @Autowired 20 | private ActionMovieDao actionMovieDao; 21 | 22 | @Autowired 23 | private MovieDao movieDao; 24 | 25 | @Override 26 | /** 27 | * 产生一个随机数,向后选取10部电影 28 | */ 29 | public List get10ActionMovie() { 30 | Integer tableCount = getTableCount(); 31 | //产生一个在1--tableCount中的随机数 32 | int x=1+(int)(Math.random()*tableCount); 33 | //如果x过大,就无法取到10条数据, 34 | //此处确保能取到10条数据 35 | if (x >= tableCount-10) { 36 | x -= 10; 37 | } 38 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 39 | List movieList = new ArrayList<>(); 40 | 41 | for(ActionMovie actionMovie:actionMovieList) { 42 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 43 | } 44 | 45 | return movieList; 46 | } 47 | 48 | /** 49 | * 得到表中的条目总数 50 | */ 51 | private Integer getTableCount() { 52 | return actionMovieDao.count(); 53 | } 54 | 55 | @Override 56 | public ActionMovie selectActionMovieById(Integer movieId) { 57 | // TODO Auto-generated method stub 58 | return null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/ThrillerMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.ActionMovieService; 14 | import com.xqt.recommend.service.ThrillerMovieService; 15 | 16 | @Service 17 | public class ThrillerMovieServiceImpl implements ThrillerMovieService{ 18 | 19 | @Autowired 20 | private ActionMovieDao actionMovieDao; 21 | 22 | @Autowired 23 | private MovieDao movieDao; 24 | 25 | @Override 26 | /** 27 | * 产生一个随机数,向后选取10部电影 28 | */ 29 | public List get10ActionMovie() { 30 | Integer tableCount = getTableCount(); 31 | //产生一个在1--tableCount中的随机数 32 | int x=1+(int)(Math.random()*tableCount); 33 | //如果x过大,就无法取到10条数据, 34 | //此处确保能取到10条数据 35 | if (x >= tableCount-10) { 36 | x -= 10; 37 | } 38 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 39 | List movieList = new ArrayList<>(); 40 | 41 | for(ActionMovie actionMovie:actionMovieList) { 42 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 43 | } 44 | 45 | return movieList; 46 | } 47 | 48 | /** 49 | * 得到表中的条目总数 50 | */ 51 | private Integer getTableCount() { 52 | return actionMovieDao.count(); 53 | } 54 | 55 | @Override 56 | public ActionMovie selectActionMovieById(Integer movieId) { 57 | // TODO Auto-generated method stub 58 | return null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.xqt.recommend.dao.UserDao; 9 | import com.xqt.recommend.entity.User; 10 | import com.xqt.recommend.service.UserService; 11 | 12 | @Service 13 | public class UserServiceImpl implements UserService{ 14 | 15 | @Autowired 16 | private UserDao userDao; 17 | 18 | @Override 19 | public List getUserList() { 20 | return userDao.queryUser(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/WarMovieServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.xqt.recommend.dao.ActionMovieDao; 10 | import com.xqt.recommend.dao.MovieDao; 11 | import com.xqt.recommend.entity.ActionMovie; 12 | import com.xqt.recommend.entity.Movie; 13 | import com.xqt.recommend.service.WarMovieService; 14 | 15 | @Service 16 | public class WarMovieServiceImpl implements WarMovieService{ 17 | 18 | @Autowired 19 | private ActionMovieDao actionMovieDao; 20 | 21 | @Autowired 22 | private MovieDao movieDao; 23 | 24 | @Override 25 | /** 26 | * 产生一个随机数,向后选取10部电影 27 | */ 28 | public List get10ActionMovie() { 29 | Integer tableCount = getTableCount(); 30 | //产生一个在1--tableCount中的随机数 31 | int x=1+(int)(Math.random()*tableCount); 32 | //如果x过大,就无法取到10条数据, 33 | //此处确保能取到10条数据 34 | if (x >= tableCount-10) { 35 | x -= 10; 36 | } 37 | List actionMovieList= actionMovieDao.selectBytableInnerId(x); 38 | List movieList = new ArrayList<>(); 39 | 40 | for(ActionMovie actionMovie:actionMovieList) { 41 | movieList.add(movieDao.selectMovieById(actionMovie.getMovieId())); 42 | } 43 | 44 | return movieList; 45 | } 46 | 47 | /** 48 | * 得到表中的条目总数 49 | */ 50 | private Integer getTableCount() { 51 | return actionMovieDao.count(); 52 | } 53 | 54 | @Override 55 | public ActionMovie selectActionMovieById(Integer movieId) { 56 | // TODO Auto-generated method stub 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/service/impl/WechatAuthServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service.impl; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import com.xqt.recommend.dao.PersonInfoDao; 12 | import com.xqt.recommend.dao.WechatAuthDao; 13 | import com.xqt.recommend.dto.WechatAuthExecution; 14 | import com.xqt.recommend.entity.PersonInfo; 15 | import com.xqt.recommend.entity.WechatAuth; 16 | import com.xqt.recommend.enums.WechatAuthStateEnum; 17 | import com.xqt.recommend.service.WechatAuthService; 18 | 19 | 20 | @Service 21 | public class WechatAuthServiceImpl implements WechatAuthService { 22 | private static Logger log = LoggerFactory 23 | .getLogger(WechatAuthServiceImpl.class); 24 | @Autowired 25 | private WechatAuthDao wechatAuthDao; 26 | @Autowired 27 | private PersonInfoDao personInfoDao; 28 | 29 | @Override 30 | public WechatAuth getWechatAuthByOpenId(String openId) { 31 | return wechatAuthDao.queryWechatInfoByOpenId(openId); 32 | } 33 | 34 | @Override 35 | @Transactional 36 | public WechatAuthExecution register(WechatAuth wechatAuth) throws RuntimeException { 37 | if (wechatAuth == null || wechatAuth.getOpenId() == null) { 38 | return new WechatAuthExecution(WechatAuthStateEnum.NULL_AUTH_INFO); 39 | } 40 | try { 41 | wechatAuth.setCreateTime(new Date()); 42 | if (wechatAuth.getPersonInfo() != null 43 | && wechatAuth.getPersonInfo().getUserId() == null) { 44 | try { 45 | wechatAuth.getPersonInfo().setCreateTime(new Date()); 46 | wechatAuth.getPersonInfo().setEnableStatus(1); 47 | PersonInfo personInfo=wechatAuth.getPersonInfo(); 48 | int effectedNum=personInfoDao.insertPersonInfo(personInfo); 49 | wechatAuth.setPersonInfo(personInfo); 50 | if(effectedNum<=0) { 51 | System.out.println("添加用户信息失败"); 52 | } 53 | } catch (Exception e) { 54 | log.error("insertPersonInfo error:"+e.toString()); 55 | throw new RuntimeException("insertPersonInfo error: " 56 | + e.getMessage()); 57 | } 58 | } 59 | int effectedNum = wechatAuthDao.insertWechatAuth(wechatAuth); 60 | if (effectedNum <= 0) { 61 | throw new RuntimeException("帐号创建失败"); 62 | } else { 63 | return new WechatAuthExecution(WechatAuthStateEnum.SUCCESS, 64 | wechatAuth); 65 | } 66 | } catch (Exception e) { 67 | log.error("insertWechatAuth error:" + e.toString()); 68 | throw new RuntimeException("insertWechatAuth error: " 69 | + e.getMessage()); 70 | } 71 | } 72 | 73 | 74 | /*@Override 75 | @Transactional 76 | public WechatAuthExecution register(WechatAuth wechatAuth, 77 | CommonsMultipartFile profileImg) throws RuntimeException { 78 | if (wechatAuth == null || wechatAuth.getOpenId() == null) { 79 | return new WechatAuthExecution(WechatAuthStateEnum.NULL_AUTH_INFO); 80 | } 81 | try { 82 | wechatAuth.setCreateTime(new Date()); 83 | if (wechatAuth.getPersonInfo() != null 84 | && wechatAuth.getPersonInfo().getUserId() == null) { 85 | if (profileImg != null) { 86 | try { 87 | addProfileImg(wechatAuth, profileImg); 88 | } catch (Exception e) { 89 | log.debug("addUserProfileImg error:" + e.toString()); 90 | throw new RuntimeException("addUserProfileImg error: " 91 | + e.getMessage()); 92 | } 93 | } 94 | try { 95 | wechatAuth.getPersonInfo().setCreateTime(new Date()); 96 | wechatAuth.getPersonInfo().setLastEditTime(new Date()); 97 | wechatAuth.getPersonInfo().setCustomerFlag(1); 98 | wechatAuth.getPersonInfo().setShopOwnerFlag(1); 99 | wechatAuth.getPersonInfo().setAdminFlag(0); 100 | wechatAuth.getPersonInfo().setEnableStatus(1); 101 | PersonInfo personInfo = wechatAuth.getPersonInfo(); 102 | int effectedNum = personInfoDao 103 | .insertPersonInfo(personInfo); 104 | wechatAuth.setUserId(personInfo.getUserId()); 105 | if (effectedNum <= 0) { 106 | throw new RuntimeException("添加用户信息失败"); 107 | } 108 | } catch (Exception e) { 109 | log.debug("insertPersonInfo error:" + e.toString()); 110 | throw new RuntimeException("insertPersonInfo error: " 111 | + e.getMessage()); 112 | } 113 | } 114 | int effectedNum = wechatAuthDao.insertWechatAuth(wechatAuth); 115 | if (effectedNum <= 0) { 116 | throw new RuntimeException("帐号创建失败"); 117 | } else { 118 | return new WechatAuthExecution(WechatAuthStateEnum.SUCCESS, 119 | wechatAuth); 120 | } 121 | } catch (Exception e) { 122 | log.debug("insertWechatAuth error:" + e.toString()); 123 | throw new RuntimeException("insertWechatAuth error: " 124 | + e.getMessage()); 125 | } 126 | }*/ 127 | /*private void addProfileImg(WechatAuth wechatAuth, 128 | CommonsMultipartFile profileImg) { 129 | String dest = FileUtil.getPersonInfoImagePath(); 130 | String profileImgAddr = ImageUtil.generateThumbnail(profileImg, dest); 131 | wechatAuth.getPersonInfo().setProfileImg(profileImgAddr); 132 | }*/ 133 | 134 | } 135 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/util/CodeUtil.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.util; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | public class CodeUtil { 6 | /** 7 | * 检查验证码是否和预期相符 8 | * 9 | * @param request 10 | * @return 11 | */ 12 | public static boolean checkVerifyCode(HttpServletRequest request) { 13 | String verifyCodeExpected = (String) request.getSession() 14 | .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); 15 | String verifyCodeActual = HttpServletRequestUtil.getString(request, "verifyCodeActual"); 16 | if (verifyCodeActual == null || !verifyCodeActual.equals(verifyCodeExpected)) { 17 | return false; 18 | } 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/util/HttpServletRequestUtil.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.util; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | public class HttpServletRequestUtil { 6 | public static int getInt(HttpServletRequest request, String key) { 7 | try { 8 | return Integer.decode(request.getParameter(key)); 9 | } catch (Exception e) { 10 | return -1; 11 | } 12 | } 13 | 14 | public static long getLong(HttpServletRequest request, String key) { 15 | try { 16 | System.out.println(request.toString()); 17 | return Long.valueOf(request.getParameter(key)); 18 | } catch (Exception e) { 19 | return -1; 20 | } 21 | } 22 | 23 | public static Double getDouble(HttpServletRequest request, String key) { 24 | try { 25 | return Double.valueOf(request.getParameter(key)); 26 | } catch (Exception e) { 27 | return -1d; 28 | } 29 | } 30 | 31 | public static boolean getBoolean(HttpServletRequest request, String key) { 32 | try { 33 | return Boolean.valueOf(request.getParameter(key)); 34 | } catch (Exception e) { 35 | return false; 36 | } 37 | } 38 | 39 | public static String getString(HttpServletRequest request, String key) { 40 | try { 41 | String result = request.getParameter(key); 42 | if (result != null) { 43 | result = result.trim(); 44 | } 45 | if ("".equals(result)) { 46 | result = null; 47 | } 48 | return result; 49 | } catch (Exception e) { 50 | return null; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/util/wechat/MyX509TrustManager.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.util.wechat; 2 | import java.security.cert.CertificateException; 3 | import java.security.cert.X509Certificate; 4 | 5 | import javax.net.ssl.X509TrustManager; 6 | 7 | /** 8 | * 证书信任管理器(用于https请求) 9 | * 10 | * @author liufeng 11 | * @date 2013-08-08 12 | */ 13 | public class MyX509TrustManager implements X509TrustManager { 14 | 15 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { 16 | } 17 | 18 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { 19 | } 20 | 21 | public X509Certificate[] getAcceptedIssuers() { 22 | return null; 23 | } 24 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/util/wechat/SignUtil.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.util.wechat; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | import java.util.Arrays; 6 | 7 | /** 8 | * 验证签名 9 | */ 10 | public class SignUtil { 11 | // 与接口中token一致 12 | private static String token = "MovieRecommend"; 13 | 14 | /** 15 | * 楠岃瘉绛惧悕 16 | * 17 | * @param signature 18 | * @param timestamp 19 | * @param nonce 20 | * @return 21 | */ 22 | public static boolean checkSignature(String signature, String timestamp, String nonce) { 23 | String[] arr = new String[] { token, timestamp, nonce }; 24 | // 将token、timestamp、nonce三个参数进行字典排序 25 | Arrays.sort(arr); 26 | StringBuilder content = new StringBuilder(); 27 | for (int i = 0; i < arr.length; i++) { 28 | content.append(arr[i]); 29 | } 30 | MessageDigest md = null; 31 | String tmpStr = null; 32 | 33 | try { 34 | md = MessageDigest.getInstance("SHA-1"); 35 | // 将三个参数字符串拼接成一个字符串进行SHA-1加密 36 | byte[] digest = md.digest(content.toString().getBytes()); 37 | tmpStr = byteToStr(digest); 38 | } catch (NoSuchAlgorithmException e) { 39 | e.printStackTrace(); 40 | } 41 | 42 | content = null; 43 | // 将SHA-1加密后的字符串与signature对比,标识该请求来源于微信 44 | return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false; 45 | } 46 | 47 | /** 48 | * 将字节数组转换为十六进制字符串 49 | * 50 | * @param byteArray 51 | * @return 52 | */ 53 | private static String byteToStr(byte[] byteArray) { 54 | String strDigest = ""; 55 | for (int i = 0; i < byteArray.length; i++) { 56 | strDigest += byteToHexStr(byteArray[i]); 57 | } 58 | return strDigest; 59 | } 60 | 61 | /** 62 | * 将字节转换为十六进制字符串 63 | * 64 | * @param mByte 65 | * @return 66 | */ 67 | private static String byteToHexStr(byte mByte) { 68 | char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; 69 | char[] tempArr = new char[2]; 70 | tempArr[0] = Digit[(mByte >>> 4) & 0X0F]; 71 | tempArr[1] = Digit[mByte & 0X0F]; 72 | 73 | String s = new String(tempArr); 74 | return s; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/util/wechat/WeiXinUser.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.util.wechat; 2 | 3 | import java.io.Serializable; 4 | 5 | public class WeiXinUser implements Serializable { 6 | 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | private int id; 13 | 14 | private String openId; 15 | 16 | private String nickName; 17 | 18 | private int sex; 19 | 20 | private String province; 21 | 22 | private String city; 23 | 24 | private String country; 25 | 26 | private String headimgurl; 27 | 28 | private String privilege; 29 | 30 | private String unionid; 31 | 32 | public int getId() { 33 | return id; 34 | } 35 | 36 | public void setId(int id) { 37 | this.id = id; 38 | } 39 | 40 | public String getOpenId() { 41 | return openId; 42 | } 43 | 44 | public void setOpenId(String openId) { 45 | this.openId = openId; 46 | } 47 | 48 | public String getNickName() { 49 | return nickName; 50 | } 51 | 52 | public void setNickName(String nickName) { 53 | this.nickName = nickName; 54 | } 55 | 56 | public int getSex() { 57 | return sex; 58 | } 59 | 60 | public void setSex(int sex) { 61 | this.sex = sex; 62 | } 63 | 64 | public String getProvince() { 65 | return province; 66 | } 67 | 68 | public void setProvince(String province) { 69 | this.province = province; 70 | } 71 | 72 | public String getCity() { 73 | return city; 74 | } 75 | 76 | public void setCity(String city) { 77 | this.city = city; 78 | } 79 | 80 | public String getCountry() { 81 | return country; 82 | } 83 | 84 | public void setCountry(String country) { 85 | this.country = country; 86 | } 87 | 88 | public String getHeadimgurl() { 89 | return headimgurl; 90 | } 91 | 92 | public void setHeadimgurl(String headimgurl) { 93 | this.headimgurl = headimgurl; 94 | } 95 | 96 | public String getPrivilege() { 97 | return privilege; 98 | } 99 | 100 | public void setPrivilege(String privilege) { 101 | this.privilege = privilege; 102 | } 103 | 104 | public String getUnionid() { 105 | return unionid; 106 | } 107 | 108 | public void setUnionid(String unionid) { 109 | this.unionid = unionid; 110 | } 111 | 112 | @Override 113 | public String toString() { 114 | return "openId:" + this.getOpenId() + ",nikename:" + this.getNickName(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/web/index/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.web.index; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | /** 8 | * 用来解析路由并转发到相应的html中 9 | * 10 | */ 11 | @Controller 12 | public class IndexController { 13 | 14 | @RequestMapping(value = "/frontend/index", method=RequestMethod.GET) 15 | public String index() { 16 | return "/frontend/index"; 17 | } 18 | 19 | @RequestMapping(value = "/frontend/moviedetail", method=RequestMethod.GET) 20 | public String movieDetail(String movieId) { 21 | 22 | return "/frontend/moviedetail"; 23 | } 24 | 25 | @RequestMapping(value = "/frontend/shoplist", method=RequestMethod.GET) 26 | public String shopList() { 27 | return "/frontend/shoplist"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/web/local/LocalController.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.web.local; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | @Controller 8 | @RequestMapping("/local") 9 | public class LocalController { 10 | /** 11 | *绑定账号路由 12 | */ 13 | @RequestMapping(value="/accountbind",method=RequestMethod.GET) 14 | private String accountbind() { 15 | return "local/accountbind"; 16 | } 17 | /** 18 | * 修改密码路由 19 | */ 20 | @RequestMapping(value="/changepsw",method=RequestMethod.GET) 21 | private String changepsw() { 22 | return "local/changepsw"; 23 | } 24 | @RequestMapping(value="/login",method=RequestMethod.GET) 25 | private String login() { 26 | return "local/login"; 27 | } 28 | @RequestMapping(value="/register",method=RequestMethod.GET) 29 | private String register() { 30 | return "local/register"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/web/useradmin/UserController.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.web.useradmin; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import com.xqt.recommend.entity.User; 15 | import com.xqt.recommend.service.UserService; 16 | 17 | @Controller 18 | @RequestMapping("/useradmin") 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @RequestMapping(value = "/listuser", method = RequestMethod.GET) 25 | @ResponseBody 26 | private Map listUser() { 27 | Map modelMap = new HashMap<>(); 28 | List list = new ArrayList<>(); 29 | try { 30 | list = userService.getUserList(); 31 | modelMap.put("rows", list); 32 | modelMap.put("total", list.size()); 33 | }catch (Exception e) { 34 | e.printStackTrace(); 35 | modelMap.put("success", false); 36 | modelMap.put("errMsg", "UserController--listUser()"+e.toString()); 37 | } 38 | return modelMap; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/java/com/xqt/recommend/web/wechat/WeiXinController.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.web.wechat; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import javax.annotation.Resource; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | 15 | 16 | import com.xqt.recommend.service.PersonInfoService; 17 | import com.xqt.recommend.util.wechat.SignUtil; 18 | 19 | import com.xqt.recommend.service.WechatAuthService; 20 | 21 | 22 | 23 | @Controller 24 | @RequestMapping("wechat") 25 | public class WeiXinController { 26 | 27 | private static Logger log = LoggerFactory.getLogger(WeiXinController.class); 28 | 29 | @Resource 30 | private WechatAuthService WechatAuthService; 31 | 32 | @Resource 33 | private PersonInfoService personInfoService; 34 | 35 | @RequestMapping(method = { RequestMethod.GET }) 36 | public void doGet(HttpServletRequest request, HttpServletResponse response) { 37 | log.debug("weixin get..."); 38 | // 微信加密签名 39 | String signature = request.getParameter("signature"); 40 | // 时间戳 41 | String timestamp = request.getParameter("timestamp"); 42 | // 随机数 43 | String nonce = request.getParameter("nonce"); 44 | // 随机字符串 45 | String echostr = request.getParameter("echostr"); 46 | 47 | // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 48 | PrintWriter out = null; 49 | try { 50 | out = response.getWriter(); 51 | if (SignUtil.checkSignature(signature, timestamp, nonce)) { 52 | log.debug("weixin get success...."); 53 | out.print(echostr); 54 | } 55 | } catch (IOException e) { 56 | e.printStackTrace(); 57 | } finally { 58 | if (out != null) 59 | out.close(); 60 | } 61 | } 62 | 63 | /*@RequestMapping(method = { RequestMethod.POST }, produces = "application/xml;charset=UTF-8") 64 | public void doPost(HttpServletRequest request, HttpServletResponse response) { 65 | try { 66 | request.setCharacterEncoding("UTF-8"); 67 | response.setCharacterEncoding("UTF-8"); 68 | // 调用核心业务类接收消息、处理消息 69 | TextMessage textMessage = CoreServiceUtil.processRequest(request); 70 | String respMessage = MessageUtil.textMessageToXml(textMessage); 71 | // 响应消息 72 | PrintWriter out = response.getWriter(); 73 | out.print(respMessage); 74 | out.close(); 75 | Point point = textMessage.getPoint(); 76 | if (point != null) { 77 | try { 78 | String openId = textMessage.getOpenId(); 79 | log.debug("openId:" + openId); 80 | log.debug("service:" + WechatAuthService); 81 | WechatAuth auth = WechatAuthService 82 | .getWechatAuthByOpenId(openId); 83 | log.debug("auth:" + auth); 84 | if (auth == null) { 85 | PersonInfo personInfo = new PersonInfo(); 86 | personInfo.setName(null); 87 | personInfo.setGender(null); 88 | personInfo.setProfileImg(null); 89 | personInfo.setEnableStatus(1); 90 | personInfo.setCustomerFlag(1); 91 | personInfo.setShopOwnerFlag(0); 92 | personInfo.setAdminFlag(0); 93 | auth = new WechatAuth(); 94 | auth.setOpenId(openId); 95 | auth.setPersonInfo(personInfo); 96 | WechatAuthService.register(auth, null); 97 | } 98 | } catch (Exception e) { 99 | log.debug("exception:" + e.getMessage()); 100 | } 101 | } 102 | } catch (UnsupportedEncodingException e) { 103 | e.printStackTrace(); 104 | } catch (IOException e) { 105 | e.printStackTrace(); 106 | } 107 | }*/ 108 | } 109 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://localhost:3306/xqt?useUnicode=true&characterEncoding=utf8 3 | jdbc.username=root 4 | jdbc.password=123456 -------------------------------------------------------------------------------- /MovieRecommend/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=ERROR,Console 2 | 3 | # appender kafka 4 | log4j.appender.kafka.syncSend=false 5 | log4j.appender.kafka=org.apache.kafka.log4jappender.KafkaLog4jAppender 6 | # multiple brokers are separated by comma ",". 7 | log4j.appender.kafka.brokerList=192.168.1.200:9092,192.168.1.201:9092 8 | log4j.appender.kafka.layout=org.apache.log4j.PatternLayout 9 | log4j.appender.kafka.layout.ConversionPattern=%m%n 10 | log4j.appender.kafka.topic=recommending-topic 11 | 12 | #\u8F93\u51FA\u65E5\u5FD7\u5230\u63A7\u5236\u53F0 13 | log4j.appender.Console=org.apache.log4j.ConsoleAppender 14 | log4j.appender.Console.Threshold=all 15 | log4j.appender.Console.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.Console.layout.ConversionPattern= %m%n 17 | 18 | #kafka 19 | log4j.logger.com.xqt.recommend.web.movieadmin.MovieAdminController=info,kafka 20 | #\u5173\u95EDspring\u4F4E\u7EA7\u522B\u65E5\u5FD7 21 | log4j.logger.org.springside.examples.miniweb=ERROR 22 | log4j.logger.com.octo.captcha.service.image.DefaultManageableImageCaptchaService=ERROR 23 | log4j.logger.com.mchange.v2.resourcepool.BasicResourcePool=ERROR 24 | log4j.logger.com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool=ERROR 25 | log4j.logger.com.mchange.v2.c3p0.impl.NewPooledConnection=ERROR 26 | log4j.logger.com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean=ERROR 27 | log4j.logger.com.mchange.v2.c3p0.C3P0Registry=ERROR 28 | log4j.logger.com.mchange.v2.log.MLog=ERROR 29 | log4j.logger.com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource=ERROR -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 我的电影 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 21 | 22 | 23 |
24 |
25 |
26 | 27 | 30 |
31 | 38 |
39 | 40 |
41 |
42 | 43 |
44 |
45 |
46 | 47 | 48 |
49 | 50 | 54 |
55 | 56 |
57 |
58 |
59 |

Action

60 |
61 |
62 | 63 |
64 |
65 | 66 |
67 |
68 |

Comedy

69 |
70 |
71 | 72 |
73 |
74 |
75 |
76 |

Crime

77 |
78 |
79 | 80 |
81 |
82 |
83 |
84 |

Fantasy

85 |
86 |
87 | 88 |
89 |
90 |
91 |
92 |

Musical

93 |
94 |
95 | 96 |
97 |
98 |
99 |
100 |

Romance

101 |
102 |
103 | 104 |
105 |
106 |
107 |
108 |

Thriller

109 |
110 |
111 | 112 |
113 |
114 |
115 |
116 |

War

117 |
118 |
119 | 120 |
121 |
122 |
123 |
124 |
125 | 126 |
127 |
128 |
129 | 130 |

131 | 132 |

133 |

134 | Binding Account 135 |

136 |

137 | Modify Password 138 |

139 |

140 | Sign In 141 |

142 |

143 | Sign Out 144 |

145 |
146 |
147 |
148 | 149 | 151 | 153 | 155 | 157 | 159 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/frontend/moviedetail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 电影详情 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 17 | 18 |
19 |
20 |
21 | 23 | Back 24 | 25 |

Detail

26 | 27 |
28 | 35 |
37 | 38 |
39 |
40 |
42 | 43 |
44 |
45 |
46 |

47 |

48 | Play 49 | 50 |
51 |

52 | Information: 53 |

54 |
55 |
56 | 57 |
58 | 59 | 71 |
72 |
73 | 74 |
75 |
76 |
77 |
78 | 79 | 82 |
83 |
84 | 85 | 86 |
87 |
88 |
89 | 90 |

91 | 92 |

93 |

94 | Binding Account 95 |

96 |

97 | Modify Password 98 |

99 |

100 | Sign In 101 |

102 |

103 | Sign Out 104 |

105 | 106 |
107 |
108 | 109 | 110 | 111 | 113 | 115 | 117 | 119 | 121 | 122 | 123 | 125 | 126 | 128 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/frontend/shoplist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 推荐电影 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 17 | 18 | 19 |
20 |
21 |
22 | Back 25 | 26 |

Recommendations

27 |
28 | 29 | 36 |
38 | 39 |
40 |
41 | 42 |

Movies You Might Like Recently:

43 |
44 | 45 |
46 |
47 |
48 |
49 | 50 |
51 |
52 |
53 | 54 |

55 | 56 |

57 |

58 | Binding Account 59 |

60 |

61 | Modify Password 62 |

63 |

64 | Sign In 65 |

66 |

67 | Sign Out 68 |

69 |
70 |
71 | 72 | 74 | 76 | 78 | 80 | 82 | 83 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/local/accountbind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 微信绑定 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 17 |
18 |

Binding Account

19 |
20 |
21 |
22 |
    23 |
  • 24 |
    25 |
    26 | 27 |
    28 |
    29 |
    30 | 31 |
    32 |
    33 |
    34 |
  • 35 |
  • 36 |
    37 |
    38 | 39 |
    40 |
    41 |
    42 | 43 |
    44 |
    45 |
    46 |
  • 47 |
  • 48 |
    49 |
    50 | 51 |
    52 |
    53 | 56 |
    57 | 点击更换 59 |
    60 |
    61 |
    62 |
  • 63 |
64 |
65 | 66 | 67 |
68 |
69 |
70 | 返回 72 |
73 |
74 | 提交 75 |
76 |
77 |
78 |
79 | 81 | 83 | 85 | 87 | 89 | 90 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/local/changepsw.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 修改密码 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 17 |
18 |
19 |
    20 |
  • 21 |
    22 |
    23 | 24 |
    25 |
    26 |
    27 | 28 |
    29 |
    30 |
    31 |
  • 32 |
  • 33 |
    34 |
    35 | 36 |
    37 |
    38 |
    39 | 40 |
    41 |
    42 |
    43 |
  • 44 |
  • 45 |
    46 |
    47 | 48 |
    49 |
    50 |
    51 | 52 |
    53 |
    54 |
    55 |
  • 56 |
  • 57 |
    58 |
    59 | 60 |
    61 |
    62 |
    63 | 64 |
    65 |
    66 |
    67 |
  • 68 |
  • 69 |
    70 |
    71 | 72 |
    73 |
    74 | 77 |
    78 | 点击更换 80 |
    81 |
    82 |
    83 |
  • 84 | 85 |
86 |
87 |
88 |
89 |
90 | Back 92 |
93 |
94 | Submit 95 |
96 |
97 |
98 |
99 | 101 | 103 | 105 | 107 | 109 | 110 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/local/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 用户登录 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 17 |
18 | Back 21 | 22 |

Sign in

23 |
24 |
25 |
26 |
    27 |
  • 28 |
    29 |
    30 | 31 |
    32 |
    33 |
    34 | 35 |
    36 |
    37 |
    38 |
  • 39 |
  • 40 |
    41 |
    42 | 43 |
    44 |
    45 |
    46 | 47 |
    48 |
    49 |
    50 |
  • 51 | 67 |
68 |
69 | 70 | 71 |
72 |
73 |
74 | Register 76 |
77 |
78 | Sign In 79 |
80 |
81 |
82 |
83 | 85 | 87 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/WEB-INF/html/local/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 注册 7 | 8 | 9 | 10 | 11 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 41 | 42 | 43 | 44 | 51 | 52 | 53 |
54 | Back 57 | 58 |

Register

59 |
60 |
61 |
62 |
    63 |
  • 64 |
    65 |
    66 | 67 |
    68 |
    69 |
    70 | 71 |
    72 |
    73 |
    74 |
  • 75 |
  • 76 |
    77 |
    78 | 79 |
    80 |
    81 |
    82 | 83 |
    84 |
    85 |
    86 |
  • 87 |
  • 88 |
    89 |
    90 | 91 |
    92 |
    93 |
    94 | 95 |
    96 |
    97 |
    98 |
  • 99 |
  • 100 |
    101 |
    102 | 103 |
    104 |
    105 |
    106 | 107 |
    108 |
    109 |
    110 |
  • 111 |
  • 112 |
    113 |
    114 | 115 |
    116 |
    117 |
    118 | 119 |
    120 |
    121 |
    122 |
  • 123 |
  • 124 |
    125 |
    126 |
    127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
    155 |
    156 |
    157 | 158 | 159 |
  • 160 | 161 |
  • 162 |
    163 |
    164 | 165 |
    166 |
    167 | 170 |
    171 | 点击更换 173 |
    174 |
    175 |
    176 |
  • 177 |
178 |
179 | 180 |
181 |
182 |
183 | Back 185 |
186 |
187 | Register 188 |
189 |
190 |
191 | 192 |
193 | 194 | 196 | 198 | 200 | 202 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/css/frontend/index.css: -------------------------------------------------------------------------------- 1 | .index-banner { 2 | height: 35%; 3 | padding-bottom: 0.4rem; 4 | } 5 | .img-wrap { 6 | overflow: hidden; 7 | } 8 | .banner-img { 9 | width: 100%; 10 | height: 100%; 11 | } 12 | .total-movie-button { 13 | height: 60px; 14 | line-height: 1.5rem; 15 | padding-left: 2px; 16 | padding-right: 2px; 17 | margin-bottom: 0.4rem; 18 | margin-top:10px; 19 | position: relative; 20 | cursor: pointer; 21 | align:center 22 | } 23 | .total-shop-button:before { 24 | content: ''; 25 | display: inline-block; 26 | position: absolute; 27 | left: 0; 28 | width: 0.15rem; 29 | height: 1.5rem; 30 | background-color: #0894ec; 31 | } 32 | .movie-classify { 33 | margin-top: 3px; 34 | border-bottom: 2px solid; 35 | border-left: 2px solid; 36 | border-color: rgba(100,100,100,0.5); 37 | border-radius: 7px; 38 | height: 3.3rem; 39 | padding: 0.2rem; 40 | cursor: pointer; 41 | } 42 | .movie-classify > .word { 43 | width: 60%; 44 | height: 100%; 45 | overflow: hidden; 46 | float: left; 47 | font-weight:bold; 48 | } 49 | .movie-classify > .word > p { 50 | margin: 0; 51 | } 52 | .movie-classify > .word > .movie-category-title { 53 | margin-top: 10px; 54 | margin-left: 10px; 55 | font-size: 0.8rem; 56 | } 57 | .movie-classify > .word > .movie-category-desc { 58 | margin: 0; 59 | font-size: 0.4rem; 60 | } 61 | // .movie-classify > .movie-img { 62 | // width: 2.4rem; 63 | // height: 2.4rem; 64 | // margin-left: 0.2rem; 65 | // display: inline-block; 66 | // } 67 | .movie-classify > .movie-classify-img-warp { 68 | width: 34%; 69 | height: 100%; 70 | margin-left: 0.2rem; 71 | display: inline-block; 72 | } 73 | .movie-classify > .movie-classify-img-warp > .movie-img { 74 | width: 100%; 75 | height: 100%; 76 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/css/frontend/moviedetail.css: -------------------------------------------------------------------------------- 1 | .detail-search { 2 | height: 2.2rem; 3 | padding-right: .5rem; 4 | padding-left: .5rem; 5 | background-color: #f7f7f8; 6 | } 7 | .infinite-scroll-preloader { 8 | margin-top: -5px; 9 | } 10 | .moviedetail-button-div { 11 | margin: 0 .3rem; 12 | } 13 | .moviedetail-button-div > .button { 14 | width: 30%; 15 | height: 1.5rem; 16 | line-height: 1.5rem; 17 | display: inline-block; 18 | margin: 1%; 19 | overflow: hidden; 20 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/css/frontend/shoplist.css: -------------------------------------------------------------------------------- 1 | .infinite-scroll-preloader { 2 | margin-top: -5px; 3 | } 4 | .shoplist-button-div { 5 | margin: 0 .3rem; 6 | } 7 | .shoplist-button-div > .button { 8 | width: 30%; 9 | height: 1.5rem; 10 | line-height: 1.5rem; 11 | display: inline-block; 12 | margin: 1%; 13 | overflow: hidden; 14 | } 15 | .select-wrap { 16 | margin: 0 .5rem; 17 | } 18 | .select { 19 | border: 1px solid #0894ec; 20 | color: #0894ec; 21 | background-color: #efeff4; 22 | width: 100%; 23 | height: 1.5rem; 24 | font-size: .7rem; 25 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/css/frontend/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 0; 3 | margin: 0; 4 | font-size: 62.5%; 5 | font-family: Arial, sans-serif; 6 | } 7 | 8 | label { 9 | display: inline; 10 | } 11 | 12 | .holder { 13 | width: 100%; 14 | background: #f9f9f9; 15 | margin: 0px auto; 16 | padding: 0px 0; 17 | font-size: 1em; 18 | } 19 | 20 | .center { 21 | margin: 0px 3px 1px 5px; 22 | } 23 | 24 | input[type="checkbox"] { 25 | display: none; 26 | } 27 | 28 | .top-content { 29 | padding: 40px 0; 30 | } 31 | h1 { 32 | font-size: 3em; 33 | font-family: 'adelle-sans', sans-serif; 34 | text-align: center; 35 | } 36 | 37 | p { 38 | font-size: 2em; 39 | font-family: 'adelle-sans', sans-serif; 40 | text-align: center; 41 | color: #bbb; 42 | } 43 | 44 | /* ==================================================================== */ 45 | /* CHECKBOX TYPE 1 ---------------------------------------------------- */ 46 | /* ==================================================================== */ 47 | 48 | [id^="checkbox-1-"] + label { 49 | background-color: #FFF; 50 | border: 1px solid #C1CACA; 51 | box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05); 52 | padding: 9px; 53 | border-radius: 5px; 54 | display: inline-block; 55 | position: relative; 56 | margin-right: 30px; 57 | } 58 | 59 | [id^="checkbox-1-"] + label:active { 60 | box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px 1px 3px rgba(0,0,0,0.1); 61 | } 62 | 63 | [id^="checkbox-1-"]:checked + label { 64 | background-color: #ECF2F7; 65 | border: 1px solid #92A1AC; 66 | box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05), inset 15px 10px -12px rgba(255, 255, 255, 0.1); 67 | color: #243441; 68 | } 69 | 70 | [id^="checkbox-1-"]:checked + label:after { 71 | content: '\2715'; 72 | position: relative; 73 | top: 16px; 74 | left: 0px; 75 | color: #758794; 76 | width: 100%; 77 | text-align: center; 78 | font-size: 1.4em; 79 | padding: 1px 0 0 0; 80 | vertical-align: text-top; 81 | 82 | } 83 | 84 | #checkbox-1-2 + label { 85 | width: 10px; 86 | height: 10px; 87 | } 88 | 89 | #checkbox-1-3 + label { 90 | width: 20px; 91 | height: 20px; 92 | } 93 | 94 | #checkbox-1-2 + label:after { 95 | left: 0px; 96 | padding: 6px 0 0 0; 97 | } 98 | 99 | #checkbox-1-3 + label:after { 100 | top: -6px; 101 | left: 0px; 102 | padding: 17px 0 0 0; 103 | } -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_action_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_action_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_comedy_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_comedy_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_crime_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_crime_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_fantasy_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_fantasy_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_logo.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_musical_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_musical_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_romance_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_romance_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_star_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_star_off.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_star_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_star_on.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_thriller_movie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_thriller_movie.jpg -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_thriller_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_thriller_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_today_recommendation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_today_recommendation.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_war_movie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_war_movie.jpg -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/images/img_war_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/MovieRecommend/src/main/webapp/resources/images/img_war_movie.png -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/common/common.js: -------------------------------------------------------------------------------- 1 | Date.prototype.Format = function(fmt) { 2 | var o = { 3 | "M+" : this.getMonth() + 1, // 月份 4 | "d+" : this.getDate(), // 日 5 | "h+" : this.getHours(), // 小时 6 | "m+" : this.getMinutes(), // 分 7 | "s+" : this.getSeconds(), // 秒 8 | "q+" : Math.floor((this.getMonth() + 3) / 3), // 季度 9 | "S" : this.getMilliseconds() 10 | // 毫秒 11 | }; 12 | if (/(y+)/.test(fmt)) 13 | fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "") 14 | .substr(4 - RegExp.$1.length)); 15 | for ( var k in o) 16 | if (new RegExp("(" + k + ")").test(fmt)) 17 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) 18 | : (("00" + o[k]).substr(("" + o[k]).length))); 19 | return fmt; 20 | } 21 | /** 22 | * 23 | */ 24 | function changeVerifyCode(img) { 25 | img.src = "../Kaptcha?" + Math.floor(Math.random() * 100); 26 | } 27 | 28 | function getQueryString(name) { 29 | var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); 30 | var r = window.location.search.substr(1).match(reg); 31 | if (r != null) { 32 | return decodeURIComponent(r[2]); 33 | } 34 | return ''; 35 | } 36 | 37 | //toast显示 38 | function showtoastFromDiv(text) { 39 | $('.card').show(); 40 | $('.card').toast({ 41 | content: text, 42 | duration: 1000 43 | }) 44 | setTimeout(() => { 45 | $('.toast_div').hide(); 46 | }, 2000); 47 | } 48 | 49 | //服务器地址 50 | var serverAddr = ""; 51 | 52 | //设置用户登录状态 53 | var userName = localStorage.getItem("userName"); 54 | if(userName){ 55 | $('#login-state').html("hello, "+userName); 56 | $('#signin').hide(); 57 | $('#signout').show(); 58 | }else{ 59 | $('#login-state').html("sign in please") 60 | $('#signin').show(); 61 | $('#signout').hide(); 62 | } 63 | 64 | //sign out 绑定事件 65 | var signoutUrl="/MovieRecommend/local/logout" 66 | $('#signout').click(function() { 67 | //$.openPanel('#panel-right-demo'); 68 | $.ajax({ 69 | url : signoutUrl, 70 | cache : false, 71 | type : 'post', 72 | dataType:'json', 73 | data : { 74 | }, 75 | success : function(data) { 76 | if (data.success) { 77 | $.toast('sign out succeed!'); 78 | localStorage.removeItem("userId"); 79 | localStorage.removeItem("userName"); 80 | setTimeout(function(){window.location.href='/MovieRecommend/frontend/index';},2000) ; 81 | } else { 82 | $.toast('sign out failed!'+data.errMsg); 83 | $('#captcha_img').click(); 84 | } 85 | } 86 | }); 87 | }); 88 | 89 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/frontend/index.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | //定义访问后台,获取头条列表以及一级类别列表的URL 3 | var url = '/MovieRecommend/movieadmin/gethottestmovie'; 4 | //访问后台,获取头条列表以及一级类别列表 5 | $.getJSON(url, function(data) { 6 | if (data.success) { 7 | //获取后台传递过来的头条列表 8 | var headLineList = data.top5Moive; 9 | var swiperHtml = ''; 10 | //遍历头条列表,并拼接出轮播图组 11 | headLineList.map(function(item, index) { 12 | swiperHtml += '' + '
' 13 | + '' + '
'; 16 | }); 17 | //将轮播图组赋值给前端HTML控件 18 | $('.swiper-wrapper').html(swiperHtml); 19 | //设定轮播图轮换时间为3秒 20 | $(".swiper-container").swiper({ 21 | autoplay : 3000, 22 | //用户对轮播图进行操作时,是否自动停止autoplay 23 | autoplayDisableOnInteraction : false 24 | }); 25 | } 26 | }); 27 | 28 | //若点击"我的",则显示侧栏 29 | $('#me').click(function() { 30 | $.openPanel('#panel-right-demo'); 31 | }); 32 | 33 | // 电影分类区域点击之后,响应的事件 34 | $('.row').on('click', '.movie-classify', function(e) { 35 | var movieCategoryId = e.currentTarget.dataset.category; 36 | var newUrl = serverAddr+'/MovieRecommend/frontend/shoplist?categoryId=' + movieCategoryId; 37 | window.location.href = newUrl; 38 | }); 39 | 40 | }); 41 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/frontend/moviedetail.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // 从地址栏里获取movieId和categoryId 4 | var Request = new Object(); 5 | Request = GetRequest(); 6 | var hottestMovieId = Request["hottestMovieId"]; 7 | var movieId = Request["movieId"]; 8 | 9 | //如果hottestMovieId不为null,说明从首页轮播图跳转过来 10 | //需要将评分部分隐藏 11 | if(hottestMovieId){ 12 | $('#star').hide(); 13 | $('#submitRating').hide(); 14 | }else{ 15 | $('#star').show(); 16 | $('#submitRating').show(); 17 | } 18 | 19 | 20 | var url = serverAddr+'/MovieRecommend/movieadmin/gethottestmovieinfo?hottestMovieId='+hottestMovieId; 21 | getHottestMovieId(url); 22 | 23 | 24 | //设置变量值,标明在推荐(离线,实时)两部分中,点击哪一个部分的卡片进行跳转到moviedetail页面 25 | var offline = false; 26 | 27 | //从localStorage中获取电影的详细信息 28 | var strOffline = localStorage.getItem('data'); 29 | if(strOffline){ 30 | var data = JSON.parse(strOffline); 31 | if(data.success){ 32 | var movieList = data.movieList; 33 | movieList.map(function(item, index) { 34 | if(item){ 35 | if(item.movieId == movieId){ 36 | offline = true; 37 | $('#movie-image').attr('src', item.movieImgAddr); 38 | $('#movie-name').html(item.movieName); 39 | $('#movie-info').html(item.movieInfo); 40 | $('#movie-play-url').attr('href',item.moviePlayUrl); 41 | $('#movie-release-time').html("上映时间:"+item.releaseTime); 42 | } 43 | } 44 | }); 45 | } 46 | } 47 | 48 | //如果离线数据中没有该movieId, 则在实时推荐的数据中寻找 49 | if(!offline){ 50 | var strOnline = localStorage.getItem('realTimeData'); 51 | if(strOnline){ 52 | var data = JSON.parse(strOnline); 53 | if(data.success){ 54 | var movieList = data.movieList; 55 | movieList.map(function(item, index) { 56 | if(item){ 57 | if(item.movieId == movieId){ 58 | $('#movie-image').attr('src', item.movieImgAddr); 59 | $('#movie-name').html(item.movieName); 60 | $('#movie-info').html(item.movieInfo); 61 | $('#movie-play-url').attr('href',item.moviePlayUrl); 62 | $('#movie-release-time').html("上映时间:"+item.releaseTime); 63 | } 64 | } 65 | }); 66 | } 67 | } 68 | } 69 | 70 | 71 | //从localStorage中获取userId 72 | //如果获取得到,说明用户处在登录状态 73 | //获取不到,说明当前处在游客模式 74 | var userId = localStorage.getItem("userId"); 75 | 76 | 77 | // 获取综合电影详细信息,json格式 78 | function getHottestMovieId(url) { 79 | $.getJSON( 80 | url, 81 | function(data) { 82 | if (data.success) { 83 | var movieInfo = data.movieInfo; 84 | $('#movie-image').attr('src', movieInfo.movieImgAddr); 85 | $('#movie-name').html(movieInfo.movieName); 86 | $('#movie-info').html(movieInfo.movieInfo); 87 | $('#movie-play-url').attr('href',movieInfo.moviePlayUrl); 88 | $('#movie-release-time').html("Release Time :"+movieInfo.releaseTime); 89 | } 90 | }); 91 | } 92 | 93 | //星级评分 94 | $('#star').raty({ 95 | width: 210, 96 | starOn: '../resources/images/img_star_on.png', 97 | starOff: '../resources/images/img_star_off.png', 98 | }); 99 | 100 | 101 | //从url中获取传递过来的movieId和categoryId 102 | function GetRequest() { 103 | var url = location.search; //获取url中"?"符后的字串 104 | var theRequest = new Object(); 105 | if (url.indexOf("?") != -1) { 106 | var str = url.substr(1); 107 | strs = str.split("&"); 108 | for(var i = 0; i < strs.length; i ++) { 109 | theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 110 | } 111 | } 112 | return theRequest; 113 | } 114 | 115 | //提交评分按钮事件绑定 116 | $('#submitRating').click(function(){ 117 | if(!userId){ 118 | alert("please sign in first!"); 119 | }else{ 120 | //获取用户的评分 121 | //将userId, movieId, rate, timestamp传递到后台 122 | jQuery("#star input[type='hidden']").each(function(){ 123 | var registerUrl="/MovieRecommend/movieadmin/usermovierate"; 124 | var rate = $(this).val(); 125 | $.ajax({ 126 | url : registerUrl, 127 | cache : false, 128 | type : 'post', 129 | dataType:'json', 130 | data : { 131 | userId:userId, 132 | movieId:movieId, 133 | rate:rate, 134 | }, 135 | success : function(data) { 136 | if (data.success) { 137 | alert("rating succeed!"); 138 | } else { 139 | alert("rating failed!"); 140 | $('#captcha_img').click(); 141 | } 142 | } 143 | }); 144 | }); 145 | } 146 | }); 147 | 148 | // 点击后打开右侧栏 149 | $('#me').click(function() { 150 | $.openPanel('#panel-right-demo'); 151 | }); 152 | // $.init(); 153 | }); 154 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/frontend/shoplist.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | var userId = localStorage.getItem("userId"); 4 | 5 | // 从地址栏URL里尝试获取电影 categoryId. 6 | var categoryId = getQueryString('categoryId'); 7 | if(categoryId>=1 && categoryId<=8){ 8 | //有categoryId,说明是从电影分类表中获取电影 9 | addCategoryItems(categoryId); 10 | //将 标签 (Movies You Might Like Recently:) 隐藏 11 | $('#real-time-label').hide(); 12 | }else{ 13 | //没有categoryId 14 | if(userId){ 15 | //如果userId不为null,说明当前处在用户以登录状态,需要从推荐电影表中读取为用户推荐的电影 16 | addItemsForUser(userId); 17 | addItemsRealTimeForUser(userId); 18 | }else{ 19 | //userId为null, 说明当前处在游客状态,需要从综合电影表中读取电影 20 | addItems(); 21 | $('#real-time-label').hide(); 22 | } 23 | } 24 | 25 | /** 26 | * 添加综合电影列表,用户登录模式中的今日推荐,为用户推荐电影 27 | * 离线推荐部分 28 | */ 29 | function addItemsRealTimeForUser(userId) { 30 | // 获取json数据的url 31 | var url = serverAddr+"/MovieRecommend/movieadmin/getrecommendmovie?userId="+userId; 32 | 33 | //开始获取json数据 34 | $.getJSON(url, function(data) { 35 | if (data.success) { 36 | var movieList = data.movieList; 37 | var html = ''; 38 | // 遍历json中电影list,拼接出卡片集合 39 | movieList.map(function(item, index) { 40 | if(item){ 41 | html += '' + '
' + '
' 43 | + item.movieName + '
' 44 | + '
' 45 | + '
' + '
    ' 46 | + '
  • ' 47 | + '
    ' + '' + '
    ' 49 | + '
    ' 50 | + '
    ' + item.movieInfo 51 | + '
    ' + '
    ' + '
  • ' + '
' 52 | + '
' + '
'+ '' 56 | + '
'; 57 | } 58 | }); 59 | 60 | // 将卡片集合添加到目标HTML组件里 61 | $('.list-div').append(html); 62 | 63 | saveJsonAsLocalStorage(data); 64 | } 65 | }); 66 | } 67 | 68 | /** 69 | * 为用户试实时推荐电影 70 | */ 71 | function addItemsForUser(userId) { 72 | // 获取json数据的url 73 | var url = serverAddr+"/MovieRecommend/movieadmin/getrecommendmovierealtime?userId="+userId; 74 | 75 | //开始获取json数据 76 | $.getJSON(url, function(data) { 77 | if (data.success) { 78 | var movieList = data.movieList; 79 | var html = ''; 80 | // 遍历json中电影list,拼接出卡片集合 81 | movieList.map(function(item, index) { 82 | if(item){ 83 | html += '' + '
' + '
' 85 | + item.movieName + '
' 86 | + '
' 87 | + '
' + '
    ' 88 | + '
  • ' 89 | + '
    ' + '' + '
    ' 91 | + '
    ' 92 | + '
    ' + item.movieInfo 93 | + '
    ' + '
    ' + '
  • ' + '
' 94 | + '
' + '
'+ '' 98 | + '
'; 99 | } 100 | 101 | }); 102 | 103 | // 将卡片集合添加到目标HTML组件里 104 | $('.list-div-realtime').append(html); 105 | 106 | //由于与离线推荐部相冲突,需要重新存储 107 | var str = JSON.stringify(data); 108 | localStorage.setItem("realTimeData",str); 109 | } 110 | }); 111 | } 112 | 113 | /** 114 | * 添加综合电影列表,电影不分类,游客模式中的今日推荐 115 | * 116 | */ 117 | function addItems() { 118 | // 获取json数据的url 119 | var url = serverAddr+"/MovieRecommend/movieadmin/top10movie"; 120 | 121 | //开始获取json数据 122 | $.getJSON(url, function(data) { 123 | if (data.success) { 124 | var movieList = data.movieList; 125 | var html = ''; 126 | // 遍历json中电影list,拼接出卡片集合 127 | movieList.map(function(item, index) { 128 | html += '' + '
' + '
' 130 | + item.movieName + '
' 131 | + '
' 132 | + '
' + '
    ' 133 | + '
  • ' 134 | + '
    ' + '' + '
    ' 136 | + '
    ' 137 | + '
    ' + item.movieInfo 138 | + '
    ' + '
    ' + '
  • ' + '
' 139 | + '
' + '
'+ '' 143 | + '
'; 144 | }); 145 | 146 | // 将卡片集合添加到目标HTML组件里 147 | $('.list-div').append(html); 148 | 149 | 150 | saveJsonAsLocalStorage(data); 151 | } 152 | }); 153 | } 154 | 155 | /** 156 | * 根据传入的categoryId,选择添加不同种类的电影 157 | */ 158 | function addCategoryItems(categoryId) { 159 | // 获取json数据的url 160 | var url = serverAddr+"/MovieRecommend/movieadmin/getmoviebycategory?categoryId="+categoryId; 161 | 162 | //开始获取json数据 163 | $.getJSON(url, function(data) { 164 | if (data.success) { 165 | var movieList = data.movieList; 166 | var html = ''; 167 | // 遍历json中电影list,拼接出卡片集合 168 | movieList.map(function(item, index) { 169 | if(item){ 170 | html += '' + '
' + '
' 172 | + item.movieName + '
' 173 | + '
' 174 | + '
' + '
    ' 175 | + '
  • ' 176 | + '
    ' + '' + '
    ' 178 | + '
    ' 179 | + '
    ' + item.movieInfo 180 | + '
    ' + '
    ' + '
  • ' + '
' 181 | + '
' + '
'+ '' 185 | + '
'; 186 | } 187 | 188 | }); 189 | 190 | // 将卡片集合添加到目标HTML组件里 191 | $('.list-div').append(html); 192 | 193 | saveJsonAsLocalStorage(data); 194 | } 195 | }); 196 | } 197 | 198 | 199 | //将json转换成字符串 200 | //存储到cookie中 201 | function saveJsonAsLocalStorage(data){ 202 | var str = JSON.stringify(data); 203 | localStorage.setItem("data", str); 204 | } 205 | 206 | // 点击卡片进入该电影的详情页 207 | $('.shop-list').on('click', '.card', function(e) { 208 | var movieId = e.currentTarget.dataset.shopId; 209 | //从LocalStorage中读取数据,只需要将movieId进行传递 210 | window.location.href = serverAddr+'/MovieRecommend/frontend/moviedetail?movieId=' + movieId; 211 | }); 212 | 213 | //若点击"我的",则显示侧栏 214 | $('#me').click(function() { 215 | $.openPanel('#panel-right-demo'); 216 | }); 217 | 218 | // 初始化页面 219 | $.init(); 220 | }) 221 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/local/accountbind.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var bindUrl='/xqt/local/bindlocalauth'; 3 | //var usertype=getQueryString('usertype'); 4 | $('#submit').click(function(){ 5 | $.toast("click"); 6 | var userName=$('#username').val(); 7 | var password=$('#pwd').val(); 8 | var verifyCodeActual=$('#j_captcha').val(); 9 | var needVertify=false; 10 | alert(password); 11 | if(!verifyCodeActual){ 12 | $.toast("请输入验证码"); 13 | return; 14 | } 15 | $.ajax({ 16 | url:bindUrl, 17 | async:false, 18 | cache:false, 19 | type:"post", 20 | dataType:'json', 21 | data:{ 22 | userName:userName, 23 | password:password, 24 | verifyCodeActual:verifyCodeActual 25 | }, 26 | success:function(data){ 27 | if(data.success){ 28 | $.toast("绑定成功!"); 29 | window.location.href='/xqt/frontend/index'; 30 | /*if(usertype==1){ 31 | window.location.href='/xqt/frontend/index'; 32 | }else{ 33 | window.location.href='/xqt/shopadmin/shoplist'; 34 | }*/ 35 | }else{ 36 | $.toast("提交失败!"+data.errMsg); 37 | $('#captcha_img').click(); 38 | } 39 | } 40 | }); 41 | }); 42 | }); -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/local/changepsw.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var url='/local/changelocalpwd'; 3 | //var usertype=getQueryString('usertype'); 4 | $('#submit').click(function(){ 5 | 6 | var userName=$('#userName').val(); 7 | var password=$('#password').val(); 8 | var newPassword=$('#newPassword').val(); 9 | var confirmPassword=$('#confirmPassword').val(); 10 | if(newPassword!=confirmPassword){ 11 | $.toast('两次输入的新密码不一致'); 12 | return; 13 | } 14 | var formData=new FormData(); 15 | formData.append('userName',userName); 16 | formData.append('password',password); 17 | formData.append('newPassword',newPassword); 18 | var verifyCodeActual=$('#j_captcha').val(); 19 | if(!verifyCodeActual){ 20 | $.toast('请输入验证码'); 21 | return; 22 | } 23 | 24 | formData.append('verifyCodeActual',verifyCodeActual); 25 | $.ajax({ 26 | url:url, 27 | type:'POST', 28 | data:formData, 29 | contentType:false, 30 | processData:false, 31 | cache:false, 32 | success:function(data){ 33 | if(data.success){ 34 | $.toast('提交成功!'); 35 | setTimeout("window.location.href='/frontend/index'",1000); 36 | 37 | }else{ 38 | $.toast("提交失败!"+data.errMsg); 39 | $('#captcha_img').click(); 40 | } 41 | } 42 | }); 43 | }); 44 | $('#back').click(function(){ 45 | window.location.href='/frontend/index'; 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/local/login.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var loginUrl=serverAddr+'/MovieRecommend/local/logincheck'; 3 | 4 | var loginCount=0; 5 | 6 | $('#register').click(function(){ 7 | window.location.href='/MovieRecommend/local/register'; 8 | }) 9 | $('#submit').click(function(){ 10 | var userName=$('#username').val(); 11 | var password =$('#pwd').val(); 12 | var verifyCodeActual=$('#j_captcha').val(); 13 | var needVerify=false; 14 | 15 | if(loginCount>=3){ 16 | if(!verifyCodeActual){ 17 | $.toast('please input vertification code!'); 18 | }else{ 19 | needVerify=true; 20 | } 21 | } 22 | $.ajax({ 23 | url:loginUrl, 24 | async:false, 25 | cache:false, 26 | type:"post", 27 | dataType:'json', 28 | data:{ 29 | userName:userName, 30 | password:password, 31 | verifyCodeActual:verifyCodeActual, 32 | needVerify:needVerify 33 | }, 34 | success:function(data){ 35 | if(data.success){ 36 | // $.toast('登录成功!'); 37 | alert('sign in succeed!'); 38 | //登录成功之后,将userId存储在本地,以表明当前处在用户登录状态 39 | localStorage.setItem("userId",data.userId); 40 | localStorage.setItem("userName",data.userName); 41 | var Id = localStorage.getItem("userId"); 42 | setTimeout("window.location.href='/MovieRecommend/frontend/index'",1000); 43 | }else{ 44 | // $.toast('登录失败!'); 45 | alert('sign in failed!'); 46 | loginCount++; 47 | if(loginCount>=3){ 48 | $('#verifyPart').show(); 49 | } 50 | } 51 | } 52 | }); 53 | }); 54 | }); -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/local/logout.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | $('#log-out').click(function(){ 3 | $.ajax({ 4 | url:'/xqt/local/logout', 5 | type:"post", 6 | async:false, 7 | cache:false, 8 | dataType:'json', 9 | success:function(data){ 10 | if(data.success){ 11 | var usertype=$("#log-out").attr("usertype"); 12 | /*window.location.href="/xqt/local/login?usertype="+usertype;*/ 13 | window.location.href="/xqt/local/login"; 14 | return false; 15 | } 16 | }, 17 | error:function(data,error){ 18 | alert(error); 19 | } 20 | }); 21 | }); 22 | }); -------------------------------------------------------------------------------- /MovieRecommend/src/main/webapp/resources/js/local/register.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | var registerUrl = '/MovieRecommend/local/registercheck'; 4 | 5 | $('#back').click(function() { 6 | window.location.href='/MovieRecommend/local/login'; 7 | }); 8 | 9 | 10 | $('#submit').click(function() { 11 | //获取用户填写的信息 12 | var userName=$.trim($('#userName').val()); 13 | var password=$.trim($('#password').val()); 14 | var confirmPassword=$.trim($('#confirmPassword').val()); 15 | var email = $.trim($('#email').val()); 16 | var verifyCodeActual = $('#j_captcha').val(); 17 | 18 | //获取复选框--用户喜欢的电影种类 19 | var chk_perefence=new Array(); 20 | $('input[name="interest"]:checked').each(function(){ 21 | chk_perefence.push($(this).val());//向数组中添加元素 22 | }); 23 | var perefenceStr=chk_perefence.join(',');//将数组元素连接起来以构建一个字符串 24 | 25 | if (!userName) { 26 | $.toast('请输入用户名!'); 27 | return; 28 | } 29 | if (!password) { 30 | $.toast('请输入密码!'); 31 | return; 32 | } 33 | if (password != confirmPassword) { 34 | $.toast('两次输入的密码不一致'); 35 | return; 36 | } 37 | if (!email) { 38 | $.toast('请输入email'); 39 | return; 40 | } 41 | var reg = /\w+[@]{1}\w+[.]\w+/; 42 | if(!reg.test(email)){ 43 | $.toast('email格式不正确'); 44 | return; 45 | } 46 | 47 | 48 | if (!verifyCodeActual) { 49 | $.toast('请输入验证码!'); 50 | return; 51 | } 52 | 53 | //向后台 /local/registercheck 54 | //发送用户填写的信息 55 | $.ajax({ 56 | url : registerUrl, 57 | cache : false, 58 | type : 'post', 59 | dataType:'json', 60 | data : { 61 | userName:userName, 62 | password:password, 63 | email:email, 64 | gender:null, 65 | verifyCodeActual:verifyCodeActual, 66 | perefenceStr:perefenceStr 67 | }, 68 | success : function(data) { 69 | if (data.success) { 70 | $.toast('提交成功!'); 71 | setTimeout(function(){window.location.href='/MovieRecommend/frontend/index';},2000) ; 72 | 73 | 74 | } else { 75 | $.toast('提交失败!'+data.errMsg); 76 | $('#captcha_img').click(); 77 | } 78 | } 79 | }); 80 | }); 81 | 82 | 83 | }); 84 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.test.context.ContextConfiguration; 5 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 6 | 7 | /** 8 | * 9 | * 配置spring和junit整合,junit启动时加载springIOC容器 10 | * 11 | */ 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | //告诉junit spring配置文件的位置 14 | @ContextConfiguration({ "classpath:spring/spring-dao.xml", "classpath:spring/spring-service.xml"}) 15 | public class BaseTest { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/ActionMovieDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Ignore; 6 | import org.junit.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import com.xqt.recommend.BaseTest; 10 | import com.xqt.recommend.entity.ActionMovie; 11 | 12 | public class ActionMovieDaoTest extends BaseTest{ 13 | 14 | @Autowired 15 | private ActionMovieDao actionMovieDao; 16 | 17 | @Test 18 | // @Ignore 19 | public void testSelectBytableInnerId() { 20 | List actionMovies = actionMovieDao.selectBytableInnerId(100); 21 | for(ActionMovie actionMovie:actionMovies) { 22 | System.out.println(actionMovie.getMovieName()); 23 | } 24 | } 25 | 26 | @Test 27 | @Ignore 28 | public void testCount() { 29 | System.out.println(actionMovieDao.count()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/HottestMovieDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import org.junit.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | import com.xqt.recommend.BaseTest; 7 | import com.xqt.recommend.entity.HottestMovie; 8 | 9 | public class HottestMovieDaoTest extends BaseTest{ 10 | 11 | @Autowired 12 | private HottestMovieDao hottestMovieDao; 13 | 14 | @Test 15 | public void testSelectMovieById() { 16 | HottestMovie hottestMovie = hottestMovieDao.selectMovieById(1); 17 | System.out.println(hottestMovie.getMovieName()); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/MovieDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Ignore; 6 | import org.junit.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import com.xqt.recommend.BaseTest; 10 | import com.xqt.recommend.entity.Movie; 11 | 12 | public class MovieDaoTest extends BaseTest{ 13 | 14 | @Autowired 15 | private MovieDao movieDao; 16 | 17 | @Test 18 | @Ignore 19 | public void testSelectTop10Movie() { 20 | List movies = movieDao.selectTop10Movie(); 21 | for(Movie movie:movies) { 22 | System.out.println(movie.getReleaseTime()); 23 | } 24 | } 25 | 26 | @Test 27 | public void testSelectMovieById() { 28 | Movie movie = movieDao.selectMovieById(1); 29 | System.out.println(movie.getMovieName()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/RecommenMovieRealTimeDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | import com.xqt.recommend.entity.RecommendMovieRealTime; 10 | 11 | public class RecommenMovieRealTimeDaoTest extends BaseTest{ 12 | 13 | @Autowired 14 | private RecommendMovieRealTimeDao recommendMovieRealTimeDao; 15 | 16 | @Test 17 | public void testSelectMovieByUserId() { 18 | List movieList= recommendMovieRealTimeDao.selectMovieByUserId(1); 19 | System.out.println("=============================================="+movieList.size()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/RecommendMovieDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | 10 | public class RecommendMovieDaoTest extends BaseTest{ 11 | 12 | @Autowired 13 | private RecommendMovieDao recommendMovieDao; 14 | 15 | @Test 16 | public void testGetMovieIdListByUserId() { 17 | List movieIdList = recommendMovieDao.getMovieIdListByUserId(1); 18 | for(int i:movieIdList) { 19 | System.out.println(i); 20 | } 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/TestUserMovieRecordDao.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.Date; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | import com.xqt.recommend.entity.UserMovieRecord; 10 | 11 | public class TestUserMovieRecordDao extends BaseTest{ 12 | 13 | @Autowired 14 | private UserMovieRecordDao userMovieRecordDao; 15 | 16 | @Test 17 | public void testInsert() { 18 | UserMovieRecord userMovieRecord = new UserMovieRecord(); 19 | 20 | userMovieRecord.setUserId(100); 21 | userMovieRecord.setMovieId(100); 22 | userMovieRecord.setUserMovieRate(5); 23 | userMovieRecord.setRecordTimestamp(new Date()); 24 | 25 | int colum = userMovieRecordDao.insert(userMovieRecord); 26 | System.out.println(colum); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/dao/UserDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | import com.xqt.recommend.entity.User; 10 | 11 | public class UserDaoTest extends BaseTest{ 12 | 13 | @Autowired 14 | private UserDao userDao; 15 | 16 | @Test 17 | public void testQueryUser() { 18 | List userList = userDao.queryUser(); 19 | for(User user:userList) { 20 | System.out.println(user.getUserName()); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/service/RecommendMovieRealTimeServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | import com.xqt.recommend.entity.Movie; 10 | 11 | public class RecommendMovieRealTimeServiceTest extends BaseTest{ 12 | 13 | @Autowired 14 | private RecommendMovieRealTimeService realTimeService; 15 | 16 | @Test 17 | public void test() { 18 | List movieInfoRealTime = realTimeService.getMovieInfoRealTime(1); 19 | for(Movie movie:movieInfoRealTime) { 20 | System.out.println(movie.getMovieName()); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/service/RecommendMovieServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | import com.xqt.recommend.entity.Movie; 10 | 11 | public class RecommendMovieServiceTest extends BaseTest{ 12 | 13 | @Autowired 14 | private RecommendMovieService recommendMovieService; 15 | 16 | @Test 17 | public void testGetMovieById() { 18 | List movieList = recommendMovieService.getMovieByUserId(2); 19 | for(Movie movie:movieList) { 20 | System.out.println(movie.getMovieId()+"-"+movie.getMovieName()); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MovieRecommend/src/test/java/com/xqt/recommend/service/UserServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.xqt.recommend.service; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.xqt.recommend.BaseTest; 9 | import com.xqt.recommend.entity.User; 10 | 11 | public class UserServiceTest extends BaseTest { 12 | 13 | @Autowired 14 | private UserService userService; 15 | 16 | @Test 17 | public void testGetUserList() { 18 | List userList = userService.getUserList(); 19 | for(User user:userList) { 20 | System.out.println(user.getUserName()); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # :art:大数据过滤推荐引擎 2 | 3 | ## 项目名称 4 | 5 | EasyLooking(电影轻松看) 6 | 7 | ## 简介 8 | 9 | 本项目是基于大数据技术,对用户所点击的电影类型进行分析,通过所得数据帮助用户自动推荐符合用户喜好的电影类型,系统包括**电影推荐引擎**和 **电影网站(前后端)** 两大部分——EasyLooking。 10 | 11 | 本项目是来自于在2018.3~2018.4期间在[东南大学](http://www.seu.edu.cn/)软件学院研究生的实训。 12 | 13 |
14 | 15 |
16 | 17 | 该项目**使用Spark通过已经获得到的所有会员电影的评分数据集,来推断每个会员的喜好**,并向会员推荐合适的电影,同时也可以将电影推荐给感兴趣的用户,达到个性化的推荐效果,以此来达到增加会员,提高营业的收入的目的。 18 | 19 | ## 技术栈 20 | 21 | - Java,Scala 22 | - Hadoop,Spark ,MySQL 23 | - SpringMVC,Spring,MyBatis 24 | 25 | ## 项目整体架构 26 | 27 |
28 | 29 |
30 | 31 | ## 一、:zap:电影推荐引擎 32 | 33 | ### 开发环境: 34 | 35 | - IntelliJ IDEA 36 | - Maven 37 | 38 | ### 技术栈: 39 | 40 | - Spark+SparkStreaming 41 | - Scala 42 | 43 | ### 架构: 44 | 45 |
46 | 47 |
48 | 49 | ## 二、:hammer:电影网站 50 | 51 | ### 开发环境: 52 | 53 | - IntelliJ IDEA 54 | - Maven 55 | 56 | ### 技术栈: 57 | 58 | - SpringMVC+Spring+MyBatis 59 | - MySQL 60 | 61 | ### 架构: 62 | 63 |
64 | 65 |
66 | 67 | ## :apple: 效果展示 68 | 69 | ### 登陆界面: 70 | 71 |
72 | 73 |
74 | 75 | ### 主页面: 76 | 77 |
78 | 79 |
80 | 81 | ## :pencil: 分析 82 | 83 | ### 离线推荐 84 | 85 | 离线推荐部分采用[协同过滤算法(ALS)](http://dblab.xmu.edu.cn/blog/1461-2/),根据**用户的喜好推荐**和**根据电影的相似度推荐**两个部分。 86 | 87 | ### 实时推荐 88 | 89 | 利用SparkStreaming+Kafka的架构用流计算的方式来分析数据,其中分析的方法是: 90 | 91 | - 给待评分电影设置的基础优先级 92 | - 高分电影的奖励因子 93 | - 低分电影的惩罚因子 94 | 95 | ### 评估 96 | 97 | 利用[RMES(均方根误差)](https://baike.baidu.com/item/%E5%9D%87%E6%96%B9%E6%A0%B9%E8%AF%AF%E5%B7%AE/3498959?fromtitle=RMSE&fromid=6536667)的方式来评估推荐的结果。其中包含以下几个影响因子: 98 | 99 | - 秩 100 | 101 | - 迭代次数 102 | 103 | - 正则系数 104 | 105 | 106 |
107 | 108 |
109 | 110 | ## 参与人员 111 | 112 | - 113 | ​ 114 | 115 | - 116 | ​ 117 | 118 | ## 参考资料 119 | 120 | - [Spark ALS文档](https://spark.apache.org/docs/2.2.0/ml-collaborative-filtering.html) 121 | - [基于协同过滤算法的电影个性化推荐系统设计与实现](http://www.cnki.com.cn/Article/CJFDTotal-RJDK201501033.htm) 122 | 123 | -------------------------------------------------------------------------------- /img/img001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/img001.png -------------------------------------------------------------------------------- /img/img002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/img002.png -------------------------------------------------------------------------------- /img/img003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/img003.png -------------------------------------------------------------------------------- /img/img004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/img004.png -------------------------------------------------------------------------------- /img/img005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/img005.png -------------------------------------------------------------------------------- /img/img006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/img006.png -------------------------------------------------------------------------------- /img/logo01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanLu1024/sundayMovies/8fccb2b542dce04ee6ec84650dc84fe5681c95f0/img/logo01.png -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/DataCleaning/countType.scala: -------------------------------------------------------------------------------- 1 | package DataCleaning 2 | 3 | /** 4 | * 统计电影的种类 5 | */ 6 | 7 | import scala.collection.mutable 8 | 9 | object countType { 10 | val s = scala.collection.mutable.Set("") 11 | def count(arr:Array[String]): mutable.Set[String] ={ 12 | for(i <- arr){ 13 | s += i 14 | } 15 | s 16 | } 17 | def main(args: Array[String]): Unit = { 18 | val arr = splitMovie.splitM(args(0)) 19 | for(i <- arr){ 20 | count(i._4) 21 | } 22 | for(i <- s){ 23 | println(i) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/DataCleaning/splitDataSet.scala: -------------------------------------------------------------------------------- 1 | package DataCleaning 2 | 3 | /** 4 | * 将数据集切分为训练集,测试解,验证集 5 | */ 6 | 7 | import Logger.LoggerLevels 8 | import org.apache.spark.{SparkConf, SparkContext} 9 | 10 | object splitDataSet { 11 | 12 | def main(args: Array[String]): Unit = { 13 | 14 | LoggerLevels.setStreamingLogLevels() 15 | //创建SparkConf()并设置 16 | val conf = new SparkConf().setAppName("splitDataSet").setMaster("local[4]") 17 | //创建sparkContext,该对象是提交spark App的入门 18 | val sc = new SparkContext(conf) 19 | 20 | //使用sc创建RDD并执行相应的transformation和action 21 | val ratings = sc.textFile(args(0)).map { 22 | 23 | line =>{ 24 | try{ 25 | val fields = line.split(",") 26 | // format: (timestamp % 10, Rating(userId, movieId, rating)) 27 | (fields(0).toInt,fields(1).toInt,fields(2).toDouble,fields(3).toLong%10) 28 | }catch { 29 | case e:Exception => (0, 0 ,0.toDouble ,0.toLong%10 ) 30 | } 31 | } 32 | } 33 | 34 | val training=ratings.filter(x=>x._4<6&&x._1!=0 ).saveAsTextFile(args(1)) 35 | val validation= ratings.filter(x=>x._4>=6&&x._4<8&&x._1!=0).saveAsTextFile(args(2)) 36 | val test=ratings.filter(x=>x._4>=8&&x._1!=0).saveAsTextFile(args(3)) 37 | 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/DataCleaning/splitMovie.scala: -------------------------------------------------------------------------------- 1 | package DataCleaning 2 | 3 | /** 4 | * 用于将电影的数据集进行清洗,由于数据有不规整的部分,需要将数据变成规整的数据集 5 | */ 6 | 7 | import Logger.LoggerLevels 8 | import org.apache.spark.{SparkConf, SparkContext} 9 | 10 | object splitMovie { 11 | def splitM(path:String): Array[(Int,String, Int,Array[String])] ={ 12 | LoggerLevels.setStreamingLogLevels() 13 | //创建SparkConf()并设置 14 | val conf = new SparkConf().setAppName("splitMovie").setMaster("local[4]") 15 | //创建sparkContext, 该对象是提交spark App的入门 16 | val sc = new SparkContext(conf) 17 | //使用sc创建RDD并执行相应的transformation和action 18 | val rawData = sc.textFile(path) 19 | 20 | 21 | val rawMovie = rawData.map(_.split(",")) 22 | println(rawData.count()) 23 | 24 | //形成一个tag数组 25 | //val tags = rawMovie.map{case Array(movieId, movie, movieType) => Tag(movieId.toInt, movie.toString, ))} 26 | val movie = rawMovie.map(line => { 27 | if(line.length == 3){ 28 | //获取电影类型 29 | var fields = line(2).split("\\|") 30 | 31 | try{ 32 | var middle = line(1).split("\\(") 33 | var date = middle(middle.length-1).substring(0,4) 34 | var movie = line(1).substring(0, line(1).length-7) 35 | (line(0).toInt, movie, date.toInt, fields) 36 | }catch { 37 | case e:Exception =>{ 38 | (line(0).toInt, line(1), 0, fields) 39 | } 40 | } 41 | 42 | }else{ 43 | println(line(0).toInt) 44 | var fields = line(line.length-1).split("\\|") 45 | try{ 46 | var middle = line(line.length-2).split("\\(") 47 | var date = middle(middle.length-1).substring(0,4).toInt 48 | var movie = "" 49 | for(j<-1 to line.length-2 ){ 50 | movie += line(j) 51 | } 52 | (line(0).toInt, movie, date, fields) 53 | }catch { 54 | case e:Exception=>{ 55 | var middle = line(line.length-2).split("\\(") 56 | //var date = middle(middle.length-1).substring(0,4).toInt 57 | var movie = "" 58 | for(j<-1 to line.length-2 ){ 59 | movie += line(j) 60 | } 61 | (line(0).toInt, movie, 0, fields) 62 | } 63 | } 64 | } 65 | }).collect() 66 | movie 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/Logger/LoggerLevels.scala: -------------------------------------------------------------------------------- 1 | package Logger 2 | 3 | import org.apache.log4j.{Level, Logger} 4 | import org.apache.spark.Logging 5 | 6 | 7 | object LoggerLevels extends Logging{ 8 | 9 | def setStreamingLogLevels(): Unit ={ 10 | val log4jInitialized = Logger.getRootLogger.getAllAppenders.hasMoreElements 11 | if(!log4jInitialized){ 12 | logInfo("Setting log level to [WARN] for streaming example." + 13 | " To override add a custom log4j.properties to the classpath.") 14 | Logger.getRootLogger.setLevel(Level.ERROR) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/ModelTest/TestModel.scala: -------------------------------------------------------------------------------- 1 | package ModelTest 2 | 3 | /** 4 | * 在秩Rank,迭代次数IterNum,正则系数Lambda不同情况下,测试出RMSE最小的情况。 5 | */ 6 | 7 | import Logger.LoggerLevels 8 | import org.apache.spark.mllib.evaluation.RegressionMetrics 9 | import org.apache.spark.mllib.recommendation.{ALS, MatrixFactorizationModel, Rating} 10 | import org.apache.spark.rdd.RDD 11 | import org.apache.spark.{SparkConf, SparkContext} 12 | 13 | object TestModel { 14 | def main(args: Array[String]): Unit = { 15 | LoggerLevels.setStreamingLogLevels() 16 | val sparkConf = new SparkConf().setAppName("TestModel").setMaster("local[4]").set("spark.local.dir","D:\\spark") 17 | val sc = new SparkContext(sparkConf) 18 | sc.setCheckpointDir(args(3)) 19 | 20 | val numPartitions = 4 21 | //读取训练集 22 | val train = sc.textFile(args(0)).map(line => { 23 | val fields = line.split(",") 24 | (fields(3).substring(0, 1).toInt, Rating(fields(0).substring(1).toInt, fields(1).toInt, fields(2).toDouble)) 25 | }).values.cache() 26 | //读取校验集 27 | val validation = sc.textFile(args(1)).map(line => { 28 | val fields = line.split(",") 29 | (fields(3).substring(0, 1).toInt, Rating(fields(0).substring(1).toInt, fields(1).toInt, fields(2).toDouble)) 30 | }).values.cache() 31 | 32 | //读取测试集 33 | val test = sc.textFile(args(2)).map(line => { 34 | val fields = line.split(",") 35 | (fields(3).substring(0, 1).toInt, Rating(fields(0).substring(1).toInt, fields(1).toInt, fields(2).toDouble)) 36 | }).values.persist() 37 | train.checkpoint() 38 | validation.checkpoint() 39 | test.checkpoint() 40 | 41 | //val numTest = test.count() 42 | // 43 | val ranks = List(60,80,100) 44 | val numlters = List(30,50,70) 45 | val lambdas = List(0.2,0.15,0.1,0.05,0.01) 46 | 47 | var bestModel: Option[MatrixFactorizationModel] = None 48 | var bestValidationRmse = Double.MaxValue 49 | var bestRank = 0 50 | var bestLambda = -1.0 51 | var bestNumIter = -1 52 | 53 | // val collection = scala.collection.mutable.ArrayBuffer[(Double, Int, Int, Double)]() 54 | // val rank = args(3).toInt 55 | // val numIter = args(4).toInt 56 | // val lambda = args(5).toDouble 57 | for(rank<-ranks;lambda<-lambdas;numIter<-numlters){ 58 | val model = ALS.train(train, rank, numIter, lambda) 59 | //训练模型 60 | //model.save("") 61 | 62 | val validationRmse = computeRmse(model, validation) 63 | 64 | println(validationRmse + " " + rank + " " + numIter + " " + lambda) 65 | 66 | if(validationRmse (user, product)} 87 | 88 | //创建(用户id,影片id) - 预测评分RDD 89 | val predictions = model.predict(usersProducts).map{ 90 | case Rating(user, product, rating) => ((user, product), rating) 91 | } 92 | 93 | //创建用户-影片实际评分RDD,并将其与上面创建的预测评分RDD join起来 94 | val ratingsAndPredictions = value.map{ 95 | case Rating(user, product, rating) => ((user, product),rating) 96 | }.join(predictions) 97 | 98 | //创建预测评分-实际评分RDD 99 | val predictedAndTrue = ratingsAndPredictions.map{case((user, product),(actual, 100 | predicted)) => (actual, predicted)} 101 | 102 | val regressionMetrics = new RegressionMetrics(predictedAndTrue) 103 | regressionMetrics.rootMeanSquaredError 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/Off_lineRecommendation/RecommendForAllUsers(1).scala: -------------------------------------------------------------------------------- 1 | package Off_lineRecommendation 2 | 3 | /** 4 | * 加载model,对每个用户进行推荐,将推荐电影放到数据库中 5 | */ 6 | 7 | import org.apache.spark.sql.SQLContext 8 | import Logger.LoggerLevels 9 | import org.apache.spark.mllib.recommendation.MatrixFactorizationModel 10 | import org.apache.spark.{SparkConf, SparkContext} 11 | import utils.connectDataBaseUtil 12 | 13 | object RecommendForAllUsers { 14 | 15 | def main(args: Array[String]): Unit = { 16 | val conf = new SparkConf().setAppName("RecommendForAllUsers").setMaster("local[4]") 17 | //创建sparkContext, 该对象是提交spark App的入门 18 | val sc = new SparkContext(conf) 19 | val sqLContext = new SQLContext(sc) 20 | /*设置提示级别*/ 21 | LoggerLevels.setStreamingLogLevels() 22 | 23 | //从本地载入训练模型 24 | val modelpath = args(0) 25 | val model = MatrixFactorizationModel.load(sc, modelpath) 26 | 27 | //从本地读取原始数据集-ratings.csv,获取所有的uerId 28 | 29 | val uIds = sc.textFile(args(1)).map(line => { 30 | val fields = line.split(",") 31 | fields(0).toInt 32 | }).distinct().toLocalIterator 33 | 34 | /*uIds.foreach(println)*/ 35 | 36 | while(uIds.hasNext){ 37 | val uid=uIds.next() 38 | val rec = model.recommendProducts(uid, 10) 39 | 40 | val result=rec.map(x => x.user.toString() + "|" 41 | + x.product.toString() + "|" + x.rating.toString()) 42 | 43 | import sqLContext.implicits._ 44 | val resultDFArray = sc.parallelize(result) 45 | val resultDF = resultDFArray. 46 | map(_.split("\\|")).map(x => Result(x(0).trim(), x(1).trim, x(2).trim())).toDF 47 | 48 | connectDataBaseUtil.connect(resultDF,"Result_all_users") 49 | 50 | } 51 | sc.stop() 52 | } 53 | } 54 | case class Result(userId:String,filmId:String,rate:String) 55 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/Off_lineRecommendation/movieSimilar.scala: -------------------------------------------------------------------------------- 1 | package Off_lineRecommendation 2 | 3 | /** 4 | * 用离线推荐model给每部电影推荐10部最相似的电影,并放到mysql数据库中 5 | */ 6 | 7 | import java.util.Properties 8 | import Logger.LoggerLevels 9 | import org.apache.spark.mllib.recommendation.MatrixFactorizationModel 10 | import org.apache.spark.sql.SQLContext 11 | import org.apache.spark.sql.types.{DoubleType, IntegerType, StructField, StructType} 12 | import org.apache.spark.{SparkConf, SparkContext} 13 | import org.jblas.DoubleMatrix 14 | 15 | object Analysis { 16 | def main(args: Array[String]): Unit = { 17 | LoggerLevels.setStreamingLogLevels() 18 | 19 | //创建SparkConf()并设置 20 | val conf = new SparkConf().setAppName("Analysis").setMaster("local[4]") 21 | //创建sparkContext, 该对象是提交spark App的入门 22 | val sc = new SparkContext(conf) 23 | //使用sc创建RDD并执行相应的transformation和action 24 | 25 | //从指定的地址创建RDD 26 | //创建SQLContext 27 | val sqlContext = new SQLContext(sc) 28 | 29 | val model = MatrixFactorizationModel.load(sc, "d:\\outmodel") 30 | 31 | 32 | 33 | //通过StructType直接指定每个字段的schema 34 | val schema = StructType( 35 | List( 36 | StructField("movie1", IntegerType, true), 37 | StructField("movie2", IntegerType, true), 38 | StructField("Similarity", DoubleType, true) 39 | ) 40 | ) 41 | 42 | //导入电影数据集 43 | val movies = sc.textFile(args(0)) 44 | 45 | //定义相似度函数 46 | def consineSimilarity(vec1: DoubleMatrix, vec2: DoubleMatrix) : Double = { 47 | vec1.dot(vec2) / (vec1.norm2() * vec2.norm2()) 48 | } 49 | val movieNum = movies.map(line =>{ 50 | val fields = line.split("\\|") 51 | fields(0).toInt 52 | }).distinct().toLocalIterator 53 | 54 | //对每一部电影进行相似度分析 55 | while (movieNum.hasNext) { 56 | 57 | val i = movieNum.next() 58 | //获取该物品的隐因子向量 59 | val itemFactor = model.productFeatures.lookup(i).head 60 | //将该向量转换为jblas矩阵类型 61 | val itemVector = new DoubleMatrix(itemFactor) 62 | 63 | //计算一个电影与其他物品的相似度 64 | val sims = model.productFeatures.map { case (id, factor) => 65 | val factorVector = new DoubleMatrix(factor) 66 | val sim = consineSimilarity(factorVector, itemVector) 67 | (id, sim) 68 | } 69 | //获取与电影567最相似的10部电影 70 | val sortedSims = sims.top(11)(Ordering.by[(Int, Double), Double] { case ( id, similarity) => similarity }) 71 | 72 | val simRDD = sortedSims.map(x=>Sim(i, x._1, x._2)) 73 | //将RDD映射到rowRDD 74 | import sqlContext.implicits._ 75 | val simDF = simRDD.toList.toDF 76 | 77 | //创建Properties存储数据库相关属性 78 | val prop = new Properties() 79 | prop.put("user", "root") 80 | prop.put("password", "123456") 81 | //将数据追加到数据库中 82 | simDF.write.mode("append").jdbc("jdbc:mysql://localhost:3306/spark","spark.t_Similar", prop) 83 | //停止SparkContext 84 | 85 | } 86 | sc.stop() 87 | } 88 | } 89 | case class Sim(movie1:Int, movie2: Int, rate:Double) 90 | 91 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/Real_timeRecommendation/StreamingRecommender.scala: -------------------------------------------------------------------------------- 1 | package Real_timeRecommendation 2 | 3 | /** 4 | * spark streaming从kafka中接收日志信息,进行实时推荐处理,将推荐结果存储到数据库中 5 | */ 6 | 7 | import java.sql.Connection 8 | import Logger.LoggerLevels 9 | import org.apache.spark.streaming.kafka.KafkaUtils 10 | import org.apache.spark.storage.StorageLevel 11 | import org.apache.spark.streaming.{Seconds, StreamingContext} 12 | import org.apache.spark.{SparkConf, SparkContext} 13 | import utils.ConnectPoolUtil 14 | import scala.collection.mutable 15 | 16 | object StreamingRecommender { 17 | 18 | //设置一些初始化参数 19 | val sparkConf = new SparkConf().setAppName("StreamingRecommender").setMaster("local[4]") 20 | val sc = new SparkContext(sparkConf) 21 | val ssc = new StreamingContext(sc, Seconds(10)) 22 | val minSimilarity=0.5 23 | //在数据库中读取用户的近期评分 24 | def getUserRecentRatings(K: Int, userId: Int):Array[(Int, Double)]={ 25 | //function feature: 通过MYSQL中评分的时间戳大小来获取userId的最近K-1次评分,与本次评分组成最近K次评分 26 | //return type:最近K次评分的数组,每一项是 27 | var connection: Connection = null 28 | 29 | var rate=0.0 30 | var movieId=0 31 | val arrayBuffer=mutable.ArrayBuffer[(Int, Double)]() 32 | try { 33 | connection=ConnectPoolUtil.getConnection() 34 | val statement = connection.createStatement() 35 | val resultSet = statement.executeQuery("select movieId,rate from user_rating_table where userId ="+userId+ " order by timestamp Desc " + 36 | "limit "+K) 37 | 38 | while (resultSet.next()) { 39 | rate = resultSet.getString("rate").toDouble 40 | movieId=resultSet.getString("movieId").toInt 41 | arrayBuffer+=((movieId,rate)) 42 | } 43 | } catch { 44 | case e => e.printStackTrace 45 | } 46 | connection.close() 47 | arrayBuffer.toArray 48 | } 49 | 50 | 51 | //从数据库中读取数据,读取两个电影的相似度 52 | def getSimilarityBetween2Movies(movie1:Int,movie2:Int):Double= { 53 | var connection: Connection = null 54 | 55 | var rate=0.6 56 | try { 57 | 58 | connection=ConnectPoolUtil.getConnection() 59 | val statement = connection.createStatement() 60 | val resultSet = statement.executeQuery("select rate from l_similar where movie1 ="+movie1+ " and movie2="+movie2) 61 | 62 | while (resultSet.next()) { 63 | rate = resultSet.getString("rate").toDouble 64 | 65 | } 66 | } catch { 67 | case e => e.printStackTrace 68 | //case _: Throwable => println("ERROR") 69 | } 70 | //connection.close() 71 | connection.close() 72 | rate 73 | 74 | } 75 | 76 | //在数据库中的相似度表中,按照电影ID查询相似的电影 77 | def getSimilarMovies(movieIds: Array[Int]):mutable.ArrayBuffer[Int]= { 78 | var connection: Connection = null 79 | 80 | var movies = mutable.ArrayBuffer[Int]() 81 | try { 82 | 83 | 84 | connection = ConnectPoolUtil.getConnection() 85 | for (movieId <- movieIds) { 86 | val statement = connection.createStatement() 87 | val resultSet = statement.executeQuery("select movie2 from l_similar where movie1 =" + movieId) 88 | 89 | while (resultSet.next()) { 90 | movies += resultSet.getString("movie2").toInt 91 | } 92 | } 93 | } 94 | catch 95 | { 96 | case e => e.printStackTrace 97 | //case _: Throwable => println("ERROR") 98 | } 99 | connection.close() 100 | movies 101 | } 102 | 103 | 104 | //计算候选项的优先级 105 | def log(m: Double): Double = math.log(m) / math.log(2) 106 | 107 | def createUpdatedRatings(recentRatings: Array[(Int, Double)],candidateMovies: mutable.ArrayBuffer[Int]): Array[(Int, Double)] ={ 108 | //function feature: 核心算法,计算每个备选电影的预期评分 109 | //return type:备选电影预计评分的数组,每一项是 110 | val allSimilars = mutable.ArrayBuffer[(Int, Double)]() 111 | val increaseCounter = mutable.Map[Int, Int]() 112 | val reduceCounter = mutable.Map[Int, Int]() 113 | var sim_sum=0 114 | for(cmovieId<-candidateMovies;(rmovieId,rate)<-recentRatings){ 115 | val sim=getSimilarityBetween2Movies(cmovieId,rmovieId) 116 | if(sim>minSimilarity) { 117 | allSimilars += ((cmovieId, sim * rate)) 118 | sim_sum+=1 119 | //[(movieId,sim * rate)] 120 | if(rate>=3.0){ 121 | increaseCounter(cmovieId)=increaseCounter.getOrElse(cmovieId,0)+1 122 | }else{ 123 | reduceCounter(cmovieId)=reduceCounter.getOrElse(cmovieId,0)+1 124 | } 125 | } 126 | } 127 | allSimilars.toArray.groupBy{case (movieId,rate)=>movieId} 128 | .map{case (movieId,simArray)=> 129 | (movieId,simArray.map(_._2).sum/sim_sum 130 | +log(increaseCounter.getOrElse[Int](movieId,1))-log(reduceCounter.getOrElse[Int](movieId,1))) 131 | }.toArray.sortBy(_._2) 132 | } 133 | //将更新出来的结果写入数据库中 134 | def updateRecommends2DB(userId:Int,updatedRecommends: Array[(Int, Double)]):Unit={ 135 | var connection: Connection = null 136 | try { 137 | connection=ConnectPoolUtil.getConnection() 138 | val statement = connection.createStatement() 139 | for (updatedRecom<-updatedRecommends){ 140 | 141 | statement.executeUpdate("INSERT into table_update VALUES("+userId+","+updatedRecom._1+","+updatedRecom._2+")") 142 | } 143 | } catch { 144 | case e => e.printStackTrace 145 | } 146 | connection.close() 147 | } 148 | 149 | def main(args: Array[String]): Unit = { 150 | LoggerLevels.setStreamingLogLevels() 151 | val zkServers = "mini1:2181,mini2:2181" 152 | val msgConsumerGroup="msgConsumerGroup1" 153 | 154 | //生成5个DStream 155 | val dataDStreams = (1 to 2).map{i => 156 | KafkaUtils.createStream(ssc, zkServers, msgConsumerGroup, Map("recommending-topic" -> 3), StorageLevel.MEMORY_ONLY)} 157 | //将上面的5个DStream合并为一个DStream 158 | var unifiedStream = ssc.union(dataDStreams).map(_._2) 159 | 160 | val dataDStream = unifiedStream.map{ case msgLine => 161 | val dataArr: Array[String] = msgLine.split(",") 162 | val userId = dataArr(0).toInt 163 | val movieId = dataArr(1).toInt 164 | val rate = dataArr(2).toDouble 165 | val startTimeMillis = dataArr(3).toString 166 | (userId, movieId, rate, startTimeMillis) 167 | }.cache 168 | 169 | val rs= dataDStream.foreachRDD(rdd => { 170 | if (!rdd.isEmpty) { 171 | rdd.map{ case (userId, movieId, rate, startTimeMillis) => 172 | //获取近期评分记录 173 | val recentRatings = getUserRecentRatings(5,userId) 174 | //获取备选电影 175 | val candidateMovies = getSimilarMovies(Array(movieId)) 176 | //为备选电影推测评分结果 177 | val updatedRecommends = createUpdatedRatings(recentRatings, candidateMovies) 178 | println("推荐表的长度为:"+updatedRecommends.length) 179 | updateRecommends2DB(userId,updatedRecommends) 180 | }.count() 181 | } 182 | }) 183 | println("推荐结果为:----------------------------") 184 | 185 | dataDStream.count().print() 186 | dataDStream.print() 187 | 188 | ssc.start() 189 | ssc.awaitTermination() 190 | } 191 | 192 | } 193 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/utils/ConnectPoolUtil.scala: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import java.sql.{Connection, PreparedStatement, ResultSet} 4 | 5 | import org.apache.commons.dbcp.BasicDataSource 6 | 7 | 8 | object ConnectPoolUtil { 9 | 10 | private var bs:BasicDataSource = null 11 | 12 | /** 13 | * 创建数据源 14 | * @return 15 | */ 16 | def getDataSource():BasicDataSource={ 17 | if(bs==null){ 18 | bs = new BasicDataSource() 19 | bs.setDriverClassName("com.mysql.jdbc.Driver") 20 | bs.setUrl("jdbc:mysql://localhost:3306/big_data") 21 | bs.setUsername("root") 22 | bs.setPassword("123456") 23 | bs.setMaxActive(200) //设置最大并发数 24 | bs.setInitialSize(30) //数据库初始化时,创建的连接个数 25 | bs.setMinIdle(50) //最小空闲连接数 26 | bs.setMaxIdle(200) //数据库最大连接数 27 | bs.setMaxWait(1000) 28 | bs.setMinEvictableIdleTimeMillis(60*1000) //空闲连接60秒中后释放 29 | bs.setTimeBetweenEvictionRunsMillis(5*60*1000) //5分钟检测一次是否有死掉的线程 30 | bs.setTestOnBorrow(true) 31 | } 32 | bs 33 | } 34 | 35 | /** 36 | * 释放数据源 37 | */ 38 | def shutDownDataSource(){ 39 | if(bs!=null){ 40 | bs.close() 41 | } 42 | } 43 | 44 | /** 45 | * 获取数据库连接 46 | * @return 47 | */ 48 | def getConnection():Connection={ 49 | var con:Connection = null 50 | try { 51 | if(bs!=null){ 52 | con = bs.getConnection() 53 | }else{ 54 | con = getDataSource().getConnection() 55 | } 56 | } catch{ 57 | case e:Exception => println(e.getMessage) 58 | } 59 | con 60 | } 61 | 62 | /** 63 | * 关闭连接 64 | */ 65 | def closeCon(rs:ResultSet ,ps:PreparedStatement,con:Connection){ 66 | if(rs!=null){ 67 | try { 68 | rs.close() 69 | } catch{ 70 | case e:Exception => println(e.getMessage) 71 | } 72 | } 73 | if(ps!=null){ 74 | try { 75 | ps.close() 76 | } catch{ 77 | case e:Exception => println(e.getMessage) 78 | } 79 | } 80 | if(con!=null){ 81 | try { 82 | con.close() 83 | } catch{ 84 | case e:Exception => println(e.getMessage) 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /movieRecommendSpark/src/main/scala/utils/connectDataBaseUtil.scala: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import java.util.Properties 4 | 5 | import org.apache.spark.sql.{DataFrame, SaveMode} 6 | 7 | object connectDataBaseUtil { 8 | 9 | def connect(dataFrame:DataFrame, tableName:String):Unit={ 10 | //创建properties存储数据库相关属性 11 | val prop = new Properties() 12 | prop.put("user","root") 13 | prop.put("password","123456") 14 | //将数据追加到数据库 15 | dataFrame.write.mode(SaveMode.Append).jdbc("jdbc:mysql://localhost:3306/big_data","big_data."+tableName,prop) 16 | 17 | } 18 | 19 | } 20 | --------------------------------------------------------------------------------