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

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

import com.jeeplus.common.utils.MenuStatusEnum;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.modules.workperson.entity.WorkPerson;
import com.jeeplus.modules.workperson.dao.WorkPersonDao;

/**
 * 人员信息Service
 * @author ssrh
 * @version 2018-08-21
 */
@Service
@Transactional(readOnly = true)
public class WorkPersonService extends CrudService<WorkPersonDao, WorkPerson> {

	public WorkPerson get(String id) {
		return super.get(id);
	}
	
	public List<WorkPerson> findList(WorkPerson workPerson) {
		return super.findList(workPerson);
	}
	
	public Page<WorkPerson> findPage(Page<WorkPerson> page, WorkPerson workPerson) {
		if(!UserUtils.getUser().isAdmin()) {
			String dataScopeSql = dataScopeFilterOR(workPerson.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_PERSON.getValue());
			workPerson.getSqlMap().put("dsf", dataScopeSql);
			if(workPerson.getCurrentUser().getBranchOffice()==null){
				workPerson.getCurrentUser().setBranchOffice(workPerson.getCurrentUser().getCompany());
			}
			workPerson.setPage(page);
			page.setList(this.findList(workPerson));
			return page;
		}else {
			return super.findPage(page, workPerson);		}
	}
	
	@Transactional(readOnly = false)
	public void save(WorkPerson workPerson) {
		super.save(workPerson);
	}
	
	@Transactional(readOnly = false)
	public void delete(WorkPerson workPerson) {
		super.delete(workPerson);
	}
	
	
	
	
}