Commit b8b81f59 authored by Quxl's avatar Quxl

完善API

parent 7ac2f196
...@@ -132,10 +132,13 @@ public class UserReviewController { ...@@ -132,10 +132,13 @@ public class UserReviewController {
@PostMapping("doubtful_append") @PostMapping("doubtful_append")
@ApiOperation("增加疑点") @ApiOperation("增加疑点")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "film_id", value="影片ID"), @ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "film_id", value="影片ID"),
@ApiImplicitParam(paramType = "query", dataType = "string", required = false, name = "content", value="疑点说明"), @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="次数"),
}) })
public Object doubtfulAppend(Long film_id, String content) { public Object doubtfulAppend(Long film_id, Integer type, String type_content, Long play_time, Integer times) {
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
...@@ -162,4 +165,25 @@ public class UserReviewController { ...@@ -162,4 +165,25 @@ public class UserReviewController {
return Rjx.jsonOk(); 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) {
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("statistics")
@ApiOperation("查询统计数据")
public Object statistics() {
LoginToken loginToken = tokenService.getToken();
Integer user_id = (Integer)loginToken.getId();
return reviewService.queryStatistics(user_id);
}
} }
...@@ -3,6 +3,7 @@ package com.egolm.film.api.user.service; ...@@ -3,6 +3,7 @@ package com.egolm.film.api.user.service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_film; import com.egolm.film.bean.Fc_film;
import com.egolm.film.bean.Fc_film_doubtful_point; import com.egolm.film.bean.Fc_film_doubtful_point;
...@@ -24,4 +25,6 @@ public interface UserReviewService { ...@@ -24,4 +25,6 @@ public interface UserReviewService {
Integer queryRound(Integer user_id, Long film_id); Integer queryRound(Integer user_id, Long film_id);
Rjx queryStatistics(Integer user_id);
} }
package com.egolm.film.api.user.service.impl; package com.egolm.film.api.user.service.impl;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.film.api.user.service.UserReviewService; import com.egolm.film.api.user.service.UserReviewService;
...@@ -89,4 +91,46 @@ public class UserReviewServiceImpl implements UserReviewService { ...@@ -89,4 +91,46 @@ public class UserReviewServiceImpl implements UserReviewService {
return jdbcTemplate.queryForInt("select round from fc_film_allot where film_id = ? and uid = ?", film_id, user_id); return jdbcTemplate.queryForInt("select round from fc_film_allot where film_id = ? and uid = ?", film_id, user_id);
} }
@Override
public Rjx queryStatistics(Integer user_id) {
String sql0 = "SELECT count(*) as total FROM fc_view_allot WHERE uid = ?";
String sql1 = "SELECT count(*) as total FROM fc_view_allot WHERE uid = ? AND review_state = 4";
String sql2 = "SELECT count(*) as total FROM fc_view_allot WHERE uid = ? AND review_state = 2";
String sql3 = "SELECT count(*) as total FROM fc_view_allot WHERE uid = ? AND (review_state = 3 or review_state = 5)";
String sql4 = "SELECT count(*) as total FROM fc_view_allot WHERE uid = ? AND review_state = 6";
Integer count0 = jdbcTemplate.queryForInt(sql0, user_id);
Integer count1 = jdbcTemplate.queryForInt(sql1, user_id);
Integer count2 = jdbcTemplate.queryForInt(sql2, user_id);
Integer count3 = jdbcTemplate.queryForInt(sql3, user_id);
Integer count4 = jdbcTemplate.queryForInt(sql4, user_id);
Double rate_1 = 0D;
Double rate_2 = 0D;
Double rate_3 = 0D;
Double rate_4 = 0D;
if(count0 > 0) {
rate_1 = (double)count1/(double)count0;
rate_2 = (double)count2/(double)count0;
rate_3 = (double)count3/(double)count0;
rate_4 = (double)count4/(double)count0;
}
return Rjx.jsonOk()
.set("total", count0)
.set("count_state_4", count1)
.set("count_state_2", count2)
.set("count_state_3_5", count3)
.set("count_state_6", count4)
.set("rate_1", toRate(rate_1))
.set("rate_2", toRate(rate_2))
.set("rate_3", toRate(rate_3))
.set("rate_4", toRate(rate_4))
;
}
private String toRate(Double dou) {
return new BigDecimal(dou*100).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
}
} }
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