package com.nantian.cloud.jljc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nantian.cloud.jljc.dto.TTrainingDto;
import com.nantian.cloud.jljc.entity.TTraining;
import com.nantian.cloud.jljc.mapper.GetTrainingOutMapper;
import com.nantian.cloud.jljc.mapper.TTrainingMapper;
import com.nantian.cloud.jljc.mapper.TTrainingPersonMapper;
import com.nantian.cloud.jljc.service.GetTrainingOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("getTrainingOutService")
public class GetTrainingOutServiceImpl extends ServiceImpl<TTrainingMapper, TTraining> implements GetTrainingOutService {
    @Autowired
    private GetTrainingOutMapper getTrainingOutMapper;
    @Autowired
    private TTrainingPersonMapper tTrainingPersonMapper;
    @Override
    public List<TTrainingDto> pageInfo() {

        //查询出培训信息
        List<TTrainingDto> tTrainingDtoList = getTrainingOutMapper.getPage();
        for (TTrainingDto trainingDto : tTrainingDtoList) {
            Integer id=trainingDto.getId();
            //根据ID去获取培训内容下的培训人数
            Integer count =  tTrainingPersonMapper.getCountById(id);
            trainingDto.setCount(count);
        }

        return tTrainingDtoList;
    }
}
