package com.pdaaphm.biz.service.impl;

import java.util.List;

import com.pdaaphm.biz.mapper.AlgorithmIoFieldMapper;
import com.pdaaphm.biz.mapper.AlgorithmMapper;
import com.pdaaphm.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pdaaphm.biz.mapper.AlgorithmSubTypeMapper;
import com.pdaaphm.biz.domain.AlgorithmSubType;
import com.pdaaphm.biz.service.IAlgorithmSubTypeService;

/**
 * 算法子类型Service业务层处理
 *
 * @author allen
 * @date 2023-07-26
 */
@Service
public class AlgorithmSubTypeServiceImpl implements IAlgorithmSubTypeService {
    @Autowired
    private AlgorithmSubTypeMapper algorithmSubTypeMapper;

    @Autowired
    private AlgorithmIoFieldMapper algorithmIoFieldMapper;

    @Autowired
    private AlgorithmMapper algorithmMapper;

    /**
     * 查询算法子类型
     *
     * @param id 算法子类型主键
     * @return 算法子类型
     */
    @Override
    public AlgorithmSubType selectAlgorithmSubTypeById(Long id) {
        return algorithmSubTypeMapper.selectAlgorithmSubTypeById(id);
    }

    /**
     * 查询算法子类型列表
     *
     * @param algorithmSubType 算法子类型
     * @return 算法子类型
     */
    @Override
    public List<AlgorithmSubType> selectAlgorithmSubTypeList(AlgorithmSubType algorithmSubType) {
        return algorithmSubTypeMapper.selectAlgorithmSubTypeList(algorithmSubType);
    }

    /**
     * 新增算法子类型
     *
     * @param algorithmSubType 算法子类型
     * @return 结果
     */
    @Override
    public int insertAlgorithmSubType(AlgorithmSubType algorithmSubType) {
        algorithmSubType.setCreateTime(DateUtils.getNowDate());
        return algorithmSubTypeMapper.insertAlgorithmSubType(algorithmSubType);
    }

    /**
     * 修改算法子类型
     *
     * @param algorithmSubType 算法子类型
     * @return 结果
     */
    @Override
    public int updateAlgorithmSubType(AlgorithmSubType algorithmSubType) {
        algorithmSubType.setUpdateTime(DateUtils.getNowDate());
        return algorithmSubTypeMapper.updateAlgorithmSubType(algorithmSubType);
    }

    /**
     * 批量删除算法子类型
     *
     * @param ids 需要删除的算法子类型主键
     * @return 结果
     */
    @Override
    public int deleteAlgorithmSubTypeByIds(Long[] ids) {
        for (Long id : ids) {
            algorithmIoFieldMapper.deleteAlgorithmIoFieldBySubTypeId(id);
            algorithmMapper.deleteAlgorithmBySubTypeId(id);
        }
        return algorithmSubTypeMapper.deleteAlgorithmSubTypeByIds(ids);
    }

    /**
     * 删除算法子类型信息
     *
     * @param id 算法子类型主键
     * @return 结果
     */
    @Override
    public int deleteAlgorithmSubTypeById(Long id) {
        algorithmIoFieldMapper.deleteAlgorithmIoFieldBySubTypeId(id);
        algorithmMapper.deleteAlgorithmBySubTypeId(id);
        return algorithmSubTypeMapper.deleteAlgorithmSubTypeById(id);
    }
}
