feat: 添加DID握手服务和初始化逻辑
refactor: 重构DisputeResolverService和DIDHandshakeService fix: 修复SovereignWealthFundService中的表名错误 docs: 更新AI模块清单和任务总览文档 chore: 添加多个README文件说明项目结构 style: 优化logger日志输出格式 perf: 改进RecommendationService的性能和类型安全 test: 添加DomainBootstrap和test-domain-bootstrap测试文件 build: 配置dashboard的umi相关文件 ci: 添加GitHub工作流配置
This commit is contained in:
@@ -114,7 +114,7 @@ export class RecommendationService {
|
||||
});
|
||||
|
||||
logger.info(`[Recommendation] User behavior recorded: ${params.userId} -> ${params.itemId} (${params.behaviorType})`);
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
logger.error(`[Recommendation] Failed to record user behavior: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ export class RecommendationService {
|
||||
* 获取行为权重
|
||||
*/
|
||||
private static getBehaviorWeight(behaviorType: string): number {
|
||||
const weights = {
|
||||
const weights: { [key: string]: number } = {
|
||||
'view': 1.0,
|
||||
'click': 2.0,
|
||||
'favorite': 3.0,
|
||||
@@ -170,7 +170,7 @@ export class RecommendationService {
|
||||
}
|
||||
|
||||
logger.info(`[Recommendation] Item attributes updated: ${params.itemId}`);
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
logger.error(`[Recommendation] Failed to update item attributes: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
@@ -229,9 +229,8 @@ export class RecommendationService {
|
||||
fromCache: false
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
logger.error(`[Recommendation] Failed to get recommendations: ${error.message}`);
|
||||
|
||||
// 降级策略:返回热门商品
|
||||
const fallback = await this.getPopularItems(params.tenantId, count);
|
||||
return {
|
||||
@@ -383,7 +382,7 @@ export class RecommendationService {
|
||||
|
||||
// 统计标签偏好
|
||||
if (item.tags && Array.isArray(item.tags)) {
|
||||
item.tags.forEach(tag => {
|
||||
item.tags.forEach((tag: string) => {
|
||||
const current = preferences.tags.get(tag) || 0;
|
||||
preferences.tags.set(tag, current + behavior.weight);
|
||||
});
|
||||
@@ -413,7 +412,7 @@ export class RecommendationService {
|
||||
|
||||
// 标签匹配
|
||||
if (item.tags && Array.isArray(item.tags)) {
|
||||
item.tags.forEach(tag => {
|
||||
item.tags.forEach((tag: string) => {
|
||||
if (userPreferences.tags.has(tag)) {
|
||||
score += userPreferences.tags.get(tag) * 0.3;
|
||||
}
|
||||
@@ -476,8 +475,8 @@ export class RecommendationService {
|
||||
.limit(50);
|
||||
|
||||
return itemsFromSimilarUsers.map(item => ({
|
||||
itemId: item.item_id,
|
||||
score: parseInt(item.interaction_count) / similarUsers.length
|
||||
itemId: String(item.item_id),
|
||||
score: parseInt(String(item.interaction_count)) / similarUsers.length
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user