package jnpf.cultivate.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.cultivate.mapper.CultivateExamSettingMapper;
import jnpf.cultivate.service.CultivateExamSettingService;
import jnpf.model.cultivate.po.exam.FtbCultivateExamSettingEntity;
import jnpf.model.cultivate.v2.exam.req.V2ExamSettingReq;
import jnpf.util.ServiceException;
import jnpf.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Desc 考试配置-实现类
 * @Author shangyi
 * @Date 2026/1/22
 */
@Slf4j
@Service
public class CultivateExamSettingServiceImpl extends ServiceImpl<CultivateExamSettingMapper, FtbCultivateExamSettingEntity> implements CultivateExamSettingService {

    @Override
    public void saveExamSetting(V2ExamSettingReq req) {
        //id = 1就是全局配置
        req.setId("1");
        FtbCultivateExamSettingEntity entity = this.getById(req.getId());
        if (Objects.isNull(entity)) {
            throw new ServiceException("要更新的考试配置不存在");
        }
        BeanUtil.copyProperties(req, entity);
        this.updateById(entity);

    }
}
