Skip to content

Commit

Permalink
✨1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
oddfar committed Jun 27, 2023
1 parent 5a88845 commit 2cdba44
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 43 deletions.
2 changes: 1 addition & 1 deletion campus-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>campus</artifactId>
<groupId>com.oddfar.campus</groupId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SysMenuController {
* 获取菜单列表
*/
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping(value = "/list",name = "菜单管理-分页")
@GetMapping(value = "/list", name = "菜单管理-分页")
public R list(SysMenuEntity menu) {
List<SysMenuEntity> menus = menuService.selectMenuList(menu, getUserId());
return R.ok(menus);
Expand All @@ -38,15 +38,15 @@ public R list(SysMenuEntity menu) {
* 根据菜单编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}",name = "菜单管理-查询")
@GetMapping(value = "/{menuId}", name = "菜单管理-查询")
public R getInfo(@PathVariable Long menuId) {
return R.ok(menuService.selectMenuById(menuId));
}

/**
* 获取菜单下拉树列表
*/
@GetMapping(value = "/treeselect",name = "菜单管理-获取菜单下拉树列表")
@GetMapping(value = "/treeselect", name = "菜单管理-获取菜单下拉树列表")
public R treeSelect(SysMenuEntity menu) {
List<SysMenuEntity> menus = menuService.selectMenuList(menu, getUserId());
return R.ok(menuService.buildMenuTreeSelect(menus));
Expand All @@ -55,7 +55,7 @@ public R treeSelect(SysMenuEntity menu) {
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}",name = "菜单管理-加载对应角色菜单列表树")
@GetMapping(value = "/roleMenuTreeselect/{roleId}", name = "菜单管理-加载对应角色菜单列表树")
public R roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
List<SysMenuEntity> menus = menuService.selectMenuList(getUserId());
R ajax = R.ok();
Expand All @@ -82,7 +82,7 @@ public R add(@Validated @RequestBody SysMenuEntity menu) {
* 修改菜单
*/
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
@PutMapping("菜单管理-修改")
@PutMapping(name = "菜单管理-修改")
public R edit(@Validated @RequestBody SysMenuEntity menu) {
if (!menuService.checkMenuNameUnique(menu)) {
return R.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
Expand All @@ -98,7 +98,7 @@ public R edit(@Validated @RequestBody SysMenuEntity menu) {
* 删除菜单
*/
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
@DeleteMapping(value = "/{menuId}",name = "菜单管理-删除")
@DeleteMapping(value = "/{menuId}", name = "菜单管理-删除")
public R remove(@PathVariable("menuId") Long menuId) {
if (menuService.hasChildByMenuId(menuId)) {
return R.error("存在子菜单,不允许删除");
Expand Down
2 changes: 1 addition & 1 deletion campus-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>campus</artifactId>
<groupId>com.oddfar.campus</groupId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.oddfar.campus.common.filter;

import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;

/**
* 排除JSON敏感属性
*
* @author ruoyi
*/
public class PropertyPreExcludeFilter extends SimplePropertyPreFilter {
public PropertyPreExcludeFilter() {
}

public PropertyPreExcludeFilter addExcludes(String... filters) {
for (int i = 0; i < filters.length; i++) {
this.getExcludes().add(filters[i]);
}
return this;
}
}
2 changes: 1 addition & 1 deletion campus-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>campus</artifactId>
<groupId>com.oddfar.campus</groupId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.oddfar.campus.common.domain.entity.SysOperLogEntity;
import com.oddfar.campus.common.domain.model.LoginUser;
import com.oddfar.campus.common.enums.BusinessStatus;
import com.oddfar.campus.common.filter.PropertyPreExcludeFilter;
import com.oddfar.campus.common.utils.SecurityUtils;
import com.oddfar.campus.common.utils.ServletUtils;
import com.oddfar.campus.common.utils.StringUtils;
Expand All @@ -25,15 +26,16 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.HandlerMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -47,7 +49,13 @@
@Component
public class LogAspect {

Logger log = LoggerFactory.getLogger(LogAspect.class);
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);

/**
* 排除敏感属性字段
*/
public static final String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};


@Value("${spring.application.name:}")
private String springApplicationName;
Expand Down Expand Up @@ -140,27 +148,6 @@ private Map<String, Object> getAnnotationProp(JoinPoint joinPoint) {
return propMap;
}

/**
* 处理请求之前执行
*
* @param joinPoint 切点
* @throws Throwable
*/
// @Before("webLog()")
public void doBefore(JoinPoint joinPoint) throws Throwable {

// 接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();

// 记录下请求内容
log.info("URL : " + request.getRequestURL().toString());
log.info("HTTP_METHOD : " + request.getMethod());
log.info("IP : " + request.getRemoteAddr());
log.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
log.info("ARGS : " + Arrays.toString(joinPoint.getArgs()));

}

protected void handleLog(final JoinPoint joinPoint, Map<String, Object> annotationProp, final Exception e, Object jsonResult) {

Expand Down Expand Up @@ -248,12 +235,9 @@ private String argsArrayToString(Object[] paramsArray) {
String params = "";
if (paramsArray != null && paramsArray.length > 0) {
for (Object o : paramsArray) {
// if (StringUtils.isNotNull(o) && !isFilterObject(o))
if (StringUtils.isNotNull(o)) {
if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
try {
// String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter());
String jsonObj = JSON.toJSONString(o);

String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter());
params += jsonObj.toString() + " ";
} catch (Exception e) {
}
Expand Down Expand Up @@ -323,4 +307,38 @@ private <T> T invokeAnnotationMethod(Annotation apiResource, String methodName,
return null;
}

/**
* 忽略敏感属性
*/
public PropertyPreExcludeFilter excludePropertyPreFilter() {
return new PropertyPreExcludeFilter().addExcludes(EXCLUDE_PROPERTIES);
}

/**
* 判断是否需要过滤的对象。
*
* @param o 对象信息。
* @return 如果是需要过滤的对象,则返回true;否则返回false。
*/
@SuppressWarnings("rawtypes")
public boolean isFilterObject(final Object o) {
Class<?> clazz = o.getClass();
if (clazz.isArray()) {
return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
} else if (Collection.class.isAssignableFrom(clazz)) {
Collection collection = (Collection) o;
for (Object value : collection) {
return value instanceof MultipartFile;
}
} else if (Map.class.isAssignableFrom(clazz)) {
Map map = (Map) o;
for (Object value : map.entrySet()) {
Map.Entry entry = (Map.Entry) value;
return entry.getValue() instanceof MultipartFile;
}
}
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
|| o instanceof BindingResult;
}

}
2 changes: 1 addition & 1 deletion campus-modular/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>campus</artifactId>
<groupId>com.oddfar.campus</groupId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion campus-modular/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ campus:
# 名称
name: oddfar-campus
# 版本
version: 1.1.1
version: 1.1.3

server:
port: 8160
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.oddfar.campus</groupId>
<artifactId>campus</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<packaging>pom</packaging>

<name>campus</name>
Expand All @@ -21,7 +21,7 @@
</modules>

<properties>
<campus.version>1.1.2</campus.version>
<campus.version>1.1.3</campus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<bitwalker.version>1.21</bitwalker.version>
Expand Down

0 comments on commit 2cdba44

Please sign in to comment.