package com.ssj.service.sys.wallet.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.sys.wallet.domain.WalletBankcard;
import com.ssj.dao.sys.wallet.dao.WalletBankcardDao;
import com.ssj.dao.sys.wallet.dao.WalletQueryDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.framework.core.persistence.DynamicSpecifications;
import com.ssj.framework.core.persistence.SearchFilter;
import com.ssj.service.sys.wallet.service.WalletBankcardService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author Mount Liu
 * @date 2018/11/19
 */
@Service(version ="1.0")
@Transactional
public class WalletBankcardServiceImpl extends BaseServiceImpl<WalletBankcard, String> implements WalletBankcardService {

    private   Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WalletBankcardDao dao;

    @Autowired
    private WalletQueryDao walletQueryDao;

    @Override
    public PagingAndSortingRepository<WalletBankcard, String> getDao() {
        return dao;
    }

    @Override
    public Page<WalletBankcard> findByPage(Map<String, Object> params, Pageable sp) {
        Map<String, SearchFilter> filters = SearchFilter.parse(params);
        Specification<WalletBankcard> specification = DynamicSpecifications.bySearchFilter(filters.values(), WalletBankcard.class);
        return dao.findAll(specification, sp);
    }

    @Override
    public Page<Map<String, Object>> findWalletBankcardByPage(Map<String, Object> searchParams, Pageable pageable) {
        return walletQueryDao.findWalletBankcardByPage(searchParams, pageable);
    }
}
