package com.ruoyi.web.modules.booking.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.modules.booking.service.IExpertRatingSyncService;
import com.ruoyi.web.modules.booking.support.ExpertRatingRecalculator;
import com.ruoyi.web.modules.farming.mapper.BizServiceAppointmentReviewMapper;
import com.ruoyi.web.modules.farming.mapper.BizTechResourceMapper;

/**
 * 专家评分定时同步实现。
 */
@Service
public class ExpertRatingSyncServiceImpl implements IExpertRatingSyncService
{
    private static final Logger log = LoggerFactory.getLogger(ExpertRatingSyncServiceImpl.class);

    @Autowired
    private BizServiceAppointmentReviewMapper bizServiceAppointmentReviewMapper;

    @Autowired
    private BizTechResourceMapper bizTechResourceMapper;

    @Override
    public int syncAllExpertRatings()
    {
        int count = ExpertRatingRecalculator.recalculateAllWithReviews(bizServiceAppointmentReviewMapper,
                bizTechResourceMapper);
        log.info("专家 expert_rating 同步完成，更新 {} 位专家", count);
        return count;
    }
}
