package cn.iocoder.yudao.module.course.service.impl;

import cn.iocoder.yudao.module.course.entity.SchoolStudentCommissionRecord;
import cn.iocoder.yudao.module.course.mapper.SchoolStudentCommissionRecordMapper;
import cn.iocoder.yudao.module.course.service.SchoolStudentCommissionRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class SchoolStudentCommissionRecordServiceImpl extends ServiceImpl<SchoolStudentCommissionRecordMapper, SchoolStudentCommissionRecord> implements SchoolStudentCommissionRecordService {

    @Override
    public boolean createRecord(SchoolStudentCommissionRecord record) {
        return save(record);
    }

    @Override
    public boolean updateRecord(SchoolStudentCommissionRecord record) {
        return updateById(record);
    }

    @Override
    public boolean deleteRecord(Long id) {
        return removeById(id);
    }

    @Override
    public SchoolStudentCommissionRecord getRecordById(Long id) {
        return getById(id);
    }

    @Override
    public List<SchoolStudentCommissionRecord> getRecordsByStudentId(Long studentId) {
        return lambdaQuery().eq(SchoolStudentCommissionRecord::getStudentId, studentId).list();
    }

    @Override
    public List<SchoolStudentCommissionRecord> getRecordsByCoachId(Long coachId) {
        return lambdaQuery().eq(SchoolStudentCommissionRecord::getCoachId, coachId).list();
    }

    @Override
    public boolean updateGrantStatus(Long id, Integer isGrant) {
        SchoolStudentCommissionRecord record = new SchoolStudentCommissionRecord();
        record.setId(id);
        record.setIsGrant(isGrant);
        return updateById(record);
    }
}
