package com.example.business.controller;
import com.alibaba.fastjson.JSONObject;
import com.example.business.pojo.*;
import com.example.business.service.MovieService;
import com.example.business.service.RecommendService;
import com.example.business.utils.Constant;
import com.example.business.utils.RetResult;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//用于处理电影相关的功能
@RestController
@Validated
public class MovieRestApi {
@Autowired
private MovieService movieService;
@Autowired
private RecommendService recommendService;
private Logger logger = LoggerFactory.getLogger(MovieRestApi.class);
//电影的详细页面
@GetMapping("/movie/{id}")
public Object getMovieInfo(@PathVariable Integer id) {
logger.info("正在查询电影详细信息:{}",id);
return RetResult.<Movie>builder()
.status(true)
.data(movieService.getMovieInfo(id))
.build();
}
//电影的详细页面
@GetMapping("/movie_extra/{id}")
public Object getMovieExtraInfo(@PathVariable Integer id) {
JSONObject jsonObject = new JSONObject();
/* //获取电影comment_parse
jsonObject.put("comment_parse", movieService.getCommentParse(id));*/
//获取电影演员
jsonObject.put("actors", movieService.getActors(id));
//获取电影tag
jsonObject.put("tags", movieService.getTages(id));
//获取电影分类
jsonObject.put("genres", movieService.getGenres(id));
//相似电影,actor和tag和genre计算余弦相似度
jsonObject.put("content_sim",recommendService.getContentSimMovie(id,Constant.DEFAULT_SIZE));
//看了此电影的人还看了,基于als的物品相似度计算
jsonObject.put("also_saw",recommendService.getAlsoSawMovies(id, Constant.DEFAULT_SIZE));
return RetResult.<JSONObject>builder()
.status(true)
.data(jsonObject)
.build();
}
@GetMapping("/category")
public Object category(@Min(value = 0, message = "start太小了吧") @Max(value = 7000, message = "start太大了吧") @RequestParam(value = "start", required = false, defaultValue = "1") Integer start,
@Min(value = 1, message = "num太小了吧") @Max(value = 100, message = "num太大了吧") @RequestParam(value = "pagenum", required = false, defaultValue = "6") Integer pagenum,
@Min(value = 0, message = "sort奇怪的参数") @Max(value = 2, message = "sort奇怪的参数") @RequestParam(value = "sort", required = false, defaultValue = "0") Integer sort,
@Min(value = 1800, message = "year太小了吧") @Max(value = 2022, message = "year太大了吧") @RequestParam(value = "beginyear", required = false) Integer beginyear,
@Min(value = 1800, message = "year太小了吧") @Max(value = 2022, message = "year太大了吧") @RequestParam(value = "endyear", required = false, defaultValue = "2021") Integer endyear,
@Size(min = 1, max = 10, message = "genre长度得按要求走") @RequestParam(value = "genres", required = false) String genres,
@Size(min = 1, max = 10, message = "place长度得按要求走") @RequestParam(value = "place", required = false) String place,
@Size(min = 1, max = 10, message = "tag长度得按要求走") @RequestParam(value = "tag", required = false) String tag) {
Map<String, Object> myMap = new HashMap<>();
myMap.put("start", start);
myMap.put("pagenum", pagenum);
switch (sort) {
case 2:
myMap.put("sort", "m.score desc");
break;
case 1:
myMap.put("sort", "m.year desc");
break;
default:
myMap.put("sort", "m.votes desc");
}
myMap.put("endyear", endyear);
if (genres != null)
myMap.put("genres", genres);
if (beginyear != null)
myMap.put("beginyear", beginyear);
if (place != null)
myMap.put("place", place);
if (tag != null)
myMap.put("tag", tag);
return RetResult.<PageInfo<BriefMovie>>builder()
.data(movieService.category(myMap))
.status(true)
.build();
}
//电影评论分页
@GetMapping("/comment")
public Object getMovieInfo(@RequestParam(value = "mid", required = true) Integer mid,
@Min(value = 0, message = "start太小了吧") @Max(value = 50, message = "start太大了吧") @RequestParam(value = "start", required = false, defaultValue = "1") Integer start,
@Min(value = 1, message = "num太小了吧") @Max(value = 20, message = "size太大了吧") @RequestParam(value = "size", required = false, defaultValue = "6") Integer size) {
return RetResult.<PageInfo<Comment>>builder()
.status(true)
.data(movieService.getComment(mid,start,size))
.build();
}
//模糊搜索功能
@GetMapping("/search")
public Object searchMovie(@RequestParam(value = "type", required = false, defaultValue = "0") Integer type,
@RequestParam(value = "text") String text) throws Exception {
return RetResult.<List<BriefMovieWithActor>>builder()
.status(true)
.data(recommendService.getFuzzyMovies(text,type))
.build();
}
//actor信息
@GetMapping("/actor/{aid}")
public Object actorInfo(@PathVariable Integer aid) {
return RetResult.<BriefActor>builder()
.status(true)
.data(movieService.getActor(aid))
.build();
}
//actor出演电影分页
@GetMapping("/actor_movie")
public Object getActorMovie(@RequestParam(value = "aid") Integer aid,
@Min(value = 0, message = "start太小了吧") @Max(value = 50, message = "start太大了吧") @RequestParam(value = "start", required = false, defaultValue = "1") Integer start,
@Min(value = 1, message = "num太小了吧") @Max(value = 20, message = "size太大了吧") @RequestParam(value = "size", required = false, defaultValue = "6") Integer size) {
return RetResult.<PageInfo<BriefMovieWithActor>>builder()
.status(true)
.data(movieService.getActorMovies(aid,start,size))
.build();
}
@GetMapping("/actor/hot")
public Object hotActor() {
return RetResult.<List<Actor>>builder()
.status(true)
.data(movieService.getHotActor())
.build();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源介绍】 基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip 该项目是个人毕设项目,答辩评审分达到95分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。 该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。 项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。
资源推荐
资源详情
资源评论
收起资源包目录
基于多模融合策略的电影推荐系统:spark推荐算法+springboot后端+小程序前端.zip (79个子文件)
project_code
business
pom.xml 5KB
src
test
java
com
example
business
BusinessApplicationTests.java 384B
main
resources
logback.xml 2KB
application.properties 251B
java
com
example
business
controller
DataUserRestApi.java 7KB
WxUserController.java 3KB
MovieRestApi.java 7KB
utils
ErrorResult.java 236B
RetResult.java 228B
HttpClientUtil.java 5KB
Constant.java 353B
dao
mapper
MovieMapper.java 2KB
RecommendMapper.java 2KB
UserWxMapper.java 827B
UserDataMapper.java 3KB
MovieCategoryProvider.java 2KB
pojo
BriefActor.java 215B
Comment.java 341B
BriefMovieWithActor.java 341B
Actor.java 235B
BriefMovie.java 283B
Count.java 134B
Rating.java 221B
UserWx.java 372B
UserData.java 239B
Tag.java 183B
Movie.java 569B
BriefMovieWithTime.java 227B
service
RecommendService.java 639B
UserWxService.java 325B
impl
MovieServiceImpl.java 3KB
UserWxServiceImpl.java 5KB
UserDataServiceImpl.java 3KB
RecommendServiceImpl.java 5KB
UserDataService.java 909B
MovieService.java 688B
BusinessApplication.java 403B
config
ClientConfigure.java 986B
annotation
MethodScope.java 356B
InterceptorConfig.java 1KB
CacheConfig.java 3KB
MyKeyGenerator.java 1KB
interceptor
TokenInterceptor.java 3KB
MessageInterceptor.java 709B
GlobalExceptionHandler.java 1KB
scrapyMovies
actor_change.py 3KB
getcomment.py 3KB
comment_parse.py 2KB
user_change.py 2KB
get_ip.py 2KB
dataset.py 3KB
doubanScrapy
scrapy.cfg 267B
doubanScrapy
__init__.py 0B
pipelines.py 4KB
spiders
__init__.py 161B
comment.py 3KB
movie_info.py 8KB
collect_id.py 2KB
items.py 2KB
settings.py 8KB
middlewares.py 5KB
translate.py 2KB
add_movie_index.py 1KB
elsatic_insert.py 2KB
test.py 531B
ratting_change.py 1017B
READ1ME.md 95B
recommender
kafkastream
pom.xml 1KB
src
main
java
com
qihe
kafkastream
Application.java 1KB
LogProcessor.java 806B
offlinerecommender
pom.xml 2KB
src
main
scala
com
qihe
offline
UserDraw.scala 5KB
AlsTrain.scala 2KB
OfflineRecommender.scala 5KB
UserSim.scala 3KB
ContentSim.scala 5KB
streamingRecommender
pom.xml 2KB
src
main
scala
com
qihe
streaming
StreamingRecommender.scala 9KB
AllStream.scala 6KB
共 79 条
- 1
资源评论
- youyou06082024-03-29资源不错,很实用,内容全面,介绍详细,很好用,谢谢分享。
z同学的编程之路
- 粉丝: 1808
- 资源: 2129
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功