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

import com.ssj.bean.sys.wallet.domain.Bank;
import com.ssj.dao.sys.wallet.dao.BankDao;
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.BankService;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author Mount Liu
 * @date 2018/11/19
 */
@Service
@Transactional
public class BankServiceImpl extends BaseServiceImpl<Bank, String> implements BankService {

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

    @Autowired
    private BankDao dao;

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

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

}
