package com.huimv.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huimv.admin.common.utils.Result;
import com.huimv.admin.common.utils.ResultCode;
import com.huimv.admin.entity.ProdWarningInfo;
import com.huimv.admin.mapper.ProdWarningInfoMapper;
import com.huimv.admin.service.IProdWarningInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 生产管理预警 服务实现类
 * </p>
 *
 * @author newspaper
 * @since 2024-01-11
 */
@Service
public class ProdWarningInfoServiceImpl extends ServiceImpl<ProdWarningInfoMapper, ProdWarningInfo> implements IProdWarningInfoService {

    @Override
    public Result listWarning(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
        String pageNo = paramsMap.get("pageNum");
        String pageSize = paramsMap.get("pageSize");
        String  farmId =  paramsMap.get("farmId");
        Page<ProdWarningInfo> page = new Page<>(Integer.parseInt(pageNo),Integer.parseInt(pageSize));
        Page<ProdWarningInfo> prodWarningInfoPage = this.page(page, new QueryWrapper<ProdWarningInfo>().lambda().eq(ProdWarningInfo::getFarmId, farmId).orderByDesc(ProdWarningInfo::getDate));
        return new Result(ResultCode.SUCCESS,prodWarningInfoPage);
    }
}
