package cn.com.countrygarden.bi.main.service.project.impl;

import java.util.Date;
import java.util.List;

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

import com.github.pagehelper.PageRowBounds;

import cn.com.countrygarden.bi.main.dao.project.ProjectJointPlanMapper;
import cn.com.countrygarden.bi.main.dao.resident.PaymentMethodMapper;
import cn.com.countrygarden.bi.main.model.PageData;
import cn.com.countrygarden.bi.main.model.project.ProjectJointPlan;
import cn.com.countrygarden.bi.main.service.project.ProjectJointPlanService;

@Service
@Transactional
public class ProjectJointPlanServiceImpl implements ProjectJointPlanService{
	  @Autowired
	  private ProjectJointPlanMapper mapper;

	@Override
	public PageData search(Integer menuId,Integer page,Integer size) {
		 PageRowBounds pageRowBounds = new PageRowBounds(page,size);
		List<ProjectJointPlan> pList = mapper.search(menuId, pageRowBounds);
		return new PageData( pList,pageRowBounds);
	}

	@Override
	public Integer save(ProjectJointPlan p,String userCode) {
		if(null == p.getId()) {
			p.setCreatedDate(new Date());
			p.setCreatedBy(userCode);
			return mapper.insert(p);
		}else {
			p.setUpdatedDate(new Date());
			p.setUpdatedBy(userCode);
			return mapper.update(p);
		}
	
	}
	@Override
	public Integer delete(Integer id) {
		return mapper.deletePlan(id);
	}
	@Override
	public ProjectJointPlan findOne(Integer id) {
		ProjectJointPlan p = new ProjectJointPlan();
		p.setId(id);
		return mapper.selectOne(p);
	}
}
