|
@@ -75,6 +75,14 @@ public class AdminController {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/logout" ,method = RequestMethod.POST)
|
|
|
+ public void Logout(HttpServletRequest request, HttpServletResponse response){
|
|
|
+ String id = request.getHeader("id");
|
|
|
+ ClearRedis(Long.valueOf(id));
|
|
|
+ HttpUtil.responseOk(request, response);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// @RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
|
// public void Insert(HttpServletRequest request, HttpServletResponse response){
|
|
|
// String name = request.getParameter("name");
|
|
@@ -195,6 +203,15 @@ public class AdminController {
|
|
|
*/
|
|
|
public void SaveRedis(Admin admin){
|
|
|
ValueOperations valueOperations = stringRedisTemplate.opsForValue();
|
|
|
- valueOperations.set(Consts.REDIS_ADMIN+admin.getId(), admin.getToken(), tokenExpire*3600, TimeUnit.SECONDS);
|
|
|
+ valueOperations.set(Consts.REDIS_ADMIN + admin.getId(), admin.getToken(), tokenExpire * 3600, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将token从redis中清除
|
|
|
+ * @param idAdmin
|
|
|
+ */
|
|
|
+ public void ClearRedis(Long idAdmin){
|
|
|
+ ValueOperations valueOperations = stringRedisTemplate.opsForValue();
|
|
|
+ valueOperations.set(Consts.REDIS_ADMIN+idAdmin, "", tokenExpire*3600, TimeUnit.SECONDS);
|
|
|
}
|
|
|
}
|