diff --git a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminResourceMgtController.java b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminResourceMgtController.java index d978f66..bd77568 100644 --- a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminResourceMgtController.java +++ b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminResourceMgtController.java @@ -24,6 +24,7 @@ import com.certusnet.xproject.admin.web.LoginToken; import com.certusnet.xproject.common.consts.GlobalConstants; import com.certusnet.xproject.common.support.AbstractXTreeBuilder; +import com.certusnet.xproject.common.support.HttpAccessLogging; import com.certusnet.xproject.common.support.TreeNodeConverter; import com.certusnet.xproject.common.util.DateTimeUtils; import com.certusnet.xproject.common.web.BaseController; @@ -53,6 +54,7 @@ public class AdminResourceMgtController extends BaseController { * @return */ @RequestMapping(value="/admin/resource/available", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/资源管理/查看资源树结构") public Object getAvailableResources(HttpServletRequest request, HttpServletResponse response) { List allResourceList = adminResourceService.getAllResourceList(null); List> dataList = resourceTreeBuilder.buildObjectTree(GlobalConstants.DEFAULT_ADMIN_ROOT_RESOURCE_ID, allResourceList, resourceTreeNodeConverter); @@ -67,8 +69,10 @@ public Object getAvailableResources(HttpServletRequest request, HttpServletRespo * @return */ @RequestMapping(value="/admin/resource/add/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/资源管理/新增资源") public Object addResource(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminResource resourceAddForm) { LoginToken loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY); + resourceAddForm.setResourceId(null); resourceAddForm.setCreateTime(DateTimeUtils.formatNow()); resourceAddForm.setCreateBy(loginToken.getLoginId()); resourceAddForm.setResourceType(AdminResourceTypeEnum.ADMIN_RESOURCE_TYPE_NORMAL.getTypeCode()); @@ -84,6 +88,7 @@ public Object addResource(HttpServletRequest request, HttpServletResponse respon * @return */ @RequestMapping(value="/admin/resource/edit/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/资源管理/修改资源") public Object editResource(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminResource resourceEditForm) { LoginToken loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY); resourceEditForm.setUpdateTime(DateTimeUtils.formatNow()); @@ -100,6 +105,7 @@ public Object editResource(HttpServletRequest request, HttpServletResponse respo * @return */ @RequestMapping(value="/admin/resource/del", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/资源管理/删除资源") public Object delResource(HttpServletRequest request, HttpServletResponse response, Long id) { adminResourceService.deleteResourceById(id, true); return genSuccessResult("删除成功!", null); diff --git a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminRoleMgtController.java b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminRoleMgtController.java index 2504f7d..4494385 100644 --- a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminRoleMgtController.java +++ b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminRoleMgtController.java @@ -29,6 +29,7 @@ import com.certusnet.xproject.admin.web.LoginToken; import com.certusnet.xproject.common.consts.GlobalConstants; import com.certusnet.xproject.common.support.AbstractXTreeBuilder; +import com.certusnet.xproject.common.support.HttpAccessLogging; import com.certusnet.xproject.common.support.OrderBy; import com.certusnet.xproject.common.support.Pager; import com.certusnet.xproject.common.support.PagingList; @@ -69,6 +70,7 @@ public class AdminRoleMgtController extends BaseController { * @return */ @RequestMapping(value="/admin/role/list", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/角色管理/查询角色列表") public Object listRole(HttpServletRequest request, HttpServletResponse response, AdminRole roleQueryForm, OrderBy orderBy, Pager pager) { PagingList roleList = adminRoleService.getRoleList(roleQueryForm, pager, orderBy); return genSuccessPagingResult(roleList); @@ -82,8 +84,10 @@ public Object listRole(HttpServletRequest request, HttpServletResponse response, * @return */ @RequestMapping(value="/admin/role/add/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/角色管理/新增角色") public Object addRole(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminRole roleAddForm) { LoginToken loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY); + roleAddForm.setRoleId(null); roleAddForm.setCreateTime(DateTimeUtils.formatNow()); roleAddForm.setCreateBy(loginToken.getLoginId()); roleAddForm.setRoleType(AdminRoleTypeEnum.ADMIN_ROLE_TYPE_NORMAL.getTypeCode()); @@ -99,6 +103,7 @@ public Object addRole(HttpServletRequest request, HttpServletResponse response, * @return */ @RequestMapping(value="/admin/role/edit/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/角色管理/修改角色") public Object editRole(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminRole roleEditForm) { LoginToken loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY); roleEditForm.setUpdateTime(DateTimeUtils.formatNow()); @@ -115,6 +120,7 @@ public Object editRole(HttpServletRequest request, HttpServletResponse response, * @return */ @RequestMapping(value="/admin/role/del", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/角色管理/删除角色") public Object delRole(HttpServletRequest request, HttpServletResponse response, Long id) { adminRoleService.deleteRoleById(id); return genSuccessResult("删除成功!", null); @@ -153,6 +159,7 @@ public Object loadRoleResources(HttpServletRequest request, HttpServletResponse * @return */ @RequestMapping(value="/admin/role/config/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/角色管理/配置角色资源关系") public Object configRoleResources(HttpServletRequest request, HttpServletResponse response, @RequestBody Map parameter) { List resourceIdList = new ArrayList(); String resourceIds = MapUtils.getString(parameter, "resourceIds"); diff --git a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminUserMgtController.java b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminUserMgtController.java index 72e5dfa..68835e8 100644 --- a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminUserMgtController.java +++ b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/controller/AdminUserMgtController.java @@ -28,6 +28,7 @@ import com.certusnet.xproject.admin.service.AdminUserService; import com.certusnet.xproject.admin.web.LoginToken; import com.certusnet.xproject.common.consts.GlobalConstants; +import com.certusnet.xproject.common.support.HttpAccessLogging; import com.certusnet.xproject.common.support.OrderBy; import com.certusnet.xproject.common.support.Pager; import com.certusnet.xproject.common.support.PagingList; @@ -66,6 +67,7 @@ public class AdminUserMgtController extends BaseController { * @return */ @RequestMapping(value="/admin/user/list", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/查询用户列表") public Object listRole(HttpServletRequest request, HttpServletResponse response, AdminUser userQueryForm, OrderBy orderBy, Pager pager) { PagingList dataList = adminUserService.getUserList(userQueryForm, pager, orderBy); return genSuccessPagingResult(dataList); @@ -79,8 +81,10 @@ public Object listRole(HttpServletRequest request, HttpServletResponse response, * @return */ @RequestMapping(value="/admin/user/add/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/新增用户") public Object addUser(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser userAddForm) throws Exception { LoginToken loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY); + userAddForm.setUserId(null); userAddForm.setCreateTime(DateTimeUtils.formatNow()); userAddForm.setCreateBy(loginToken.getLoginId()); userAddForm.setStatus(AdminUserStatusEnum.ADMIN_USER_STATUS_ENABLED.getStatusCode()); @@ -111,6 +115,7 @@ public Object addUser(HttpServletRequest request, HttpServletResponse response, * @return */ @RequestMapping(value="/admin/user/edit/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/修改用户") public Object editUser(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser userEditForm) throws Exception { LoginToken loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY); userEditForm.setUpdateBy(loginToken.getLoginId()); @@ -140,6 +145,7 @@ public Object editUser(HttpServletRequest request, HttpServletResponse response, * @return */ @RequestMapping(value="/admin/user/del", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/删除用户") public Object delUser(HttpServletRequest request, HttpServletResponse response, Long id) { AdminUser user = new AdminUser(); user.setUserId(id); @@ -148,13 +154,14 @@ public Object delUser(HttpServletRequest request, HttpServletResponse response, } /** - * 修改密码 + * 修改用户密码 * @param request * @param response * @param passwdEditForm * @return */ @RequestMapping(value="/admin/user/changepwd/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/修改用户密码", excludeParamNames={"password","repassword"}) public Object changeUserPasswd(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser passwdEditForm, Boolean forceUpdate) { if(forceUpdate == null){ forceUpdate = false; @@ -171,6 +178,7 @@ public Object changeUserPasswd(HttpServletRequest request, HttpServletResponse r * @return */ @RequestMapping(value="/admin/user/enable", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/启用用户") public Object enableUser(HttpServletRequest request, HttpServletResponse response, Long userId) { return updateUserStatus(request, response, userId, AdminUserStatusEnum.ADMIN_USER_STATUS_ENABLED); } @@ -183,6 +191,7 @@ public Object enableUser(HttpServletRequest request, HttpServletResponse respons * @return */ @RequestMapping(value="/admin/user/disable", method=GET, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/禁用用户") public Object disableUser(HttpServletRequest request, HttpServletResponse response, Long userId) { return updateUserStatus(request, response, userId, AdminUserStatusEnum.ADMIN_USER_STATUS_DISABLED); } @@ -217,6 +226,7 @@ public Object loadUserRoles(HttpServletRequest request, HttpServletResponse resp * @return */ @RequestMapping(value="/admin/user/config/add", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/添加用户角色配置") public Object addUserRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Map parameter) { Long userId = MapUtils.getLong(parameter, "userId"); String roleIds = MapUtils.getString(parameter, "roleIds"); @@ -246,6 +256,7 @@ public Object addUserRoles(HttpServletRequest request, HttpServletResponse respo * @return */ @RequestMapping(value="/admin/user/config/del", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON) + @HttpAccessLogging(title="系统管理/用户管理/删除用户角色配置") public Object delUserRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Map parameter) { Long userId = MapUtils.getLong(parameter, "userId"); String roleIds = MapUtils.getString(parameter, "roleIds"); diff --git a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DbStoreHttpAccessLogHandler.java b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DbStoreHttpAccessLogDAO.java similarity index 78% rename from xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DbStoreHttpAccessLogHandler.java rename to xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DbStoreHttpAccessLogDAO.java index f32832c..3b50fcb 100644 --- a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DbStoreHttpAccessLogHandler.java +++ b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DbStoreHttpAccessLogDAO.java @@ -1,6 +1,8 @@ package com.certusnet.xproject.admin.web.interceptor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; import com.certusnet.xproject.admin.model.AdminUser; import com.certusnet.xproject.admin.model.AdminUserAccessLog; @@ -9,24 +11,21 @@ import com.certusnet.xproject.common.util.CollectionUtils; import com.certusnet.xproject.common.util.DateTimeUtils; import com.certusnet.xproject.common.util.JsonUtils; -import com.certusnet.xproject.common.util.SpringUtils; -import com.certusnet.xproject.common.web.springmvc.interceptor.AbstractHttpAccessLogHandler; import com.certusnet.xproject.common.web.springmvc.interceptor.HttpAccessLog; +import com.certusnet.xproject.common.web.springmvc.interceptor.HttpAccessLogDAO; -public class DbStoreHttpAccessLogHandler extends AbstractHttpAccessLogHandler { +@Component +public class DbStoreHttpAccessLogDAO implements HttpAccessLogDAO { - private final AdminUserAccessLogService adminUserAccessLogService; + @Autowired + private AdminUserAccessLogService adminUserAccessLogService; - public DbStoreHttpAccessLogHandler(HttpAccessLog httpAccessLog) { - super(httpAccessLog); - this.adminUserAccessLogService = SpringUtils.getBean(AdminUserAccessLogService.class); - } - public LoggingType getLoggingType() { return LoggingType.DB; } - public void handleLogger(HttpAccessLog httpAccessLog) throws Exception { + public void saveLog(HttpAccessLog httpAccessLog) throws Exception { + AdminUser adminUser = (AdminUser) httpAccessLog.getAccessUser(); AdminUserAccessLog accessLog = new AdminUserAccessLog(); accessLog.setTitle(httpAccessLog.getTitle()); accessLog.setUri(httpAccessLog.getUri()); @@ -34,7 +33,7 @@ public void handleLogger(HttpAccessLog httpAccessLog) throws Exceptio accessLog.setRequestHeader(CollectionUtils.isEmpty(httpAccessLog.getRequestHeader()) ? null : JsonUtils.object2Json(httpAccessLog.getRequestHeader())); accessLog.setRequestContentType(httpAccessLog.getRequestContentType() == null ? null : httpAccessLog.getRequestContentType().toString()); accessLog.setRequestParameter(JsonUtils.object2Json(httpAccessLog.getRequestParameter())); - accessLog.setAccessUserId(httpAccessLog.getAccessUser().getUserId()); + accessLog.setAccessUserId(adminUser.getUserId()); accessLog.setAccessTime(httpAccessLog.getAccessTime()); accessLog.setClientIpAddr(httpAccessLog.getClientIpAddr()); accessLog.setServerIpAddr(httpAccessLog.getServerIpAddr()); diff --git a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DefaultHttpAccessLoggingInterceptor.java b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DefaultHttpAccessLoggingInterceptor.java index ca77bb0..a4bf42c 100644 --- a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DefaultHttpAccessLoggingInterceptor.java +++ b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/DefaultHttpAccessLoggingInterceptor.java @@ -14,11 +14,8 @@ import com.certusnet.xproject.admin.model.AdminUser; import com.certusnet.xproject.admin.service.AdminUserService; import com.certusnet.xproject.admin.web.LoginToken; -import com.certusnet.xproject.common.support.HttpAccessLogging.LoggingType; import com.certusnet.xproject.common.web.shiro.ShiroUtils; -import com.certusnet.xproject.common.web.springmvc.interceptor.AbstractHttpAccessLogHandler; import com.certusnet.xproject.common.web.springmvc.interceptor.AbstractHttpAccessLoggingInterceptor; -import com.certusnet.xproject.common.web.springmvc.interceptor.HttpAccessLog; import com.certusnet.xproject.common.web.springmvc.interceptor.HttpAccessLog.HttpRequestParameter; @SuppressWarnings("unchecked") @@ -51,14 +48,4 @@ protected AdminUser getAccessUser(HttpServletRequest request, LoggingContext log } } - protected AbstractHttpAccessLogHandler createHttpAccessLoggerHandler(LoggingContext loggingContext) { - LoggingType loggingType = loggingContext.getHttpAccessLogging().loggingType(); - if(LoggingType.DB.equals(loggingType)){ - return new DbStoreHttpAccessLogHandler((HttpAccessLog) loggingContext.getHttpAccessLog()); - }else if(LoggingType.FILE.equals(loggingType)){ - return new FileStoreHttpAccessLogHandler((HttpAccessLog) loggingContext.getHttpAccessLog()); - } - return null; - } - } diff --git a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/FileStoreHttpAccessLogHandler.java b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/FileStoreHttpAccessLogDAO.java similarity index 77% rename from xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/FileStoreHttpAccessLogHandler.java rename to xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/FileStoreHttpAccessLogDAO.java index 1fdd7a7..26a5df2 100644 --- a/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/FileStoreHttpAccessLogHandler.java +++ b/xproject-admin/src/main/java/com/certusnet/xproject/admin/web/interceptor/FileStoreHttpAccessLogDAO.java @@ -2,6 +2,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; import com.certusnet.xproject.admin.model.AdminUser; import com.certusnet.xproject.admin.model.AdminUserAccessLog; @@ -9,29 +10,27 @@ import com.certusnet.xproject.common.util.CollectionUtils; import com.certusnet.xproject.common.util.DateTimeUtils; import com.certusnet.xproject.common.util.JsonUtils; -import com.certusnet.xproject.common.web.springmvc.interceptor.AbstractHttpAccessLogHandler; import com.certusnet.xproject.common.web.springmvc.interceptor.HttpAccessLog; +import com.certusnet.xproject.common.web.springmvc.interceptor.HttpAccessLogDAO; -public class FileStoreHttpAccessLogHandler extends AbstractHttpAccessLogHandler { +@Component +public class FileStoreHttpAccessLogDAO implements HttpAccessLogDAO { - private static final Logger logger = LoggerFactory.getLogger(FileStoreHttpAccessLogHandler.class); + private static final Logger logger = LoggerFactory.getLogger(FileStoreHttpAccessLogDAO.class); - public FileStoreHttpAccessLogHandler(HttpAccessLog httpAccessLog) { - super(httpAccessLog); - } - public LoggingType getLoggingType() { return LoggingType.DB; } - public void handleLogger(HttpAccessLog httpAccessLog) throws Exception { + public void saveLog(HttpAccessLog httpAccessLog) throws Exception { + AdminUser adminUser = (AdminUser) httpAccessLog.getAccessUser(); AdminUserAccessLog accessLog = new AdminUserAccessLog(); accessLog.setTitle(httpAccessLog.getTitle()); accessLog.setUri(httpAccessLog.getUri()); accessLog.setMethod(httpAccessLog.getMethod()); accessLog.setRequestHeader(CollectionUtils.isEmpty(httpAccessLog.getRequestHeader()) ? null : JsonUtils.object2Json(httpAccessLog.getRequestHeader())); accessLog.setRequestParameter(JsonUtils.object2Json(httpAccessLog.getRequestParameter())); - accessLog.setAccessUserId(httpAccessLog.getAccessUser().getUserId()); + accessLog.setAccessUserId(adminUser.getUserId()); accessLog.setAccessTime(httpAccessLog.getAccessTime()); accessLog.setClientIpAddr(httpAccessLog.getClientIpAddr()); accessLog.setServerIpAddr(httpAccessLog.getServerIpAddr()); diff --git a/xproject-admin/src/main/webapp/admin/role/index.html b/xproject-admin/src/main/webapp/admin/role/index.html index ddccf28..a9b0373 100644 --- a/xproject-admin/src/main/webapp/admin/role/index.html +++ b/xproject-admin/src/main/webapp/admin/role/index.html @@ -225,7 +225,7 @@

关 闭 - 保存配置 + 保存配置
diff --git a/xproject-admin/src/main/webapp/resources/scripts/admin/resource/index.js b/xproject-admin/src/main/webapp/resources/scripts/admin/resource/index.js index ca39043..afee856 100644 --- a/xproject-admin/src/main/webapp/resources/scripts/admin/resource/index.js +++ b/xproject-admin/src/main/webapp/resources/scripts/admin/resource/index.js @@ -302,6 +302,8 @@ Vue.onDocumentReady(function() { closeEditDialog: function(){ this.editDialogVisible = false; this.$refs.resourceEditForm.resetFields(); + this.resourceEditForm.resourceId = ''; + this.resourceEditForm.parentResourceId = ''; } } }); diff --git a/xproject-admin/src/main/webapp/resources/scripts/admin/role/index.js b/xproject-admin/src/main/webapp/resources/scripts/admin/role/index.js index 1a1783f..8e975c5 100644 --- a/xproject-admin/src/main/webapp/resources/scripts/admin/role/index.js +++ b/xproject-admin/src/main/webapp/resources/scripts/admin/role/index.js @@ -299,6 +299,7 @@ Vue.onDocumentReady(function() { closeEditDialog: function(){ this.editDialogVisible = false; this.$refs.roleEditForm.resetFields(); + this.roleEditForm.roleId = ''; //手动reset }, loadRoleResourceDataList: function(loading, roleId){ var _this = this; @@ -353,10 +354,12 @@ Vue.onDocumentReady(function() { ]); }, onRoleResourceTreeNodeCheckClick: function(data, node){ - if(node.checked){ - this.recursiveCheckParent(node, node.checked); //当前节点被选中时则选中其所有父节点 - }else{ - this.recursiveCheckChild(node, node.checked); //当前节点被取消选中时则取消选中其所有子节点 + if(this.currentActionType == 'conf'){ + if(!node.checked){ + this.recursiveCheckParent(node, !node.checked); //当前节点被选中时则选中其所有父节点 + }else{ + this.recursiveCheckChild(node, !node.checked); //当前节点被取消选中时则取消选中其所有子节点 + } } }, recursiveCheckParent: function(node, checked){ diff --git a/xproject-admin/src/main/webapp/resources/scripts/admin/user/index.js b/xproject-admin/src/main/webapp/resources/scripts/admin/user/index.js index 40a7a83..e30996f 100644 --- a/xproject-admin/src/main/webapp/resources/scripts/admin/user/index.js +++ b/xproject-admin/src/main/webapp/resources/scripts/admin/user/index.js @@ -302,48 +302,55 @@ Vue.onDocumentReady(function() { }, openUserEditDialog: function(cmd, row){ this.currentActionType = cmd; - if(cmd == 'edit'){ - this.userEditForm.userId = row.userId; - this.userEditForm.userName = row.userName; - this.userEditForm.realName = row.realName; - this.userEditForm.mobilePhone = row.mobilePhone; - this.userEditForm.email = row.email; - this.userEditForm.userIcon = row.userIcon; - this.userEditForm.userIconUrl = row.userIconUrl; - } this.editDialogVisible = true; + var _this = this; + Vue.nextTick(function(){ + if(cmd == 'edit'){ + _this.userEditForm.userId = row.userId; + _this.userEditForm.userName = row.userName; + _this.userEditForm.realName = row.realName; + _this.userEditForm.mobilePhone = row.mobilePhone; + _this.userEditForm.email = row.email; + _this.userEditForm.userIcon = row.userIcon; + _this.userEditForm.userIconUrl = row.userIconUrl; + } + }); }, closeEditDialog: function(){ this.editDialogVisible = false; this.$refs.userEditForm.resetFields(); + this.userEditForm.userId = ''; //手动reset }, openUserViewConfigDialog: function(cmd, row){ this.currentActionType = cmd; - this.userViewConfigForm.userId = row.userId; - this.userViewConfigForm.userName = row.userName; - this.userViewConfigForm.realName = row.realName; - this.userViewConfigForm.mobilePhone = row.mobilePhone; - this.userViewConfigForm.email = row.email; - this.userViewConfigForm.userIcon = row.userIcon; - this.userViewConfigForm.userIconUrl = row.userIconUrl; - this.userViewConfigForm.userType = row.userType; - this.userViewConfigForm.userTypeName = row.userTypeName; - this.userViewConfigForm.status = row.status; - this.userViewConfigForm.statusName = row.statusName; - this.userViewConfigForm.lastLoginTime = row.lastLoginTime; - this.userViewConfigForm.loginTimes = row.loginTimes; - this.userViewConfigForm.createBy = row.createBy; - this.userViewConfigForm.createTime = row.createTime; - this.userViewConfigForm.updateBy = row.updateBy; - this.userViewConfigForm.updateTime = row.updateTime; - if(cmd == 'conf'){ - this.viewConfigActiveTabName = 'userRoleConfig'; - this.queryUserRoleList(1500); - }else{ - this.viewConfigActiveTabName = 'userDetail'; - this.queryUserRoleList(0); - } - this.viewConfigDialogVisible = true; + this.viewConfigDialogVisible = true; + var _this = this; + Vue.nextTick(function(){ + _this.userViewConfigForm.userId = row.userId; + _this.userViewConfigForm.userName = row.userName; + _this.userViewConfigForm.realName = row.realName; + _this.userViewConfigForm.mobilePhone = row.mobilePhone; + _this.userViewConfigForm.email = row.email; + _this.userViewConfigForm.userIcon = row.userIcon; + _this.userViewConfigForm.userIconUrl = row.userIconUrl; + _this.userViewConfigForm.userType = row.userType; + _this.userViewConfigForm.userTypeName = row.userTypeName; + _this.userViewConfigForm.status = row.status; + _this.userViewConfigForm.statusName = row.statusName; + _this.userViewConfigForm.lastLoginTime = row.lastLoginTime; + _this.userViewConfigForm.loginTimes = row.loginTimes; + _this.userViewConfigForm.createBy = row.createBy; + _this.userViewConfigForm.createTime = row.createTime; + _this.userViewConfigForm.updateBy = row.updateBy; + _this.userViewConfigForm.updateTime = row.updateTime; + if(cmd == 'conf'){ + _this.viewConfigActiveTabName = 'userRoleConfig'; + _this.queryUserRoleList(1500); + }else{ + _this.viewConfigActiveTabName = 'userDetail'; + _this.queryUserRoleList(0); + } + }); }, closeUserViewConfigDialog: function(){ this.viewConfigDialogVisible = false; @@ -357,9 +364,12 @@ Vue.onDocumentReady(function() { }, openChangePwdDialog: function(cmd, row){ this.currentActionType = cmd; - this.changePwdForm.userId = row.userId; - this.changePwdForm.userName = row.userName; this.changePwdDialogVisible = true; + var _this = this; + Vue.nextTick(function(){ + _this.changePwdForm.userId = row.userId; + _this.changePwdForm.userName = row.userName; + }); }, closeChangePwdDialog: function(){ this.changePwdDialogVisible = false; diff --git a/xproject-common/src/main/java/com/certusnet/xproject/common/support/AbstractSpringTypedBeanManager.java b/xproject-common/src/main/java/com/certusnet/xproject/common/support/AbstractSpringTypedBeanManager.java index 4a614fd..d42ad18 100644 --- a/xproject-common/src/main/java/com/certusnet/xproject/common/support/AbstractSpringTypedBeanManager.java +++ b/xproject-common/src/main/java/com/certusnet/xproject/common/support/AbstractSpringTypedBeanManager.java @@ -8,6 +8,7 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.web.context.WebApplicationContext; import com.certusnet.xproject.common.util.CollectionUtils; @@ -23,7 +24,7 @@ public abstract class AbstractSpringTypedBeanManager implements SpringTyped private final Map typeOfMap = new HashMap(); public AbstractSpringTypedBeanManager() { - Class c = getClass(); + Class c = getThisSuperclass(getClass()); Type t = c.getGenericSuperclass(); if (t instanceof ParameterizedType) { Type[] ps = ((ParameterizedType) t).getActualTypeArguments(); @@ -39,7 +40,15 @@ public AbstractSpringTypedBeanManager() { protected Class getTypeOf() { return typeOf; } - + + protected Class getThisSuperclass(Class clazz) { + if(clazz.getSuperclass().equals(AbstractSpringTypedBeanManager.class)){ + return clazz; + }else{ + return getThisSuperclass(clazz.getSuperclass()); + } + } + public T getTypedBean(P parameter) { if(!loaded){ synchronized (typeOfMap) { @@ -65,9 +74,16 @@ public T getTypedBean(P parameter) { } public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; + //如果参数applicationContext是容器环境下SpringMVC Application上下文,则取其parent (ROOT) + if(applicationContext instanceof WebApplicationContext && applicationContext.getParent() != null){ + this.applicationContext = applicationContext.getParent(); + } } + public ApplicationContext getApplicationContext() { + return applicationContext; + } + protected T processBean(T bean) { return bean; } diff --git a/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLogHandler.java b/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLogHandler.java deleted file mode 100644 index 5bfc554..0000000 --- a/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLogHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.certusnet.xproject.common.web.springmvc.interceptor; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.certusnet.xproject.common.support.HttpAccessLogging; -/** - * 日志处理类,如将日志写入数据库、日志文件等等 - * - * @param - * @author pengpeng - * @date 2014年10月17日 下午7:24:08 - * @version 1.0 - */ -public abstract class AbstractHttpAccessLogHandler implements Runnable { - - private static final Logger logger = LoggerFactory.getLogger(AbstractHttpAccessLogHandler.class); - - private final HttpAccessLog httpAccessLog; - - public AbstractHttpAccessLogHandler(HttpAccessLog httpAccessLog) { - super(); - this.httpAccessLog = httpAccessLog; - } - - public void run() { - try { - handleLogger(httpAccessLog); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - } - - /** - * 获取日志的记录方式 - * @return - */ - public abstract HttpAccessLogging.LoggingType getLoggingType(); - - /** - * 日志处理方法,如将日志写入数据库、日志文件等等 - * @param httpAccessLog - * @throws Exception - */ - public abstract void handleLogger(HttpAccessLog httpAccessLog) throws Exception; - -} diff --git a/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLoggingInterceptor.java b/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLoggingInterceptor.java index c6bc56e..00d26d8 100644 --- a/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLoggingInterceptor.java +++ b/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/AbstractHttpAccessLoggingInterceptor.java @@ -30,7 +30,9 @@ import org.springframework.web.util.ContentCachingResponseWrapper; import com.certusnet.xproject.common.consts.GlobalConstants; +import com.certusnet.xproject.common.support.AbstractSpringTypedBeanManager; import com.certusnet.xproject.common.support.HttpAccessLogging; +import com.certusnet.xproject.common.support.HttpAccessLogging.LoggingType; import com.certusnet.xproject.common.support.Messages; import com.certusnet.xproject.common.support.NamedThreadFactory; import com.certusnet.xproject.common.util.CollectionUtils; @@ -45,11 +47,12 @@ /** * Http请求日志记录拦截器 * - * @author pengpeng - * @date 2014年10月16日 下午9:21:35 - * @version 1.0 + * @author pengpeng + * @date 2017年5月20日 下午4:16:20 + * @version 1.0 */ -public abstract class AbstractHttpAccessLoggingInterceptor implements HandlerInterceptor, DisposableBean { +@SuppressWarnings("unchecked") +public abstract class AbstractHttpAccessLoggingInterceptor extends AbstractSpringTypedBeanManager implements HandlerInterceptor, DisposableBean { private static final Pattern messageSourceCodePattern = Pattern.compile("\\$\\{([a-zA-Z0-9_.]+)\\}"); @@ -121,7 +124,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons httpAccessLog.setRequestHeader(extractRequestHeader(request, loggingContext)); } getLoggingContextThreadLocal().set(loggingContext); - logger.debug(">>> access logging [preHandle] : " + httpAccessLog); + //logger.debug(">>> access logging [preHandle] : " + httpAccessLog); } } } catch (Throwable e) { @@ -140,7 +143,7 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response, if(httpAccessLog != null){ httpAccessLog.setAccessEndMillis(System.currentTimeMillis()); httpAccessLog.setProcessTime1(httpAccessLog.getAccessEndMillis() - httpAccessLog.getAccessBeginMillis()); - logger.debug(">>> access logging [postHandle] : " + httpAccessLog); + //logger.debug(">>> access logging [postHandle] : " + httpAccessLog); } } } @@ -158,14 +161,11 @@ public void afterCompletion(HttpServletRequest request, HttpServletResponse resp httpAccessLog.setProcessTime2(nowTimeMillis - httpAccessLog.getAccessEndMillis()); httpAccessLog.setAccessEndMillis(nowTimeMillis); httpAccessLog.setLoggingCompleted(true); - httpAccessLog.setRequestParameter(extractRequestParameter(request, loggingContext)); - httpAccessLog.setAccessUser(getAccessUser(request, loggingContext)); httpAccessLog.setResponseContentType(getContentType(response.getContentType())); httpAccessLog.setResponseResult(extractResponseResult(response, loggingContext)); - logger.debug(">>> access logging [postHandle] : " + httpAccessLog); - AbstractHttpAccessLogHandler httpAccessLogHandler = createHttpAccessLoggerHandler(loggingContext); - if(httpAccessLogHandler != null){ - getHttpAccessLogHandlerExecutor().execute(httpAccessLogHandler); + HttpAccessLogDAO httpAccessLogDAO = getHttpAccessLogDAO(loggingContext); + if(httpAccessLogDAO != null){ + getHttpAccessLogHandlerExecutor().submit(new DefaultHttpAccessLoggingTask(request, response, loggingContext, httpAccessLogDAO)); } } } @@ -256,7 +256,6 @@ protected HttpRequestParameter extractRequestParameter(HttpServletRequest reques * @param loggingContext * @return */ - @SuppressWarnings("unchecked") protected HttpRequestParameter excludeRequestParameter(HttpRequestParameter parameter, LoggingContext loggingContext) { HttpAccessLogging httpAccessLogging = loggingContext.httpAccessLogging; String[] excludeNameParams = httpAccessLogging.excludeParamNames(); @@ -289,7 +288,6 @@ protected HttpRequestParameter excludeRequestParameter(HttpRequestParameter para * @param parameter * @param paramName */ - @SuppressWarnings("unchecked") protected void excludeParameter(Map parameter, String paramName) { if(!CollectionUtils.isEmpty(parameter)){ parameter.remove(paramName); @@ -384,6 +382,13 @@ public void destroy() throws Exception { getHttpAccessLogHandlerExecutor().shutdown(); } + protected boolean filterBean(HttpAccessLogDAO httpAccessLogDAO, LoggingType parameter) { + if(parameter != null){ + return parameter.equals(httpAccessLogDAO.getLoggingType()); + } + return false; + } + /** * 获取操作人的LoginUser对象 * @param request @@ -397,7 +402,9 @@ public void destroy() throws Exception { * @param loggingContext * @return */ - protected abstract AbstractHttpAccessLogHandler createHttpAccessLoggerHandler(LoggingContext loggingContext); + protected HttpAccessLogDAO getHttpAccessLogDAO(LoggingContext loggingContext) { + return getTypedBean(loggingContext.getHttpAccessLogging().loggingType()); + } /** * 日志记录上下文 @@ -450,4 +457,40 @@ public void setModelAndView(ModelAndView modelAndView) { } + @SuppressWarnings("unused") + public class DefaultHttpAccessLoggingTask implements Runnable { + + private final HttpServletRequest request; + + private final HttpServletResponse response; + + private final LoggingContext loggingContext; + + private final HttpAccessLogDAO httpAccessLogDAO; + + public DefaultHttpAccessLoggingTask(HttpServletRequest request, HttpServletResponse response, LoggingContext loggingContext, HttpAccessLogDAO httpAccessLogDAO) { + super(); + this.request = request; + this.response = response; + this.loggingContext = loggingContext; + this.httpAccessLogDAO = httpAccessLogDAO; + } + + public void run() { + try { + HttpAccessLog httpAccessLog = loggingContext.getHttpAccessLog(); + if (httpAccessLog != null) { + httpAccessLog.setRequestParameter(extractRequestParameter(request, loggingContext)); + httpAccessLog.setAccessUser(getAccessUser(request, loggingContext)); + logger.debug(">>> http access log : " + httpAccessLog); + httpAccessLogDAO.saveLog((HttpAccessLog) httpAccessLog); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + } + + } + } diff --git a/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/HttpAccessLogDAO.java b/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/HttpAccessLogDAO.java new file mode 100644 index 0000000..71d0925 --- /dev/null +++ b/xproject-common/src/main/java/com/certusnet/xproject/common/web/springmvc/interceptor/HttpAccessLogDAO.java @@ -0,0 +1,27 @@ +package com.certusnet.xproject.common.web.springmvc.interceptor; + +import com.certusnet.xproject.common.support.HttpAccessLogging; +/** + * 日志DAO,如将日志写入数据库、日志文件等等 + * + * @param + * @author pengpeng + * @date 2014年10月17日 下午7:24:08 + * @version 1.0 + */ +public interface HttpAccessLogDAO { + + /** + * 获取日志的记录方式 + * @return + */ + public HttpAccessLogging.LoggingType getLoggingType(); + + /** + * 日志处理方法,如将日志写入数据库、日志文件等等 + * @param httpAccessLog + * @throws Exception + */ + public void saveLog(HttpAccessLog httpAccessLog) throws Exception; + +}