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

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.sys.fx.domain.MaterielTemplate;
import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
import com.ssj.dao.sys.fx.dao.FxQueryDao;
import com.ssj.dao.sys.fx.dao.MaterielTemplateDao;
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.MaterielTemplateService;
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 MaterielTemplateServiceImpl extends BaseServiceImpl<MaterielTemplate,String> implements MaterielTemplateService {
    @Autowired
    private MaterielTemplateDao dao;
    @Autowired
    private FxQueryDao queryDao;

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

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