package com.zhiwei.manage.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiwei.manage.bean.FieldBean;
import com.zhiwei.manage.bean.PageEty;
import com.zhiwei.manage.dao.FieldBeanDao;
@Service
public class FieldBeanServiceImpl implements FieldBeanService {

	@Autowired
	private FieldBeanDao fd;
	
	@Override
	public FieldBean getFieldsByPt(String pt) {
		return fd.getFieldsByPt(pt);
	}

	@Override
	public void insert(FieldBean fieldBean) {
		fd.insert(fieldBean);
	}

	@Override
	public boolean update(FieldBean fieldBean) {
		return fd.update(fieldBean);
	}

	@Override
	public boolean delete(List<String> id) {
		return fd.delete(id);
	}

	@Override
	public PageEty findAllFields(int pageNo,int pageSize,String pt) {
		PageEty page=new PageEty();
		List<FieldBean> list=fd.findAllFields(pageNo,pageSize,pt);
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		int count=fd.findFieldCount(pt);
		page.setDataCount(count);
		if(count%pageSize==0){
			page.setPageCount(count/pageSize);
		}else{
			page.setPageCount(count/pageSize+1);
		}
		page.setData(list);
		return page;
	}

}
