|
|
@@ -1,25 +1,15 @@
|
|
|
package com.etotem.cfc.service;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.entity.UserContentWeight;
|
|
|
-import com.etotem.cfc.mapper.UserContentWeightMapper;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.Collections;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 用户内容偏好权重服务。
|
|
|
* 表为空时返回空列表,推荐排序将自动回退到 matchScore。
|
|
|
*/
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class UserContentWeightService {
|
|
|
-
|
|
|
- @Resource
|
|
|
- private UserContentWeightMapper userContentWeightMapper;
|
|
|
+public interface UserContentWeightService {
|
|
|
|
|
|
/**
|
|
|
* 查询内容偏好权重列表。
|
|
|
@@ -31,22 +21,18 @@ public class UserContentWeightService {
|
|
|
* @param itemId 内容ID
|
|
|
* @return 权重列表(表为空时返回空列表)
|
|
|
*/
|
|
|
- public List<UserContentWeight> listWeights(Long userId, Long familyId, String contentType, Long itemId) {
|
|
|
- if (familyId == null || contentType == null || itemId == null) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
- try {
|
|
|
- return userContentWeightMapper.selectList(
|
|
|
- new LambdaQueryWrapper<UserContentWeight>()
|
|
|
- .eq(UserContentWeight::getFamilyId, familyId)
|
|
|
- .eq(UserContentWeight::getContentType, contentType)
|
|
|
- .eq(UserContentWeight::getItemId, itemId)
|
|
|
- .eq(userId != null, UserContentWeight::getUserId, userId)
|
|
|
- );
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn("查询用户内容偏好权重失败: familyId={}, contentType={}, itemId={}, error={}",
|
|
|
- familyId, contentType, itemId, e.getMessage());
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
- }
|
|
|
+ List<UserContentWeight> listWeights(Long userId, Long familyId, String contentType, Long itemId);
|
|
|
+
|
|
|
+ /** 查询单个用户的内容偏好权重,不存在返回 null */
|
|
|
+ UserContentWeight getWeight(Long userId, Long familyId, String contentType, Long itemId);
|
|
|
+
|
|
|
+ /** 保存/更新一条内容偏好权重(id 非空则更新,否则新增) */
|
|
|
+ void saveWeight(UserContentWeight weight);
|
|
|
+
|
|
|
+ /** 直接更新指定内容的权重值 */
|
|
|
+ void updateWeight(Long userId, Long familyId, String contentType, Long itemId, BigDecimal newWeight);
|
|
|
+
|
|
|
+ /** 记录一次内容行为,按增量累加权重(上限 10.0),无记录时新建 */
|
|
|
+ void recordBehavior(Long userId, Long familyId, String contentType, Long itemId,
|
|
|
+ String dimensionCode, BigDecimal increment, String reason);
|
|
|
}
|