package com.yihu.wlyy.service.common.advert;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.yihu.wlyy.entity.advert.Advert;
import com.yihu.wlyy.repository.advert.AdvertDao;
import com.yihu.wlyy.service.BaseService;

@Component
@Transactional(rollbackFor = Exception.class)
public class AdvertService extends BaseService {

	@Autowired
	private AdvertDao advertDao;

	/**
	 * 根据类型查询广告列表
	 * @param type
	 * @return
	 */
	public Page<Advert> findByType(int type) {
		// 排序
		Sort sort = new Sort(Direction.ASC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, 100, sort);
		return advertDao.findByType(type, pageRequest);
	}

}
