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.enumModel.ePassType;
import com.template.model.pojo.ActivityImage;
import com.template.mapper.ActivityImageMapper;
import com.template.model.pojo.ActivityImage;
import com.template.model.pojo.AlumniClub;
import com.template.model.result.PageUtils;
import com.template.model.vo.ActivityImageApplyVo;
import com.template.model.vo.ActivityMyImageApplyVo;
import com.template.model.vo.AlumniMyJoinActivityPageVo;
import com.template.model.vo.ImageMyPageVo;
import com.template.services.ActivityImageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2024-11-27
 */
@Service
public class ActivityImageServiceImpl extends ServiceImpl<ActivityImageMapper, ActivityImage> implements ActivityImageService {
    @Autowired
    private ActivityImageMapper activityImageMapper;

    @Override
    public int insertActivityImage(ActivityImage au) {
        int result = activityImageMapper.insert(au);
        return result;
    }

    @Override
    public int updateActivityImage(ActivityImage au) {
        int result = activityImageMapper.updateById(au);
        return result;
    }

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

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

    @Override
    public PageUtils<ActivityImage> queryActivityImagePages(int currentPage, int pageCount, Integer userId,int isPass) {
        Page<ActivityImage> page = new Page<>(currentPage, pageCount);
        QueryWrapper<ActivityImage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("create_user", userId);
        if(isPass > 0){
            queryWrapper.eq("is_pass", isPass);
        }
        queryWrapper.orderByDesc("create_time");
        IPage<ActivityImage> result = activityImageMapper.selectPage(page, queryWrapper);
        return new PageUtils(result);
    }

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

    @Override
    public PageUtils<ActivityMyImageApplyVo> activityMyImagePageDatas(int currentPage, int pageCount, Integer userId, String name) {
        Page<ActivityMyImageApplyVo> page = new Page<>(currentPage, pageCount);
        IPage<ActivityMyImageApplyVo> result = activityImageMapper.activityMyImagePageDatas(page, userId, name);
        return new PageUtils(result);
    }

    @Override
    public List<ActivityImage> queryActivityImages(Integer activityId) {
        QueryWrapper<ActivityImage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("activity_id", activityId);
        queryWrapper.eq("is_pass", ePassType.Passed.getValue());
        List<ActivityImage> result = activityImageMapper.selectList(queryWrapper);
        return result;
    }

    @Override
    public PageUtils<ActivityMyImageApplyVo> activityApproveImagePageDatas(int currentPage, int pageCount, Integer userId, String name) {
        Page<ActivityMyImageApplyVo> page = new Page<>(currentPage, pageCount);
        IPage<ActivityMyImageApplyVo> result = activityImageMapper.activityApproveImagePageDatas(page, userId, name);
        return new PageUtils(result);
    }

}
