package com.ruoyi.web.controller.chenyanlogin.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.controller.chenyanlogin.entity.QiXiang;
import com.ruoyi.web.controller.chenyanlogin.mapper.QiXiangMapper;
import com.ruoyi.web.controller.chenyanlogin.service.IQiXiangService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.web.controller.chenyanlogin.vo.QiXiangVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-09-29
 */
@Service
public class QiXiangServiceImpl extends ServiceImpl<QiXiangMapper, QiXiang> implements IQiXiangService {

    @Autowired
    private QiXiangMapper qiXiangMapper;

    @Override
    public List<QiXiangVo> getListQiXiang(Map<String,String> map) {
        String startDate = map.get("startDate");
        String endDate = map.get("endDate");
        String type = map.get("type");

        QueryWrapper<QiXiang> qiXiangQueryWrapper = new QueryWrapper<>();
        qiXiangQueryWrapper.ge(StringUtils.isNotEmpty(startDate),"time",startDate);
        qiXiangQueryWrapper.le(StringUtils.isNotEmpty(endDate),"time",endDate);
        List<QiXiangVo> list  = new ArrayList<>();
        if ("1".equals(type)){
            list =   qiXiangMapper.getListQiXiangDay(qiXiangQueryWrapper);
        }else if ("2".equals(type)){
            list =   qiXiangMapper.getListQiXiangWeek(qiXiangQueryWrapper);
        }else {
            list =   qiXiangMapper.getListQiXiangMonth(qiXiangQueryWrapper);
        }
        return list;
    }
}
