1、处理标签表不存在问题

2、优化启动脚本
3、微信解密必须要求JDK11以上版本
main
linlei 2 years ago
parent 9946cf16e9
commit c8a4069885

@ -1,5 +1,6 @@
package com.xcs.wx.controller;
import cn.hutool.system.SystemUtil;
import com.xcs.wx.domain.dto.DecryptDTO;
import com.xcs.wx.domain.vo.ResponseVO;
import com.xcs.wx.domain.vo.WeChatVO;
@ -31,6 +32,10 @@ public class DatabaseController {
*/
@GetMapping("/decrypt")
public ResponseVO<Boolean> decrypt(DecryptDTO decryptDTO) {
// 读取JDK版本号
if (SystemUtil.getJavaInfo().getVersionInt() < 1100) {
return ResponseVO.error(-1, "微信解密必须要求JDK11以上版本,请更换JDK以上版本。");
}
databaseService.decrypt(decryptDTO);
// 返回数据
return ResponseVO.ok(true);

@ -0,0 +1,41 @@
package com.xcs.wx.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* SQLite
*
* @author xcs
* @date 202461309:18:29
*/
@Data
@TableName("sqlite_master")
public class SqliteMaster {
/**
* type
*/
@TableField("type")
private String type;
/**
* tblName
*/
@TableField("tbl_name")
private String tblName;
/**
* rootPage
*/
@TableField("rootpage")
private String rootPage;
/**
* sql
*/
@TableField("sql")
private String sql;
}

@ -0,0 +1,18 @@
package com.xcs.wx.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcs.wx.domain.Session;
import com.xcs.wx.domain.SqliteMaster;
import com.xcs.wx.domain.vo.SessionVO;
import java.util.List;
/**
* SQLite Mapper
*
* @author xcs
* @date 20231221 1708
**/
public interface SqliteMasterMapper extends BaseMapper<SqliteMaster> {
}

@ -0,0 +1,18 @@
package com.xcs.wx.repository;
/**
* SQLite Repository
*
* @author xcs
* @date 202461309:19:24
*/
public interface SqliteMasterRepository {
/**
*
*
* @param tableName
* @return
*/
boolean isTableExists(String tableName);
}

@ -2,12 +2,15 @@ package com.xcs.wx.repository.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcs.wx.constant.DataSourceType;
import com.xcs.wx.domain.ContactLabel;
import com.xcs.wx.mapper.ContactLabelMapper;
import com.xcs.wx.repository.ContactLabelRepository;
import com.xcs.wx.repository.SqliteMasterRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import java.util.Collections;
@ -23,12 +26,14 @@ import java.util.stream.Collectors;
* @date 20231222 1725
**/
@Repository
@RequiredArgsConstructor
@DS(value = DataSourceType.MICRO_MSG_DB)
public class ContactLabelRepositoryImpl extends ServiceImpl<ContactLabelMapper, ContactLabel> implements ContactLabelRepository {
private final SqliteMasterRepository sqliteMasterRepository;
@Override
public Map<String, String> queryContactLabelAsMap() {
// 返回头像并转换成map
return Optional.ofNullable(queryContactLabelAsList())
.map(headImgUrls -> headImgUrls.stream().collect(Collectors.toMap(ContactLabel::getLabelId, ContactLabel::getLabelName)))
.orElse(Collections.emptyMap());
@ -36,9 +41,12 @@ public class ContactLabelRepositoryImpl extends ServiceImpl<ContactLabelMapper,
@Override
public List<ContactLabel> queryContactLabelAsList() {
String contactLabelTableName = TableInfoHelper.getTableInfo(ContactLabel.class).getTableName();
if (!sqliteMasterRepository.isTableExists(contactLabelTableName)) {
return Collections.emptyList();
}
LambdaQueryWrapper<ContactLabel> wrapper = Wrappers.<ContactLabel>lambdaQuery()
.select(ContactLabel::getLabelId,ContactLabel::getLabelName);
// 返回头像并转换成map
.select(ContactLabel::getLabelId, ContactLabel::getLabelName);
return super.list(wrapper);
}
}

@ -39,7 +39,7 @@ public class ContactRepositoryImpl extends ServiceImpl<ContactMapper, Contact> i
@Override
public List<AllContactVO> queryAllContact() {
return getBaseMapper().queryAllContact();
return getBaseMapper().queryAllContact().stream().filter(contactVO -> !contactVO.getNickName().isEmpty()).collect(Collectors.toList());
}
@Override

@ -0,0 +1,21 @@
package com.xcs.wx.repository.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcs.wx.domain.SqliteMaster;
import com.xcs.wx.mapper.SqliteMasterMapper;
import com.xcs.wx.repository.SqliteMasterRepository;
import org.springframework.stereotype.Repository;
@Repository
public class SqliteMasterRepositoryImpl extends ServiceImpl<SqliteMasterMapper, SqliteMaster> implements SqliteMasterRepository {
@Override
public boolean isTableExists(String tableName) {
LambdaQueryWrapper<SqliteMaster> wrapper = Wrappers.<SqliteMaster>lambdaQuery()
.eq(SqliteMaster::getType, "table")
.eq(SqliteMaster::getTblName, tableName);
return super.count(wrapper) > 0;
}
}

@ -51,21 +51,21 @@ public class DatabaseServiceImpl implements DatabaseService, ApplicationRunner {
// 过滤出文件名以.db结尾的文件
.filter(file -> file.toString().endsWith(".db"))
// 过滤指定的数据库文件
.filter(file -> {
String filePath = file.toString();
// 聊天记录数据库
return filePath.matches(".*\\\\MSG\\d+\\.db") ||
// 联系人
filePath.endsWith("MicroMsg.db") ||
// 朋友圈
filePath.endsWith("Sns.db") ||
// 索引联系人
filePath.endsWith("FTSContact.db") ||
// 图片
filePath.endsWith("HardLinkImage.db") ||
// 视频
filePath.endsWith("HardLinkVideo.db");
})
// .filter(file -> {
// String filePath = file.toString();
// // 聊天记录数据库
// return filePath.matches(".*\\\\MSG\\d+\\.db") ||
// // 联系人
// filePath.endsWith("MicroMsg.db") ||
// // 朋友圈
// filePath.endsWith("Sns.db") ||
// // 索引联系人
// filePath.endsWith("FTSContact.db") ||
// // 图片
// filePath.endsWith("HardLinkImage.db") ||
// // 视频
// filePath.endsWith("HardLinkVideo.db");
// })
// 将每个符合条件的文件路径映射为DecryptDTO对象
.map(item -> new DecryptBO(item.toString(), item.toString().replace(scanPath, replacementPath)))
// 批量解密

@ -66,7 +66,7 @@ public class ImgDecoderUtil {
// 获取文件名(不包含扩展名)
String fileName = file.getName();
// 文件名+后缀
String picName = fileName.substring(0, fileName.length() - 4) + extension;
String picName = fileName.replace(".dat", "") + extension;
// 构造输出文件的完整路径
String fileOutPath = Paths.get(outPath, picName).toString();
@ -137,4 +137,8 @@ public class ImgDecoderUtil {
// 如果没有匹配的文件类型,返回错误代码
return new int[]{-1, -1};
}
public static void main(String[] args) {
decodeDat("D:\\xuchengsheng\\output_file1", "D:\\");
}
}

@ -3,7 +3,7 @@
<mapper namespace="com.xcs.wx.mapper.HardLinkImageAttributeMapper">
<!-- 查询群聊 -->
<!-- 查询图片地址 -->
<select id="queryHardLinkImage" resultType="java.lang.String">
SELECT
'\\FileStorage\MsgAttach\\' || hli1.Dir || '\\' || 'Image' || '\\' || hli2.Dir || '\\' || hlia.FileName

@ -21,24 +21,6 @@ set JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=%LOG_HOME%\heapdump.hprof
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
set JAVA_OPTS=%JAVA_OPTS% -XX:-OmitStackTraceInFastThrow
for /f "tokens=3" %%i in ('java -version 2^>^&1 ^| findstr /i "version"') do (
set version=%%i
goto :breakloop
)
:breakloop
for /f "tokens=1-3 delims=." %%a in ("%version%") do (
set MAJOR_VERSION=%%a
)
set MAJOR_VERSION=%MAJOR_VERSION:"=%
set MAJOR_VERSION=%MAJOR_VERSION: =%
if %MAJOR_VERSION% LSS 11 (
echo JDK 版本必须为 11 或更高才能运行该应用程序。
exit /b 1
)
echo Starting the %SERVER_NAME% ...
java %JAVA_OPTS% -Dspring.thymeleaf.prefix=file:../html/ -Dlog.home=%LOG_HOME% -classpath %CLASS_PATH% com.xcs.wx.WxDumpApplication

Loading…
Cancel
Save