/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.organization;

import com.yihu.wlyy.entity.organization.HospitalMapping;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * 医院映射接口
 **/
public interface HospitalMappingDao extends PagingAndSortingRepository<HospitalMapping, Long>,JpaSpecificationExecutor<HospitalMapping>  {

	@Query(value="select a.photo from dm_hospital a,wlyy_hospital_mapping b where a.code = b.code and b.mapping_code = ?1 and b.type=?2",nativeQuery = true)
	String getPhotoByMappingCode(String mappingCode,String type);

	@Query("select a.mappingCode from HospitalMapping a where a.code=?1 and a.type=?2")
	String getMappingCode(String code,String type);

	@Query("select a.code from HospitalMapping a where a.mappingCode=?1 and a.type=?2")
	String getCodeByMapping(String mappingCode,String type);
}
