package vip.xiaonuo.quality.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import vip.xiaonuo.quality.entity.QualityEffectice;
import vip.xiaonuo.quality.entity.QualityWarning;
import vip.xiaonuo.quality.mapper.QualityWarningMapper;
import vip.xiaonuo.quality.param.QualityWarningParam;
import vip.xiaonuo.quality.service.IQualityWarningService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 质量管控生产预警 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-11
 */
@Service
public class QualityWarningServiceImpl extends ServiceImpl<QualityWarningMapper, QualityWarning> implements IQualityWarningService {

    @Autowired
    private QualityWarningMapper warningMapper;

    @Override
    public Page<QualityWarning> listPage(QualityWarningParam warningParam) {
        String orgId = warningParam.getOrgId();
        Page<QualityWarning> page = new Page<>(warningParam.getPageNum(), warningParam.getPageSize());
        QueryWrapper<QualityWarning> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
        queryWrapper.orderByDesc("create_time");
        return warningMapper.selectPage(page, queryWrapper);
    }
}
