64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
import {
|
|
listRecommendations,
|
|
getRecommendationById,
|
|
insertRecommendation,
|
|
updateRecommendation,
|
|
deleteRecommendation,
|
|
} from "../db/repo.js";
|
|
|
|
export async function handleListRecommendations({ tenantId, q = "", limit = 200 }) {
|
|
const items = await listRecommendations({ tenantId, q, limit });
|
|
return { items };
|
|
}
|
|
|
|
export async function handleGetRecommendation({ tenantId, id }) {
|
|
return getRecommendationById({ tenantId, id });
|
|
}
|
|
|
|
export async function handleCreateRecommendation({
|
|
tenantId,
|
|
rule_key,
|
|
trigger = {},
|
|
queries = [],
|
|
boosts = {},
|
|
ask_slots = [],
|
|
active = true,
|
|
priority = 100,
|
|
trigger_product_ids = [],
|
|
recommended_product_ids = [],
|
|
rule_type = "crosssell",
|
|
trigger_event = null,
|
|
items = [],
|
|
}) {
|
|
return insertRecommendation({
|
|
tenantId, rule_key, trigger, queries, boosts, ask_slots, active, priority,
|
|
trigger_product_ids, recommended_product_ids, rule_type, trigger_event, items
|
|
});
|
|
}
|
|
|
|
export async function handleUpdateRecommendation({
|
|
tenantId,
|
|
id,
|
|
trigger,
|
|
queries,
|
|
boosts,
|
|
ask_slots,
|
|
active,
|
|
priority,
|
|
trigger_product_ids,
|
|
recommended_product_ids,
|
|
rule_type,
|
|
trigger_event,
|
|
items,
|
|
}) {
|
|
return updateRecommendation({
|
|
tenantId, id, trigger, queries, boosts, ask_slots, active, priority,
|
|
trigger_product_ids, recommended_product_ids, rule_type, trigger_event, items
|
|
});
|
|
}
|
|
|
|
export async function handleDeleteRecommendation({ tenantId, id }) {
|
|
const deleted = await deleteRecommendation({ tenantId, id });
|
|
return { deleted };
|
|
}
|