package vip.xiaonuo.risk.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.risk.entity.RiskContract;
import vip.xiaonuo.risk.entity.RiskContractWarning;
import vip.xiaonuo.risk.mapper.RiskContractWarningMapper;
import vip.xiaonuo.risk.param.RiskContractWarningParam;
import vip.xiaonuo.risk.service.IRiskContractWarningService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 风控管控合同逾期预警 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-11
 */
@Service
public class RiskContractWarningServiceImpl extends ServiceImpl<RiskContractWarningMapper, RiskContractWarning> implements IRiskContractWarningService {

    @Autowired
    private RiskContractWarningMapper warningMapper;

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

}
