| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.EnvironmentAware; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class LogLocalServiceImpl implements ILogLocalService{ |
| | | public class LogLocalServiceImpl implements ILogLocalService, EnvironmentAware { |
| | | |
| | | /** |
| | | * 各个服务存放的的父路径 |
| | |
| | | */ |
| | | private Boolean isWindows = true; |
| | | |
| | | { |
| | | String os = System.getProperty("os.name").toLowerCase(); |
| | | //默认就配置为windows的,如果不是当前系统不是windows就需要对其转换为linux的文件路径格式 |
| | | /** |
| | | * 根据当前运行的环境,对配置的日志路径格式进行调整 |
| | | * @param environment |
| | | */ |
| | | @Override |
| | | public void setEnvironment(Environment environment) { |
| | | String os = environment.getProperty("os.name").toLowerCase(); |
| | | if (!os.contains("win")) { |
| | | this.PARENTPATH = this.PARENTPATH.substring(this.PARENTPATH.lastIndexOf(":") + 1).replace("\\", "/"); |
| | | this.LOGPATH = this.LOGPATH.replace("\\", "/"); |
| | |
| | | throw new ServerException("未获取到该日志路径!"); |
| | | } |
| | | FileObjectBO fileObjectBO = new FileObjectBO(); |
| | | String logFullPaths = localLogVO.getLogFullPaths(); |
| | | String logFullPaths = this.convertWindows2Linux(localLogVO.getLogFullPaths()); |
| | | // 判断是否是父目录 |
| | | if(!localLogVO.getHasChildren()){ |
| | | //只下载一个日志文件 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 下载之前将windows的路径格式转换为linux |
| | | * @param fullPath |
| | | * @return |
| | | */ |
| | | private String convertWindows2Linux(String fullPath){ |
| | | String os = System.getProperty("os.name").toLowerCase(); |
| | | if (!os.contains("win")) { |
| | | fullPath = fullPath.replace("\\", "/"); |
| | | } |
| | | return fullPath; |
| | | } |
| | | |
| | | /** |
| | | * 删除日志文件 |
| | | * @param localLogVO 文件全路径集合 |
| | | * @throws ServerException |