controller层:

public class Login{

public String confirmLogin(HttpServletRequest request) {

Member member = memberService.checkIdAndToken(request);

if(member==null){

return "登录失败";}

return "登录成功";

}

impl层

public class LoginServiceImpl{

public Member checkIdAndToken(HttpServletRequest request) {
String id = HttpRequestUtils.getHeaderByName(request, "id");
String token = HttpRequestUtils.getHeaderByName(request, "token");
if (id == null) {
id = request.getParameter("id");
}
if (token == null) {
token = request.getParameter("token");
}
return memberRepository.findByIdAndToken(id, token);
}

}

repository 层

public interface MemberRepository{

{Member findByIdAndToken(String id, String token);

}

}

posted on 2019-01-04 23:18  qqzhulu  阅读(448)  评论(0编辑  收藏  举报