Commit 173d5f3c authored by Quxl's avatar Quxl

审片API

parent d4f2021a
......@@ -136,9 +136,29 @@ public class UserReviewController {
@ApiImplicitParam(paramType = "query", dataType = "int", required = true, name = "type", value="疑点类型"),
@ApiImplicitParam(paramType = "query", dataType = "string", required = true, name = "type_content", value="疑点说明"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "play_time", value="播放时间"),
@ApiImplicitParam(paramType = "query", dataType = "int", required = true, name = "times", value="次数"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "times", value="次数"),
})
public Object doubtfulAppend(Long film_id, Integer type, String type_content, Long play_time, Integer times) {
public Object doubtfulAppend(Long film_id, Integer type, String type_content, Long play_time, Long times) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Integer round = reviewService.queryRound(user_id, film_id);
reviewService.doubtfulAppend(user_id, film_id, round, type, type_content, play_time, times);
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("play_append")
@ApiOperation("增加播放记录")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "film_id", value="影片ID"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "playtime", value="播放时间"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "watchtime", value="观看时间"),
})
public Object playAppend(Long film_id, Long playtime, Long watchtime) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Integer round = reviewService.queryRound(user_id, film_id);
reviewService.playAppend(user_id, film_id, round, playtime, watchtime);
return Rjx.jsonOk();
}
......@@ -150,6 +170,10 @@ public class UserReviewController {
@ApiImplicitParam(paramType = "query", dataType = "string", required = false, name = "veto", value="否决理由"),
})
public Object doReject(Long film_id, String veto) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Integer round = reviewService.queryRound(user_id, film_id);
reviewService.doReject(user_id, film_id, round, veto);
return Rjx.jsonOk();
}
......@@ -162,18 +186,10 @@ public class UserReviewController {
@ApiImplicitParam(paramType = "query", dataType = "string", required = true, name = "content", value="选片结论"),
})
public Object doPass(Long film_id, Double score, String content) {
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("play_append")
@ApiOperation("增加播放记录")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "film_id", value="影片ID"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "playtime", value="播放时间"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "watchtime", value="观看时间"),
})
public Object playAppend(Long film_id, Long playtime, Long watchtime) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Integer round = reviewService.queryRound(user_id, film_id);
reviewService.doPass(user_id, film_id, round, score, content);
return Rjx.jsonOk();
}
......
......@@ -27,4 +27,12 @@ public interface UserReviewService {
Rjx queryStatistics(Long user_id);
void doubtfulAppend(Long user_id, Long film_id, Integer round, Integer type, String type_content, Long play_time, Long times);
void playAppend(Long user_id, Long film_id, Integer round, Long playtime, Long watchtime);
void doReject(Long user_id, Long film_id, Integer round, String veto);
void doPass(Long user_id, Long film_id, Integer round, Double score, String content);
}
......@@ -14,6 +14,8 @@ import com.egolm.film.api.user.service.UserReviewService;
import com.egolm.film.bean.Fc_film;
import com.egolm.film.bean.Fc_film_doubtful_point;
import com.egolm.film.bean.Fc_film_review;
import com.egolm.film.bean.Fc_film_user_play;
import com.egolm.film.config.WebMvcConfig;
@Service
public class UserReviewServiceImpl implements UserReviewService {
......@@ -133,4 +135,83 @@ public class UserReviewServiceImpl implements UserReviewService {
return new BigDecimal(dou*100).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
}
@Override
public void doubtfulAppend(Long user_id, Long film_id, Integer round, Integer type, String type_content, Long play_time, Long times) {
Fc_film_doubtful_point doubtful = new Fc_film_doubtful_point();
String ip = WebMvcConfig.getRemoteIp();
doubtful.setCreate_ip(ip);
doubtful.setCreate_time(System.currentTimeMillis());
doubtful.setFilm_id(film_id);
doubtful.setPlay_time(play_time + "");
doubtful.setRound(round);
doubtful.setTimes(times);
doubtful.setType(type);
doubtful.setType_content(type_content);
doubtful.setUid(user_id);
jdbcTemplate.save(doubtful);
}
@Override
public void playAppend(Long user_id, Long film_id, Integer round, Long playtime, Long watchtime) {
Fc_film_user_play play = new Fc_film_user_play();
play.setAddtime(System.currentTimeMillis());
play.setFilm_id(film_id);
play.setPlaytime(playtime + "");
play.setRound(round);
play.setWatchtime(watchtime);
play.setUid(user_id);
jdbcTemplate.save(play);
}
@Override
public void doReject(Long user_id, Long film_id, Integer round, String veto) {
boolean isSave = false;
Fc_film_review review = null;
try {
review = this.jdbcTemplate.queryForBean("select * from fc_film_review where uid = ? and film_id = ? and round = ?", Fc_film_review.class, user_id, film_id, round);
} catch (Exception e) {
isSave = true;
review = new Fc_film_review();
review.setUid(user_id);
review.setFilm_id(film_id);
}
String ip = WebMvcConfig.getRemoteIp();
review.setRound(round);
review.setVeto(veto);
review.setReview_ip(ip);
review.setReview_time(System.currentTimeMillis());
review.setState(2);
if(isSave) {
this.jdbcTemplate.save(review);
} else {
this.jdbcTemplate.update(review);
}
}
@Override
public void doPass(Long user_id, Long film_id, Integer round, Double score, String content) {
boolean isSave = false;
Fc_film_review review = null;
try {
review = this.jdbcTemplate.queryForBean("select * from fc_film_review where uid = ? and film_id = ? and round = ?", Fc_film_review.class, user_id, film_id, round);
} catch (Exception e) {
isSave = true;
review = new Fc_film_review();
review.setUid(user_id);
review.setFilm_id(film_id);
}
String ip = WebMvcConfig.getRemoteIp();
review.setRound(round);
review.setSelect_result(content);
review.setReview_ip(ip);
review.setAward_1_score(new BigDecimal(score));
review.setReview_time(System.currentTimeMillis());
review.setState(1);
if(isSave) {
this.jdbcTemplate.save(review);
} else {
this.jdbcTemplate.update(review);
}
}
}
......@@ -95,4 +95,23 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
}
return null;
}
public static String getRemoteIp() {
HttpServletRequest request = WebMvcConfig.getRequest();
String ip = request.getHeader("X-Real_IP");
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("X-Forwarded-For");
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getRemoteAddr();
}
String[] ips = ip.trim().split(", ");
return ips[ips.length - 1].trim();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment