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

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.sys.fx.domain.MaterielOff;
import com.ssj.dao.sys.fx.dao.MaterielOffDao;
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.fx.service.MaterielOffService;
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 java.util.Map;

@Service(version="1.0")
public class MaterielOffServiceImpl extends BaseServiceImpl<MaterielOff, String> implements MaterielOffService {

    @Autowired
    private MaterielOffDao dao;

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

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