提交 5e5ddc74 编写于 作者: N Nicky.Ma

修改Constant类命名

上级 7764519c
......@@ -7,7 +7,7 @@ import java.util.Locale;
* @author Nicky
* @date 2017年3月6日
*/
public class Constants {
public class CommonConsts {
//定义统一Locale.CHINA,程序中所有和Locale相关操作均默认使用此Locale
public static final Locale LOCALE_CHINA = Locale.CHINA;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.util;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -40,7 +40,7 @@ public class DateUtils {
* @return
*/
public static Date parse(String pattern, String date){
return parse(pattern, date, Constants.LOCALE_CHINA);
return parse(pattern, date, CommonConsts.LOCALE_CHINA);
}
/**
......
......@@ -3,7 +3,7 @@ package org.muses.jeeplatform.web.controller;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -30,7 +30,7 @@ public class CodeController {
Subject currentUser = SecurityUtils.getSubject();
Session session = currentUser.getSession();
session.setAttribute(Constants.SESSION_SECURITY_CODE, code);
session.setAttribute(CommonConsts.SESSION_SECURITY_CODE, code);
try {
ServletOutputStream out = response.getOutputStream();
......
......@@ -8,7 +8,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.ResultVO;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
......@@ -95,7 +95,7 @@ public class LoginController extends BaseController {
//获取Shiro管理的Session
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
String codeSession = (String)session.getAttribute(Constants.SESSION_SECURITY_CODE);
String codeSession = (String)session.getAttribute(CommonConsts.SESSION_SECURITY_CODE);
String code = logindata[2];
/**检测页面验证码是否为空,调用工具类检测**/
if(Tools.isEmpty(code)){
......@@ -116,9 +116,9 @@ public class LoginController extends BaseController {
}else{
//Shiro添加会话
session.setAttribute("username", username);
session.setAttribute(Constants.SESSION_USER, user);
session.setAttribute(CommonConsts.SESSION_USER, user);
//删除验证码Session
session.removeAttribute(Constants.SESSION_SECURITY_CODE);
session.removeAttribute(CommonConsts.SESSION_SECURITY_CODE);
//保存登录IP
this.getRemortIP(username);
/**Shiro加入身份验证**/
......@@ -153,7 +153,7 @@ public class LoginController extends BaseController {
/**获取Shiro管理的Session**/
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
User user = (User)session.getAttribute(Constants.SESSION_USER);
User user = (User)session.getAttribute(CommonConsts.SESSION_USER);
if(user != null){
Set<Role> roles = user.getRoles();
......@@ -218,8 +218,8 @@ public class LoginController extends BaseController {
/**Shiro管理Session**/
Subject sub = SecurityUtils.getSubject();
Session session = sub.getSession();
session.removeAttribute(Constants.SESSION_USER);
session.removeAttribute(Constants.SESSION_SECURITY_CODE);
session.removeAttribute(CommonConsts.SESSION_USER);
session.removeAttribute(CommonConsts.SESSION_SECURITY_CODE);
/**Shiro销毁登录**/
Subject subject = SecurityUtils.getSubject();
subject.logout();
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.muses.jeeplatform.annotation.LogController;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.service.MenuService;
......@@ -39,7 +39,7 @@ public class MenuController extends BaseController {
public ModelAndView toMenuList(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<Menu> menuPage;
......@@ -72,7 +72,7 @@ public class MenuController extends BaseController {
pageIndex = 1;
}
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
Page<Menu> menuPage = menuService.findAll(pageIndex, pageSize, Sort.Direction.ASC,"menuId");
String json = JSON.toJSONString(menuPage.getContent());
return json;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.muses.jeeplatform.annotation.LogController;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.service.PermissionPageService;
import org.muses.jeeplatform.service.PermissionService;
......@@ -43,7 +43,7 @@ public class PermissionController extends BaseController {
public ModelAndView queryAll(HttpServletRequest request, HttpServletResponse response, Model model){
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<Permission> permissionPage;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.core.entity.admin.Role;
......@@ -51,7 +51,7 @@ public class RoleController extends BaseController {
public ModelAndView queryAll(HttpServletRequest request, HttpServletResponse response, Model model){
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<Role> rolePage;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.email.JavaEmailSender;
import org.muses.jeeplatform.core.entity.admin.Role;
import org.muses.jeeplatform.core.entity.admin.User;
......@@ -52,7 +52,7 @@ public class UserController extends BaseController {
public ModelAndView findAll(HttpServletRequest request, HttpServletResponse response, Model model) {
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<User> userPage;
......@@ -90,7 +90,7 @@ public class UserController extends BaseController {
@RequestMapping(value = "/searchU", produces = "application/json;charset=UTf-8")
public ModelAndView doSearch(@RequestParam(value = "pageIndex",required = false) String pageIndexStr, @RequestParam(value = "keyword",required = false) String keyword,
@RequestParam(value = "startDate",required = false) String startDateStr, @RequestParam(value = "endDate",required = false) String endDateStr) {
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<User> userPage;
......
......@@ -3,7 +3,7 @@ package org.muses.jeeplatform.web.interceptor;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.User;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
......@@ -22,19 +22,19 @@ public class LoginInterceptor extends HandlerInterceptorAdapter{
HttpServletResponse response, Object handler) throws Exception {
String urlpath = request.getServletPath();
/**正则表达式过滤,不匹配该值的就拦截处理**/
if(urlpath.matches(Constants.REGEXP_PATH)){
if(urlpath.matches(CommonConsts.REGEXP_PATH)){
return true;
}else {
//shiro框架的会话管理,获取Session,校验用户是否通过登录验证
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
User user = (User)session.getAttribute(Constants.SESSION_USER);
User user = (User)session.getAttribute(CommonConsts.SESSION_USER);
if(user != null){
/**加入权限校验,待开发...**/
return true;
}else{
//重定向到登录页面
response.sendRedirect(request.getContextPath() + Constants.URL_LOGIN);
response.sendRedirect(request.getContextPath() + CommonConsts.URL_LOGIN);
return false;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册