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

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.common.utils.MenuStatusEnum;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.workprojectdeposit.dao.WorkProjectDepositDao;
import com.jeeplus.modules.workprojectdeposit.entity.WorkProjectDeposit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * 保证金模块Service
 * @author 杨帆
 * @version 2017-12-26
 */
@Service
@Transactional(readOnly = true)
public class WorkProjectDepositService extends CrudService<WorkProjectDepositDao, WorkProjectDeposit> {
	@Autowired
	private WorkProjectDepositDao workProjectDepositDao;
	public WorkProjectDeposit getById(String id){return workProjectDepositDao.getById(id);};
	public WorkProjectDeposit get(String id) {
		return super.get(id);
	}
	
	public List<WorkProjectDeposit> findList(WorkProjectDeposit workProjectDeposit) {
		workProjectDeposit.getSqlMap().put("dsf", dataScopeFilter(workProjectDeposit.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_PROJECTDEPOSIT.getValue()));
		return super.findList(workProjectDeposit);
	}
	
	public Page<WorkProjectDeposit> findPage(Page<WorkProjectDeposit> page, WorkProjectDeposit workProjectDeposit) {
		workProjectDeposit.getSqlMap().put("dsf", dataScopeFilter(workProjectDeposit.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_PROJECTDEPOSIT.getValue()));
		return super.findPage(page, workProjectDeposit);
	}
	
	@Transactional(readOnly = false)
	public void save(WorkProjectDeposit workProjectDeposit) {
		super.save(workProjectDeposit);
	}

	@Transactional(readOnly = false)
	public void delete(WorkProjectDeposit workProjectDeposit) {
		super.delete(workProjectDeposit);
	}

	public List<WorkProjectDeposit> findByPid(String bidingProject) {
		return workProjectDepositDao.getByPid(bidingProject);
	}


    public List<WorkProjectDeposit> getByBidingProjectId(String workBidingProjectId) {
		List<WorkProjectDeposit> list = new ArrayList<>();
		if(StringUtils.isNotBlank(workBidingProjectId)){
			list = workProjectDepositDao.getByBidingProjectId(workBidingProjectId);
		}

		return list;
    }
}