package com.yonge.cooleshow.biz.dal.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.microsvc.toolkit.common.webportal.exception.BizException;
import com.yonge.cooleshow.biz.dal.dao.TeacherSubjectPriceDao;
import com.yonge.cooleshow.biz.dal.entity.TeacherSubjectPrice;
import com.yonge.cooleshow.biz.dal.service.TeacherSubjectPriceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("TeacherSubjectPriceService")
public class TeacherSubjectPriceServiceImpl extends ServiceImpl<TeacherSubjectPriceDao, TeacherSubjectPrice> implements TeacherSubjectPriceService {

    private final static Logger log = LoggerFactory.getLogger(TeacherSubjectPriceServiceImpl.class);

    @Override
    public TeacherSubjectPriceDao getDao() {
        return this.baseMapper;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void upSet(List<TeacherSubjectPrice> teacherSubjectPriceList) {
        Long teacherId = teacherSubjectPriceList.get(0).getTeacherId();
        String courseType = teacherSubjectPriceList.get(0).getCourseType();
        this.lambdaUpdate().eq(TeacherSubjectPrice::getTeacherId, teacherId)
                .eq(TeacherSubjectPrice::getCourseType, courseType).remove();
        this.saveBatch(teacherSubjectPriceList);
    }

}

