package com.jxy.marketall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxy.common.core.utils.StringUtils;
import com.jxy.common.core.web.Result.AjaxResult;
import com.jxy.marketall.entity.Arh99;
import com.jxy.marketall.mapper.Arh99Mapper;
import com.jxy.marketall.service.Arh99Service;
import com.jxy.marketall.vo.QueryVo;
import org.springframework.stereotype.Service;

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


/**
 * @Description Arh99查询业务处理
 * @Date 2022/6/2017:51
 * @Author 杜懿
 */
@Service
public class Arh99ServiceImpl extends ServiceImpl<Arh99Mapper, Arh99> implements Arh99Service {

    @Override
    public AjaxResult findArh99ByTime(QueryVo queryVo) {

        LambdaQueryWrapper<Arh99> arh99LambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(queryVo.getSma() < 1){
            arh99LambdaQueryWrapper.ge(!StringUtils.isEmpty(queryVo.getStart()),Arh99::getDate,queryVo.getStart())
                    .le(!StringUtils.isEmpty(queryVo.getEnd()),Arh99::getDate,queryVo.getEnd()).orderByAsc(Arh99::getDate);
            List<Arh99> list = baseMapper.selectList(arh99LambdaQueryWrapper);
            return AjaxResult.success(list);
        }else {
            //传入sma 代表是请求均值
            arh99LambdaQueryWrapper.orderByAsc(Arh99::getDate);
            List<Arh99> list = baseMapper.selectList(arh99LambdaQueryWrapper);


            return AjaxResult.success(list);
        }
    }
}
