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

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yonge.cooleshow.biz.dal.dao.MusicSheetAuthRecordDao;
import com.yonge.cooleshow.biz.dal.dto.req.TeacherMusicSheetAuditReq;
import com.yonge.cooleshow.biz.dal.entity.MusicSheetAuthRecord;
import com.yonge.cooleshow.biz.dal.service.MusicSheetAuthRecordService;
import com.yonge.cooleshow.common.exception.BizException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;


@Service
public class MusicSheetAuthRecordServiceImpl extends ServiceImpl<MusicSheetAuthRecordDao, MusicSheetAuthRecord> implements MusicSheetAuthRecordService {


    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean audit(TeacherMusicSheetAuditReq param, Long userId) {

        MusicSheetAuthRecord musicSheetAuthRecord = new MusicSheetAuthRecord();
        musicSheetAuthRecord.setMusicSheetId(param.getMusicSheetId());
        musicSheetAuthRecord.setCreateTime(new Date());
        musicSheetAuthRecord.setAuditState(param.getAuthStatus());
        musicSheetAuthRecord.setReason(param.getRemark());
        musicSheetAuthRecord.setVerifyUserId(userId);
        return this.saveOrUpdate(musicSheetAuthRecord);
    }
}