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.bean.sys.fx.domain.MaterielOffDetail;
import com.ssj.dao.sys.fx.dao.FxQueryDao;
import com.ssj.dao.sys.fx.dao.MaterielOffDetailDao;
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.MaterielOffDetailService;
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.List;
import java.util.Map;

@Service(version="1.0")
public class MaterielOffDetailServiceImpl extends BaseServiceImpl<MaterielOffDetail, String> implements MaterielOffDetailService {

    @Autowired
    private MaterielOffDetailDao dao;

    @Autowired
    private FxQueryDao queryDao;

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

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

    @Override
    public List<Map<String, Object>> findMapList(Map<String, Object> params) {
        return queryDao.findMapList(params);
    }
}
