/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.lightinit.hsdatagateway.modules.gateway.service;

import java.util.ArrayList;
import java.util.List;

import com.lightinit.hsdatagateway.common.persistence.Page;
import com.lightinit.hsdatagateway.common.service.CrudService;
import com.lightinit.hsdatagateway.modules.gateway.entity.BlackWhiteList;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lightinit.hsdatagateway.common.persistence.Page;
import com.lightinit.hsdatagateway.common.service.CrudService;
import com.lightinit.hsdatagateway.modules.gateway.entity.BlackWhiteList;
import com.lightinit.hsdatagateway.modules.gateway.dao.BlackWhiteListDao;

/**
 * 黑白名单
 * @Author: yangrui
 * @version 2019-03-05
 */
@Service
@Transactional(readOnly = true)
public class BlackWhiteListService extends CrudService<BlackWhiteListDao, BlackWhiteList> {

	public BlackWhiteList get(Long id) {
		return super.get(id);
	}
	
	public List<BlackWhiteList> findList(BlackWhiteList blackWhiteList) {
		return super.findList(blackWhiteList);
	}
	
	public Page<BlackWhiteList> findPage(Page<BlackWhiteList> page, BlackWhiteList blackWhiteList) {
		page.setOrderBy("created_at desc");
		return super.findPage(page, blackWhiteList);
	}
	
	@Transactional(readOnly = false)
	public void save(BlackWhiteList blackWhiteList) {
		super.save(blackWhiteList);
	}
	
	@Transactional(readOnly = false)
	public void delete(BlackWhiteList blackWhiteList) {
		super.delete(blackWhiteList);
	}

    public List<BlackWhiteList> findListByType(String type) {
		return dao.findList(new BlackWhiteList(type));
    }

	/**
	 * 根据type获取ip
	 * @param type
	 * @return
	 */
	public List<String> findIpByType(String type) {
		return dao.findIpByType(type);
	}
}