package cn.com.countrygarden.bi.main.service.resident.impl;

import cn.com.countrygarden.bi.main.dao.resident.PaymentMethodMapper;
import cn.com.countrygarden.bi.main.model.resident.ContractConstant;
import cn.com.countrygarden.bi.main.model.resident.PaymentMethod;
import cn.com.countrygarden.bi.main.service.resident.PaymentMethodService;
import cn.com.countrygarden.bi.main.util.RedisCacheUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * Created by chenweijiang on 2017/11/13.
 */
@Service
@Transactional
public class PaymentMethodServiceImpl implements PaymentMethodService{

    @Autowired
    private PaymentMethodMapper mapper;

    @Override
    public List<PaymentMethod> listAll() {
        List<PaymentMethod> resultList = RedisCacheUtils.remeberList(ContractConstant.PaymentMethod.CACHE_KEY,ContractConstant.PaymentMethod.EXPIRED_TIME,new HashMap<String,String>(),PaymentMethod.class,
                p->{
                    PaymentMethod query = new PaymentMethod();
                    query.setIsDelete(false);
                    return mapper.select(query);
                }
        );

        return resultList;
    }
}
