Commit aec1ad3d authored by zhangyong's avatar zhangyong
parents c532f860 d4f2021a
......@@ -18,15 +18,9 @@
<repositories>
<repository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus Staging</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
......
......@@ -4,6 +4,8 @@ import com.egolm.film.model.LoginToken;
public interface TokenService {
final String JSESSIONID = "JSESSIONID";
LoginToken getToken();
LoginToken doLogin(String username, String password);
......@@ -12,4 +14,5 @@ public interface TokenService {
boolean isLogin();
boolean isLoginByToken(String token);
}
......@@ -3,6 +3,7 @@ package com.egolm.film.api.admin.service.impl;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -35,6 +36,11 @@ public class AdminTokenServiceImpl implements AdminTokenService {
Integer adminid = (Integer)map.get("adminid");
LoginToken token = new LoginToken(adminid);
session.setAttribute(TOKEN_NAME, token);
Cookie cookie = WebMvcConfig.getCookie(JSESSIONID);
if(cookie != null) {
String sql = "update fc_admin set token = ? where id = ?";
jdbcTemplate.executeUpdate(sql, cookie.getValue(), adminid);
}
return token;
} else if(state == 2) {
throw new XException("用户已禁用");
......@@ -69,4 +75,18 @@ public class AdminTokenServiceImpl implements AdminTokenService {
public boolean isLogin() {
return this.getToken() != null;
}
@Override
public boolean isLoginByToken(String token_string) {
HttpSession session = WebMvcConfig.getSession();
try {
String sql = "select adminid from fc_admin where token = ?";
Integer adminid = jdbcTemplate.queryForInt(sql, token_string);
LoginToken token = new LoginToken(adminid);
session.setAttribute(TOKEN_NAME, token);
return true;
} catch (Exception e) {
return false;
}
}
}
......@@ -18,7 +18,7 @@ import com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.film.api.common.service.Messages;
import com.egolm.film.api.util.AliyunUtil;
import com.egolm.film.util.AliyunUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......
......@@ -12,8 +12,8 @@ import com.egolm.film.api.common.service.LanguageService;
@Service
public class LanguageServiceImpl implements LanguageService {
static String en = "Chinese,French,Russian,Japanese,Portugal,Farsi,Italian,English,German,Spanish,Arabic,Hindi,Korean,Other";
static String zh = "中文,法语,俄罗斯语,日文,葡萄牙语,波斯语,意大利语,英语,德语,西班牙语,阿拉伯语,印第语,韩语,其他";
static String en = "Chinese,Dialect,French,Russian,Japanese,Portugal,Farsi,Italian,English,German,Spanish,Arabic,Hindi,Korean,Other";
static String zh = "普通话,方言,法语,俄罗斯语,日文,葡萄牙语,波斯语,意大利语,英语,德语,西班牙语,阿拉伯语,印第语,韩语,其他";
public List<Map<String, String>> queryLanguageList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
......
......@@ -110,7 +110,6 @@ public class MemberApplyController {
@ApiImplicitParam(paramType="query", dataType="string", required=true, name="film_medium", value="影片色彩"),
@ApiImplicitParam(paramType="query", dataType="string", required=true, name="film_format", value="样片规格"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="film_express_no", value="快递单号"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="film_format_url", value="样片URL地址"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="film_format_passw", value="样片URL访问密码"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="film_format_other", value="其他样品信息"),
......@@ -130,7 +129,6 @@ public class MemberApplyController {
String other_filmfest_name,
String film_medium,
String film_format,
String film_express_no,
String film_format_url,
String film_format_passw,
String film_format_other) {
......@@ -153,7 +151,6 @@ public class MemberApplyController {
other_filmfest_name,
film_medium,
film_format,
film_express_no,
film_format_url,
film_format_passw,
film_format_other);
......
......@@ -82,7 +82,6 @@ public interface MemberService {
String other_filmfest_name,
String film_medium,
String film_format,
String film_express_no,
String film_format_url,
String film_format_passw,
String film_format_other);
......@@ -126,4 +125,8 @@ public interface MemberService {
boolean changePasswordByMemberId(Integer member_id, String password, String newPassword);
Fc_member getMemberByToken(String token);
void updateToken(Integer member_id, String token_string);
}
......@@ -223,7 +223,6 @@ public class MemberServiceImpl implements MemberService {
String other_filmfest_name,
String film_medium,
String film_format,
String film_express_no,
String film_format_url,
String film_format_passw,
String film_format_other) {
......@@ -246,7 +245,6 @@ public class MemberServiceImpl implements MemberService {
+ "other_filmfest_name = ?, "
+ "film_medium = ?, "
+ "film_format = ?, "
+ "film_express_no = ?, "
+ "film_format_url = ?, "
+ "film_format_passw = ?, "
+ "film_format_other = ?, "
......@@ -269,7 +267,6 @@ public class MemberServiceImpl implements MemberService {
other_filmfest_name,
film_medium,
film_format,
film_express_no,
film_format_url,
film_format_passw,
film_format_other,
......@@ -469,4 +466,16 @@ public class MemberServiceImpl implements MemberService {
return false;
}
@Override
public Fc_member getMemberByToken(String token) {
String sql = "select * from fc_member where token = ?";
return jdbcTemplate.queryForBean(sql, Fc_member.class, token);
}
@Override
public void updateToken(Integer member_id, String token_string) {
String sql = "update fc_member set token = ? where id = ?";
jdbcTemplate.executeUpdate(sql, token_string, member_id);
}
}
package com.egolm.film.api.member.service.impl;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -41,6 +42,10 @@ public class MemberTokenServiceImpl implements MemberTokenService {
Integer id = member.getId();
LoginToken token = new LoginToken(id);
session.setAttribute(TOKEN_NAME, token);
Cookie cookie = WebMvcConfig.getCookie(JSESSIONID);
if(cookie != null) {
memberService.updateToken(id, cookie.getValue());
}
return token;
} else {
throw new XException(messages.get("err.user_pwd_err"));
......@@ -71,4 +76,23 @@ public class MemberTokenServiceImpl implements MemberTokenService {
return this.getToken() != null;
}
@Override
public boolean isLoginByToken(String token_string) {
HttpSession session = WebMvcConfig.getSession();
try {
Fc_member member = memberService.getMemberByToken(token_string);
Integer state = member.getState();
if(state == 1) {
Integer id = member.getId();
LoginToken token = new LoginToken(id);
session.setAttribute(TOKEN_NAME, token);
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
package com.egolm.film.api.user;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.member.service.MemberService;
import com.egolm.film.api.user.service.UserReviewService;
import com.egolm.film.api.user.service.UserTokenService;
import com.egolm.film.bean.Fc_film_doubtful_point;
import com.egolm.film.bean.Fc_film_review;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_director;
import com.egolm.film.bean.Fc_member_film_issuer;
import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.model.LoginToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api
@Controller
@RequestMapping("user/review")
public class UserReviewController {
@Autowired
private UserTokenService tokenService;
@Autowired
private UserReviewService reviewService;
@Autowired
private MemberService memberService;
@ResponseBody
@PostMapping("review_list")
@ApiOperation("已审核列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "index", value="分页页码"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "limit", value="分页大小"),
@ApiImplicitParam(paramType = "query", dataType = "string", required = false, name = "limitKey", value="分页排序", allowMultiple=true),
})
public Object getReviewList(Long index, Long limit, String[] limitKey) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Page page = new Page(index, limit, limitKey);
List<Map<String, Object>> list = reviewService.limitReviewList(user_id, page);
return Rjx.jsonOk().setData(list).setPage(page);
}
@ResponseBody
@PostMapping("unview_list")
@ApiOperation("未审核列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "index", value="分页页码"),
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "limit", value="分页大小"),
@ApiImplicitParam(paramType = "query", dataType = "string", required = false, name = "limitKey", value="分页排序", allowMultiple=true),
})
public Object getUnviewList(Long index, Long limit, String[] limitKey) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Page page = new Page(index, limit, limitKey);
List<Map<String, Object>> list = reviewService.limitUnviewList(user_id, page);
return Rjx.jsonOk().setData(list).setPage(page);
}
@ResponseBody
@PostMapping("member_apply_detail")
@ApiOperation("查询申报影片详细信息")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "film_id", value="影片ID"),
})
public Object getMemberApplyDetail(Long film_id) {
Long member_film_id = reviewService.queryMemberFilmIdByFilmId(film_id);
Fc_member_film memberFilm = memberService.queryMemberFilmById(member_film_id);
List<Fc_member_film_director> directorList = memberService.queryMemberFilmDirectorList(member_film_id);
List<Fc_member_film_issuer> issuerList = memberService.queryMemberFilmIssuerList(member_film_id);
List<Fc_member_film_playactor> playactorList = memberService.queryMemberFilmPlayactorList(member_film_id);
List<Fc_member_film_show> showList = memberService.queryMemberFilmShowList(member_film_id);
return Rjx.jsonOk()
.setData(memberFilm)
.set("member_film_id", member_film_id)
.set("directorList", directorList)
.set("issuerList", issuerList)
.set("playactorList", playactorList)
.set("showList", showList)
;
}
@ResponseBody
@PostMapping("review_record_list")
@ApiOperation("查询评审记录列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "film_id", value="影片ID"),
})
public Object getReviewRecordList(Long film_id) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
Integer round = reviewService.queryRound(user_id, film_id);
List<Fc_film_review> reviewList = reviewService.queryRoundReviewList(user_id, round, film_id);
return Rjx.jsonOk().setData(reviewList);
}
@ResponseBody
@PostMapping("doubtful_list")
@ApiOperation("查询疑点列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "film_id", value="影片ID"),
})
public Object getDoubtfulList(Long film_id) {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
List<Fc_film_doubtful_point> doubtfulList = reviewService.queryDoubtfulList(user_id, film_id);
return Rjx.jsonOk().setData(doubtfulList);
}
@ResponseBody
@PostMapping("doubtful_append")
@ApiOperation("增加疑点")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "film_id", value="影片ID"),
@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, Integer type, String type_content, Long play_time, Integer times) {
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("do_reject")
@ApiOperation("审片否决")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = false, name = "film_id", value="影片ID"),
@ApiImplicitParam(paramType = "query", dataType = "string", required = false, name = "veto", value="否决理由"),
})
public Object doReject(Long film_id, String veto) {
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("do_pass")
@ApiOperation("审片通过")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "long", required = true, name = "film_id", value="影片ID"),
@ApiImplicitParam(paramType = "query", dataType = "float", required = true, name = "score", value="评分"),
@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) {
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("statistics")
@ApiOperation("查询统计数据")
public Object statistics() {
LoginToken loginToken = tokenService.getToken();
Long user_id = (Long)loginToken.getId();
return reviewService.queryStatistics(user_id);
}
}
package com.egolm.film.api.user.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_film;
import com.egolm.film.bean.Fc_film_doubtful_point;
import com.egolm.film.bean.Fc_film_review;
public interface UserReviewService {
List<Map<String, Object>> limitReviewList(Long user_id, Page page);
List<Map<String, Object>> limitUnviewList(Long user_id, Page page);
Long queryMemberFilmIdByFilmId(Long film_id);
List<Fc_film_review> queryRoundReviewList(Long user_id, Integer round, Long film_id);
List<Fc_film_doubtful_point> queryDoubtfulList(Long user_id, Long film_id);
Fc_film queryFilmById(Long film_id);
Integer queryRound(Long user_id, Long film_id);
Rjx queryStatistics(Long user_id);
}
package com.egolm.film.api.user.service.impl;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
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;
@Service
public class UserReviewServiceImpl implements UserReviewService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> limitReviewList(Long user_id, Page page) {
String sql = ""
+ " select "
+ "film.*, "
+ "allot.uid, "
+ "allot.review_round, "
+ "allot.film_id, "
+ "review.is_save, "
+ "review.state review_state, "
+ "review.save_state "
+ "from "
+ "fc_film_allot allot "
+ "left join fc_film film on film.id = allot.film_id "
+ "left join fc_film_review review on review.film_id = allot.film_id and review.uid = allot.uid and review.round = allot.review_round "
+ "where "
+ "allot.uid = ? "
+ "and review.state > 0";
return jdbcTemplate.limit(sql, page, user_id);
}
@Override
public List<Map<String, Object>> limitUnviewList(Long user_id, Page page) {
String sql = ""
+ " select "
+ "film.*, "
+ "allot.uid, "
+ "allot.review_round, "
+ "allot.film_id, "
+ "review.is_save, "
+ "review.state review_state, "
+ "review.save_state "
+ "from "
+ "fc_film_allot allot "
+ "left join fc_film film on film.id = allot.film_id "
+ "left join fc_film_review review on review.film_id = allot.film_id and review.uid = allot.uid and review.round = allot.review_round "
+ "where "
+ "allot.uid = ? "
+ "and review.state is null";
return jdbcTemplate.limit(sql, page, user_id);
}
@Override
public Long queryMemberFilmIdByFilmId(Long film_id) {
String sql = "select mf.id from fc_member_film mf, fc_film f where mf.film_no = f.film_no and f.id = ?";
return jdbcTemplate.queryForLong(sql, film_id);
}
@Override
public List<Fc_film_review> queryRoundReviewList(Long user_id, Integer round, Long film_id) {
String sql = "SELECT fc_film_review.* FROM fc_film_review WHERE film_id = ? AND uid = ? AND round = ?";
return jdbcTemplate.queryForBeans(sql, Fc_film_review.class, film_id, user_id, round);
}
@Override
public List<Fc_film_doubtful_point> queryDoubtfulList(Long user_id, Long film_id) {
String sql = "SELECT * FROM fc_film_doubtful_point WHERE uid = ? AND film_id = ?";
return jdbcTemplate.queryForBeans(sql, Fc_film_doubtful_point.class, user_id, film_id);
}
@Override
public Fc_film queryFilmById(Long film_id) {
return jdbcTemplate.queryForBean("select * from fc_film where id = ?", Fc_film.class, film_id);
}
@Override
public Integer queryRound(Long user_id, Long film_id) {
return jdbcTemplate.queryForInt("select round from fc_film_allot where film_id = ? and uid = ?", film_id, user_id);
}
@Override
public Rjx queryStatistics(Long 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) + "%";
}
}
package com.egolm.film.api.user.service.impl;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.film.api.common.service.Messages;
import com.egolm.film.api.user.service.UserTokenService;
import com.egolm.film.bean.Fc_user;
import com.egolm.film.config.Common;
import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException;
import com.egolm.film.model.LoginToken;
......@@ -21,33 +21,39 @@ public class UserTokenServiceImpl implements UserTokenService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private Messages messages;
@Override
public LoginToken doLogin(String username, String password) {
HttpSession session = WebMvcConfig.getSession();
String md5String = StringUtil.toMD5HexString(password).toLowerCase();
String loginSql = "select * from fc_user where username = ? and password = ?";
List<Map<String, Object>> list = this.jdbcTemplate.queryForList(loginSql, username, md5String);
if(list != null) {
if(list.size() == 1) {
Map<String,Object> map = list.get(0);
Integer state = (Integer)map.get("state");
Fc_user user = null;
try {
user = this.jdbcTemplate.queryForBean("select * from fc_user where username = ?", Fc_user.class, username);
} catch (Exception e) {
throw new XException(messages.get("err.user_pwd_err"));
}
Integer state = user.getState();
if(state == 1) {
Integer adminid = (Integer)map.get("adminid");
LoginToken token = new LoginToken(adminid);
String salt = user.getSalt();
String dbPwd = user.getPassword();
String encodePassword = Common.encodePassword(password, salt);
if(encodePassword.equals(dbPwd)) {
Long uid = user.getUid();
LoginToken token = new LoginToken(uid);
session.setAttribute(TOKEN_NAME, token);
return token;
} else if(state == 2) {
throw new XException("用户已禁用");
} else {
throw new XException("用户状态未知");
Cookie cookie = WebMvcConfig.getCookie(JSESSIONID);
if(cookie != null) {
jdbcTemplate.executeUpdate("update fc_user set token = ? where uid = ?", cookie.getValue(), uid);
}
} else if(list.size() == 0) {
throw new XException("用户名或密码错误");
return token;
} else {
throw new XException("用户登陆信息重复,请联系管理员");
throw new XException(messages.get("err.user_pwd_err"));
}
} else if(state == 2) {
throw new XException(messages.get("err.user_disabled"));
} else {
throw new XException("用户名或密码错误");
throw new XException(messages.get("err"));
}
}
......@@ -69,4 +75,18 @@ public class UserTokenServiceImpl implements UserTokenService {
public boolean isLogin() {
return this.getToken() != null;
}
@Override
public boolean isLoginByToken(String token_string) {
HttpSession session = WebMvcConfig.getSession();
try {
String sql = "select uid from fc_user where token = ?";
Long uid = jdbcTemplate.queryForLong(sql, token_string);
LoginToken token = new LoginToken(uid);
session.setAttribute(TOKEN_NAME, token);
return true;
} catch (Exception e) {
return false;
}
}
}
......@@ -2,6 +2,7 @@ package com.egolm.film.config;
import java.util.EventListener;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
......@@ -82,4 +83,16 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
return null;
}
public static Cookie getCookie(String name) {
HttpServletRequest request = WebMvcConfig.getRequest();
if(request != null) {
Cookie[] cookies = request.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(name)) {
return cookie;
}
}
}
return null;
}
}
package com.egolm.film.config.interceptor;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -7,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.film.api.TokenService;
import com.egolm.film.api.admin.service.AdminTokenService;
import com.egolm.film.config.XException;
......@@ -21,6 +23,16 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
if(tokenService.isLogin()) {
return super.preHandle(req, resp, handler);
} else {
String sessionid = null;
Cookie[] cookies = req.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(TokenService.JSESSIONID)) {
sessionid = cookie.getValue();
}
}
if(sessionid != null && tokenService.isLoginByToken(sessionid)) {
return super.preHandle(req, resp, handler);
}
throw new XException("用户未登陆", 300);
}
}
......
package com.egolm.film.config.interceptor;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -7,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.film.api.TokenService;
import com.egolm.film.api.member.service.MemberTokenService;
import com.egolm.film.config.XException;
......@@ -21,6 +23,16 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
if(tokenService.isLogin()) {
return super.preHandle(req, resp, handler);
} else {
String sessionid = null;
Cookie[] cookies = req.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(TokenService.JSESSIONID)) {
sessionid = cookie.getValue();
}
}
if(sessionid != null && tokenService.isLoginByToken(sessionid)) {
return super.preHandle(req, resp, handler);
}
throw new XException("用户未登陆", 300);
}
}
......
package com.egolm.film.config.interceptor;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -7,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.film.api.TokenService;
import com.egolm.film.api.user.service.UserTokenService;
import com.egolm.film.config.XException;
......@@ -21,6 +23,16 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
if(tokenService.isLogin()) {
return super.preHandle(req, resp, handler);
} else {
String sessionid = null;
Cookie[] cookies = req.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(TokenService.JSESSIONID)) {
sessionid = cookie.getValue();
}
}
if(sessionid != null && tokenService.isLoginByToken(sessionid)) {
return super.preHandle(req, resp, handler);
}
throw new XException("用户未登陆", 300);
}
}
......
package com.egolm.film.api.util;
package com.egolm.film.util;
import java.util.Map;
......
package com.egolm.film.config;
package com.egolm.film.util;
import java.sql.SQLException;
......
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