package com.ruoyi.web.modules.technology.support;

import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.web.modules.technology.domain.BizPracticalTraining;
import com.ruoyi.web.modules.technology.mapper.BizPracticalTrainingMapper;

/**
 * 刷新并持久化培训状态与实际报名人数。
 */
@Component
public class PracticalTrainingStatusSupport
{
    @Autowired
    private BizPracticalTrainingMapper bizPracticalTrainingMapper;

    public void refreshAndPersist(BizPracticalTraining row, Date now)
    {
        if (row == null || row.getId() == null || now == null)
        {
            return;
        }
        PracticalTrainingEnrollStatusResolver.applyEnrollStatus(row, now);
        bizPracticalTrainingMapper.updateTrainingStatusAndCount(row);
    }

    public void refreshCountAndPersist(BizPracticalTraining row, int actualCount, Date now)
    {
        if (row == null || row.getId() == null || now == null)
        {
            return;
        }
        row.setActualEnrolledCount(actualCount);
        refreshAndPersist(row, now);
    }
}
