Skip to content

Commit

Permalink
fix: 非管理员对敏感数据不可见
Browse files Browse the repository at this point in the history
  • Loading branch information
akl7777777 committed Aug 16, 2024
1 parent 3a0ee53 commit a479d8b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN mvn -f /home/app/pom.xml clean package

# 使用基础 Java 镜像运行 JAR 文件
FROM openjdk:11-jre-slim
COPY --from=build /home/app/target/ShellApiLogOptimizer-0.0.1-SNAPSHOT.jar /usr/app/app.jar
COPY --from=build /home/app/target/ShellApiLogOptimizer-0.1.5-SNAPSHOT.jar /usr/app/app.jar
WORKDIR /usr/app
EXPOSE 8080

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ public class LogQueryDTO {
private String sql;
private String ip;

// excludeTypes
private List<Integer> excludeTypes;
// excludeFields
private List<String> excludeFields;
// 可以添加构造函数、builder 方法等,根据需要使用
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,23 @@ public EsPageInfo<Log> pageQuery(LogQueryDTO queryDTO) {
if (StrUtil.isNotBlank(queryDTO.getContent())) {
wrapper.like(Log::getContent, queryDTO.getContent());
}
wrapper.orderBy(true,false,Log::getCreatedAt);

// 处理 excludeTypes
if (queryDTO.getExcludeTypes() != null && !queryDTO.getExcludeTypes().isEmpty()) {
wrapper.not(w -> w.in(Log::getType, queryDTO.getExcludeTypes()));
}

// 处理 excludeFields
if (queryDTO.getExcludeFields() != null && !queryDTO.getExcludeFields().isEmpty()) {
wrapper.notSelect(queryDTO.getExcludeFields().toArray(new String[0]));
}
wrapper.orderBy(true, false, Log::getCreatedAt);

// 物理分页
return logMapper.pageQuery(wrapper, queryDTO.getPage(), queryDTO.getSize());
EsPageInfo<Log> pageInfo = logMapper.pageQuery(wrapper, queryDTO.getPage(), queryDTO.getSize());


return pageInfo;
}

@Override
Expand Down Expand Up @@ -243,6 +257,10 @@ public Long count(LogQueryDTO queryDTO) {
if (StrUtil.isNotBlank(queryDTO.getContent())) {
wrapper.like(Log::getContent, queryDTO.getContent());
}
// 处理 excludeTypes
if (queryDTO.getExcludeTypes() != null && !queryDTO.getExcludeTypes().isEmpty()) {
wrapper.not(w -> w.in(Log::getType, queryDTO.getExcludeTypes()));
}

return logMapper.selectCount(wrapper);
}
Expand Down

0 comments on commit a479d8b

Please sign in to comment.