package com.template.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.template.model.pojo.ActivityReport;
import com.template.mapper.ActivityReportMapper;
import com.template.model.result.PageUtils;
import com.template.model.vo.ActivityDetailExcelVo;
import com.template.model.vo.AlumniActivityApplyPageVo;
import com.template.model.vo.AlumniMyJoinActivityPageVo;
import com.template.model.vo.UserVo;
import com.template.services.ActivityReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2024-11-27
 */
@Service
public class ActivityReportServiceImpl extends ServiceImpl<ActivityReportMapper, ActivityReport> implements ActivityReportService {

    @Autowired
    private ActivityReportMapper activityReportMapper;

    @Override
    public int insertActivityReport(ActivityReport au) {
        int result = activityReportMapper.insert(au);
        return result;
    }

    @Override
    public int updateActivityReport(ActivityReport au) {
        int result = activityReportMapper.updateById(au);
        return result;
    }

    @Override
    public ActivityReport queryDataById(Integer id) {
        ActivityReport result = activityReportMapper.selectById(id);
        return result;
    }

    @Override
    public int deleteDataById(Integer id) {
        int result = activityReportMapper.deleteById(id);
        return result;
    }

    @Override
    public List<UserVo> queryReportDatasByActivityId(Integer activityId) {
        List<UserVo> result = activityReportMapper.queryReportDatasByActivityId(activityId);
        return result;
    }

    @Override
    public int queryActivityReportNumber(Integer activityId) {
        QueryWrapper<ActivityReport> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("activity_id",activityId);
        int count = activityReportMapper.selectCount(queryWrapper);
        return count;
    }

    @Override
    public List<ActivityDetailExcelVo> activityDetailByActivityIds(List<Integer> activityIds) {
        List<ActivityDetailExcelVo> result = activityReportMapper.activityDetailByActivityIds(activityIds);
        return result;
    }

    @Override
    public PageUtils<AlumniMyJoinActivityPageVo> queryMyJoinActivityPages(int currentPage, int pageCount, Integer userId) {
        Page<AlumniMyJoinActivityPageVo> page = new Page<>(currentPage, pageCount);
        IPage<AlumniMyJoinActivityPageVo> result = activityReportMapper.queryMyJoinActivityPages(page, userId);
        return new PageUtils(result);
    }
}
