package cn.com.countrygarden.bi.main.dao.mediaResource;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import cn.com.countrygarden.bi.main.core.Mapper;
import cn.com.countrygarden.bi.main.dto.AdvertisingResourcesDto;
import cn.com.countrygarden.bi.main.dto.BasicInfoDto;
import cn.com.countrygarden.bi.main.dto.mediaResource.AreaDto;
import cn.com.countrygarden.bi.main.model.mediaResource.AdvertisingResources;
import cn.com.countrygarden.bi.main.model.mediaResource.BasicInfo;

public interface ScheduleBasicInfoMapper extends Mapper<BasicInfo>{

	@Select("select basics_id from t_media_comm_info")
	List<String> findBasicId();

	List<Map<String,Object>>  selectBasicInfo(BasicInfoDto dto);

	long selectBasicInfoCount(BasicInfoDto dto);
	
	List<String> selectPropertyAreaData(BasicInfoDto dto);
	
	@Select("select concat(comm_name,'-',comm_id) as commName from t_media_comm_info where is_delete = 0 and organ_name = #{organName} order by comm_name")
	List<String> propertyProjectData(BasicInfoDto dto);

	@Select("select comm_name from t_media_comm_info group by comm_name")	
	List<String> selectPropertyProjectData();

	Map<String,String> findOne(BasicInfo po);

	List<Map<String,Object>> findBasic(BasicInfoDto dto);

	@Select("select comm_id as commId,organ_code as organCode from t_media_comm_info where organ_name = #{organName} and comm_name = #{commName} limit 1 ")
	BasicInfo findCommIdAndOrganCode(AdvertisingResources po);

	String verify(@Param("organCode")String organCode,@Param("organName")String organName,@Param("commId")String commId,@Param("commName")String commName);

	@Select("select comm_address as commAddress from t_media_comm_info where organ_code = #{organCode} and comm_id = #{commId} ")
	String findCommAddress(@Param("organCode")String organCode,@Param("commId")String commId);

	@Select("select IFNULL(organ_code,'') from t_media_comm_info group by organ_code")
	List<String> findAllOrganCode();

	@Select("select IFNULL(comm_id,'') as commId,comm_name as commName,organ_name as organName,organ_code as organCode from t_media_comm_info where is_delete = 0 ")
	List<BasicInfoDto> findAllCommId();

	@Select("select comm_address from t_media_comm_info where organ_name = #{organName} and comm_name = #{commName} limit 1")
	String getCommAddress(AdvertisingResourcesDto dto);

	List<BasicInfo> finddbBasicInfo();

	int updateMatchingBasic(BasicInfo basicInfo);

	@Select("select id as value,area_name as text from t_media_area where area_parent_id = #{areaParentId} ")
	List<Map<String, Object>> provinces(AreaDto dto);

	String verify2(@Param("organName")String organName,@Param("commId")String commId,@Param("commName")String commName);

	int updateOne(BasicInfo po);


	@Select("select count(id) from user_roles where user_code = #{userCode} and role_code = #{roleCode}")
	int findUserRole(@Param("userCode")String userCode,@Param("roleCode")String code);

	int saveOne(BasicInfoDto dto);

	List<String> selectPropertyData(BasicInfoDto dto);


}
