feat(数据库): 扩展数据库查询操作符并优化联系人分组逻辑

- 在 DatabaseService 中添加新的查询操作符(notEqual, aboveOrEqual, belowOrEqual, contains, anyOf, notIn, between)
- 修改 createContractList 方法以支持未分组联系人的查询
- 添加调试日志用于跟踪缓存结果和真实分组
This commit is contained in:
2025-09-18 15:04:06 +08:00
parent 5b5a05d8c5
commit d110c97424
3 changed files with 55 additions and 7 deletions

View File

@@ -12,16 +12,36 @@ export const createContractList = async (
countLables: ContactGroupByLabel[],
) => {
// 根据 groupType 决定查询不同的服务
const realGroup = countLables
.filter(item => item.id !== 0)
.map(item => item.id);
console.log(realGroup);
const dataByLabels = [];
for (const label of countLables) {
let data;
if (label.groupType === 1) {
// groupType: 1, 查询 contractService
data = await contractService.findWhere("groupId", label.id);
// 过滤出 kfSelected 对应的联系人
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
console.log(label.groupName);
if (label.id == 0) {
data = await contractService.findWhereMultiple([
{
field: "groupId",
operator: "notIn",
value: realGroup,
},
]);
// 过滤出 kfSelected 对应的联系人
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
}
} else {
data = await contractService.findWhere("groupId", label.id);
// 过滤出 kfSelected 对应的联系人
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
}
}
// console.log(`标签 ${label.groupName} 对应的联系人数据:`, data);
} else if (label.groupType === 2) {
// groupType: 2, 查询 weChatGroupService

View File

@@ -131,6 +131,8 @@ export const useCkChatStore = createPersistStore<CkChatState>(
lastSearchKeyword = state.searchKeyword;
}
console.log("cachedResult", cachedResult);
return cachedResult;
};
})(),