package com.huimv.beeboxs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huimv.beeboxs.common.utils.Result;
import com.huimv.beeboxs.common.utils.ResultCode;
import com.huimv.beeboxs.entity.HiveBeehiveOut;
import com.huimv.beeboxs.mapper.HiveBeehiveOutMapper;
import com.huimv.beeboxs.service.IHiveBeehiveOutService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2022-04-22
 */
@Service
public class HiveBeehiveOutServiceImpl extends ServiceImpl<HiveBeehiveOutMapper, HiveBeehiveOut> implements IHiveBeehiveOutService {
    @Override
    public Result searchList(Map map) {
        String startDate = (String)map.get("startDate");
        String endDate = (String)map.get("endDate");
        String hiveId = (String)map.get("hiveId");

        QueryWrapper<HiveBeehiveOut> wrapper = new QueryWrapper<>();
        if (StringUtils.isBlank(hiveId)){
            return new Result(10001,"请选择基站箱",false);
        }
        wrapper.eq("station_id",hiveId);
//        wrapper.orderByDesc("create_date");

        wrapper.ge(StringUtils.isNotBlank(startDate),"create_date",startDate);
        wrapper.le(StringUtils.isNotBlank(endDate),"create_date",endDate);

        return new Result(ResultCode.SUCCESS,this.list(wrapper));
    }
}
