package com.ruoyi.mall.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.mall.domain.MallBatch;
import com.ruoyi.mall.domain.MallExamData;
import com.ruoyi.mall.domain.MallSubjectClass;
import com.ruoyi.mall.domain.Vo.BatchVO;
import com.ruoyi.mall.mapper.MallBatchMapper;
import com.ruoyi.mall.mapper.MallExamDataMapper;
import com.ruoyi.mall.mapper.MallSubjectClassMapper;
import com.ruoyi.mall.service.IMallBatchService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 录取批次Service业务层处理
 *
 * @author Lsm
 * @date 2023-10-18
 */
@Service
public class MallBatchServiceImpl implements IMallBatchService
{
    @Resource
    private MallBatchMapper mallBatchMapper;

    @Resource
    private MallSubjectClassMapper mallSubjectClassMapper;

    @Resource
    private MallExamDataMapper mallExamDataMapper;

    /**
     * 查询录取批次
     *
     * @param batchId 录取批次主键
     * @return 录取批次
     */
    @Override
    public MallBatch selectMallBatchByMallBatchId(Long batchId)
    {
        return mallBatchMapper.selectMallBatchByBatchId(batchId);
    }

    /**
     * 查询录取批次列表
     *
     * @param mallBatch 录取批次
     * @return 录取批次
     */
    @Override
    public List<MallBatch> selectMallBatchList(MallBatch mallBatch)
    {
        return mallBatchMapper.selectMallBatchList(mallBatch);
    }

    /**
     * 新增录取批次
     *
     * @param mallBatch 录取批次
     * @return 结果
     */
    @Override
    public int insertMallBatch(MallBatch mallBatch)
    {
        if(mallBatch.getBatchName().contains("专科")){
            mallBatch.setBatchType(1);
        }else{
            mallBatch.setBatchType(0);
        }
        mallBatch.setDisplayStatus(0);
        mallBatch.setCreateAt(DateUtils.getTime());
        mallBatch.setDelFlag("0");
        return mallBatchMapper.insertMallBatch(mallBatch);
    }

    /**
     * 修改录取批次
     *
     * @param mallBatch 录取批次
     * @return 结果
     */
    @Override
    public int updateMallBatch(MallBatch mallBatch)
    {
        mallBatch.setCreateAt(DateUtils.getTime());
        return mallBatchMapper.updateMallBatch(mallBatch);
    }

    /**
     * 批量删除录取批次
     *
     * @param mallBatchIds 需要删除的录取批次主键
     * @return 结果
     */
    @Override
    public int deleteMallBatchByMallBatchIds(Long[] mallBatchIds)
    {
        return mallBatchMapper.deleteMallBatchByBatchIds(mallBatchIds);
    }

    /**
     * 删除录取批次信息
     *
     * @param mallBatchId 录取批次主键
     * @return 结果
     */
    @Override
    public int deleteMallBatchByMallBatchId(Long mallBatchId)
    {
        return mallBatchMapper.deleteMallBatchByBatchId(mallBatchId);
    }

    /**
     * 批次查询列表
     * @return
     */
    @Override
    public List<BatchVO> selectBatchList() {
        // 批次列表
        return mallBatchMapper.selectBatchList();
    }

    /**
     * 所有批次
     * @return 结果
     */
    @Override
    public List<BatchVO> selectAllBatchList() {
        return  mallBatchMapper.selectAllBatchList();
    }
}
