package com.ruoyi.business.test.service.impl;

import java.util.Arrays;
import java.util.List;

import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ruoyi.common.utils.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.business.test.mapper.TestStudentsScoresMapper;
import com.ruoyi.business.test.domain.TestStudentsScores;
import com.ruoyi.business.test.service.ITestStudentsScoresService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 学生成绩Service业务层处理
 * 
 * @author Duke_yzl
 * @date 2025-02-18
 */
@Service
public class TestStudentsScoresServiceImpl extends MPJBaseServiceImpl<TestStudentsScoresMapper, TestStudentsScores> implements ITestStudentsScoresService
{
    @Resource
    private TestStudentsScoresMapper testStudentsScoresMapper;


    /**
     * 查询学生成绩
     * 
     * @param scoreId 学生成绩主键
     * @return 学生成绩
     */
    @Override
    public TestStudentsScores selectTestStudentsScoresByScoreId(Long scoreId)
    {
        return getById(scoreId);
    }

    /**
     * 查询学生成绩列表
     * 
     * @param testStudentsScores 学生成绩
     * @return 学生成绩
     */
    @Override
    public List<TestStudentsScores> selectTestStudentsScoresList(TestStudentsScores testStudentsScores)
    {
        MPJLambdaWrapper<TestStudentsScores> selectTestStudentsScoresList = new MPJLambdaWrapper<TestStudentsScores>()
                    .selectAll(TestStudentsScores.class)
                    .eq(StringUtils.isNotNull(testStudentsScores.getStudentId()),TestStudentsScores::getStudentId,testStudentsScores.getStudentId())
                    .like(StringUtils.isNotBlank(testStudentsScores.getCourseName()),TestStudentsScores::getCourseName,testStudentsScores.getCourseName())
                    .eq(StringUtils.isNotNull(testStudentsScores.getScore()),TestStudentsScores::getScore,testStudentsScores.getScore())
 ;

        return selectJoinList(TestStudentsScores.class, selectTestStudentsScoresList);
    }

    /**
     * 新增学生成绩
     * 
     * @param testStudentsScores 学生成绩
     * @return 结果
     */
    @Override
    public boolean insertTestStudentsScores(TestStudentsScores testStudentsScores)
    {
        return save(testStudentsScores);
    }

    /**
     * 修改学生成绩
     * 
     * @param testStudentsScores 学生成绩
     * @return 结果
     */
    @Override
    public boolean updateTestStudentsScores(TestStudentsScores testStudentsScores)
    {
        return updateById(testStudentsScores);
    }

    /**
     * 批量删除学生成绩
     * 
     * @param scoreIds 需要删除的学生成绩主键
     * @return 结果
     */
    @Transactional(
            rollbackFor = {Exception.class}
    )
    @Override
    public boolean deleteTestStudentsScoresByScoreIds(Long[] scoreIds)
    {
        return removeBatchByIds(Arrays.asList(scoreIds));
    }

    /**
     * 删除学生成绩信息
     * 
     * @param scoreId 学生成绩主键
     * @return 结果
     */
    @Override
    public boolean deleteTestStudentsScoresByScoreId(Long scoreId)
    {
        return removeById(scoreId);
    }
}
