package com.slodon.b2b2c.model.member.advich;

import com.slodon.b2b2c.core.response.PagerInfo;
import com.slodon.b2b2c.dao.read.system.CountryReadMapper;
import com.slodon.b2b2c.system.example.CountryExample;
import com.slodon.b2b2c.system.pojo.Country;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author cyan
 */
@Component
@Slf4j
public class CountryModel {

    @Resource
    private CountryReadMapper countryReadMapper;

    /**
     * @param example 查询条件信息
     * @param pager   分页信息
     */
    public List<Country> getPhoneCodeList(CountryExample example, PagerInfo pager) {
        List<Country> enquiryList;
        if (pager != null) {
            pager.setRowsCount(countryReadMapper.countByExample(example));
            enquiryList = countryReadMapper.listPageByExample(example, pager.getStart(), pager.getPageSize());
        } else {
            enquiryList = countryReadMapper.listByExample(example);
        }
        return enquiryList;
    }
}
