/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.work.service.review;

import java.util.List;

import com.jeeplus.modules.sys.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.TreeService;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.work.entity.report.WorkReport;
import com.jeeplus.modules.work.entity.review.WorkReportReview;
import com.jeeplus.modules.work.dao.report.WorkReportRecordDao;
import com.jeeplus.modules.work.dao.review.WorkReportReviewDao;

/**
 * 工作报告的评论与回复Service
 * @author 许凯
 * @version 2017-04-28
 */
@Service
@Transactional(readOnly = true)
public class WorkReportReviewService extends TreeService<WorkReportReviewDao, WorkReportReview> {
	
	@Autowired
	private WorkReportReviewDao workReportReviewDao;

	public WorkReportReview get(String id) {
		return super.get(id);
	}
	
	public List<WorkReportReview> findList(WorkReportReview workReportReview) {
		if (StringUtils.isNotBlank(workReportReview.getParentIds())){
			workReportReview.setParentIds(","+workReportReview.getParentIds()+",");
		}
		return super.findList(workReportReview);
	}
	
	public Page<WorkReportReview> findPage(Page<WorkReportReview> page, WorkReportReview workReportReview) {
		workReportReview.setPage(page);
		page.setList(workReportReviewDao.findList(workReportReview));
		return page;
	}

	public Page<WorkReportReview> findPageByCompany(Page<WorkReportReview>page,WorkReportReview workReportReview,String companyId){
		workReportReview.setPage(page);
		page.setList(workReportReviewDao.findListByCompany(workReportReview,companyId));
		return page;
	}
	
	@Transactional(readOnly = false)
	public void save(WorkReportReview workReportReview) {
		super.save(workReportReview);
	}
	
	@Transactional(readOnly = false)
	public void delete(WorkReportReview workReportReview) {
		super.delete(workReportReview);
	}
	
	public Page<WorkReportReview> findListByReportId(Page<WorkReportReview> page, WorkReportReview workReportReview) {
		workReportReview.setPage(page);
		page.setList(workReportReviewDao.findListByReportId(workReportReview));
		return page;
	}
	public List<WorkReportReview> findReviewListByReportId(String workReportId){
		return workReportReviewDao.getReviewByReportId(workReportId);
	}
	
}