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

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 com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.sys.organization.domain.OrgTeacher;
import com.ssj.dao.sys.organization.dao.OrgTeacherDao;
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.organization.service.OrgTeacherService;

import java.util.Map;

/**
 * @author Mount Liu
 * @date 2019/2/27
 */
@Service(version ="1.0")
@Transactional
public class OrgTeacherServiceImpl extends BaseServiceImpl<OrgTeacher, String> implements OrgTeacherService {

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

    @Autowired
    private OrgTeacherDao dao;

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

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