package org.jeecg.modules.database.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.database.entity.Experiment;
import org.jeecg.modules.database.entity.ExperimentRating;
import org.jeecg.modules.database.mapper.ExperimentRatingMapper;
import org.jeecg.modules.database.service.IExperimentRatingService;
import org.jeecg.modules.database.service.IExperimentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Description: 试验评分
 * @Author: jeecg-boot
 * @Date: 2024-11-16
 * @Version: V1.0
 */
@Service
public class ExperimentRatingServiceImpl extends ServiceImpl<ExperimentRatingMapper, ExperimentRating> implements IExperimentRatingService {

    @Autowired
    private IExperimentService experimentService;

    @Override
    public void fetchExperimentDetail(ExperimentRating experimentRating) {
        if (Objects.isNull(experimentRating)) {
            return;
        }
        Experiment experiment = experimentService.getById(experimentRating.getExperimentId());
        if (Objects.isNull(experiment)) {
            return;
        }
        experimentRating.setExperimentName(experiment.getName());
        experimentRating.setExperimentNo(experiment.getExperimentNo());
    }
}
