package com.ruoyi.mall.service.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.mall.domain.Vo.TextSchoolVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MallTestSchoolMapper;
import com.ruoyi.mall.domain.MallTestSchool;
import com.ruoyi.mall.service.IMallTestSchoolService;

import javax.annotation.Resource;

/**
 * 校考院校Service业务层处理
 *
 * @author ruoyi
 * @date 2023-11-01
 */
@Service
public class MallTestSchoolServiceImpl implements IMallTestSchoolService
{
    @Resource
    private MallTestSchoolMapper mallTestSchoolMapper;

    /**
     * 查询校考院校
     *
     * @param testSchoolId 校考院校主键
     * @return 校考院校
     */
    @Override
    public MallTestSchool selectMallTestSchoolByTestSchoolId(Long testSchoolId)
    {

        return mallTestSchoolMapper.selectMallTestSchoolByTestSchoolId(testSchoolId);
    }

    /**
     * 查询校考院校列表
     *
     * @param mallTestSchool 校考院校
     * @return 校考院校
     */
    @Override
    public List<MallTestSchool> selectMallTestSchoolList(MallTestSchool mallTestSchool)
    {
        return mallTestSchoolMapper.selectMallTestSchoolList(mallTestSchool);
    }

    /**
     * 新增校考院校
     *
     * @param mallTestSchool 校考院校
     * @return 结果
     */
    @Override
    public int insertMallTestSchool(MallTestSchool mallTestSchool)
    {

        mallTestSchool.setCreateTime(DateUtils.getNowDate());
        mallTestSchool.setDelFlag(0);
        return mallTestSchoolMapper.insertMallTestSchool(mallTestSchool);
    }

    /**
     * 修改校考院校
     *
     * @param mallTestSchool 校考院校
     * @return 结果
     */
    @Override
    public int updateMallTestSchool(MallTestSchool mallTestSchool)
    {
        mallTestSchool.setUpdateTime(DateUtils.getNowDate());
        return mallTestSchoolMapper.updateMallTestSchool(mallTestSchool);
    }

    /**
     * 批量删除校考院校
     *
     * @param testSchoolIds 需要删除的校考院校主键
     * @return 结果
     */
    @Override
    public int deleteMallTestSchoolByTestSchoolIds(Long[] testSchoolIds)
    {
        return mallTestSchoolMapper.deleteMallTestSchoolByTestSchoolIds(testSchoolIds);
    }

    /**
     * 删除校考院校信息
     *
     * @param testSchoolId 校考院校主键
     * @return 结果
     */
    @Override
    public int deleteMallTestSchoolByTestSchoolId(Long testSchoolId)
    {
        return mallTestSchoolMapper.deleteMallTestSchoolByTestSchoolId(testSchoolId);
    }

    /**
     * 校考院校
     * @param searchValue 搜索词
     * @param acceptYear 年份
     * @param majorId 专业id
     * @return 结果
     */
    @Override
    public PageInfo<TextSchoolVO> selectTestSchoolList(String searchValue,
                                                       String acceptYear,
                                                       Integer majorId,
                                                       Integer pageNum,
                                                       Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<TextSchoolVO> list = mallTestSchoolMapper.selectTestSchoolList(searchValue, acceptYear, majorId);
        return new PageInfo<>(list);
    }
}
