<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.tsy.data.idsse.dsds.mapper.dict.DictDataMapper">
 
  <!-- 分页查询 -->
  <select id="dataWithPage" resultType="map">
	select * from dict_data where 1=1  	
	<if test="query != null and query != ''">
      and (data_name like concat('%',#{query},'%')  or data_remark like concat('%',#{query},'%') or data_alias like concat('%',#{query},'%')) 
    </if>
    <if test="order != null and order != ''">
		ORDER BY ${order} 
	</if>
	<if test="type != null and (type == 'DESC')">
	 	DESC
	</if>
  </select>
  <select id="searchWithPage" resultType="map">
	select v.tsy_id id,v.data_name name,v.data_alias value from dict_data v
	<!-- 如果有平台类型，需要去查找有平台类型的航次 -->
	<if test="param.voyage_name != null and param.voyage_name != ''">
		,(select distinct data_id from sample_dataset where voyage_name=#{param.voyage_name}) p0		
	</if>	
	<if test="param.platform_type != null and param.platform_type != ''">
		,(select distinct data_id from sample_dataset where platform_type=#{param.platform_type}) p1		
	</if>	
	<if test="param.platform_name != null and param.platform_name != ''">
		,(select distinct data_id from sample_dataset where platform_name=#{param.platform_name}) p2		
	</if>
	<if test="param.equipment_type != null and param.equipment_type != ''">
		,(select distinct data_id from sample_dataset where equipment_type=#{param.equipment_type}) p3		
	</if>
	<if test="param.data_type != null and param.data_type != ''">
		,(select distinct data_id from sample_dataset where data_type=#{param.data_type}) p4		
	</if>
	where 1=1 
	<if test="param.voyage_name != null and param.voyage_name != ''">
		and p0.data_id = v.tsy_id		 	
	</if>
	<if test="param.platform_type != null and param.platform_type != ''">
		and p1.data_id = v.tsy_id		 
	</if>	
	<if test="param.platform_name != null and param.platform_name != ''">
		and p2.data_id = v.tsy_id		 	
	</if>
	<if test="param.equipment_type != null and param.equipment_type != ''">
		and p3.data_id = v.tsy_id			
	</if>
	<if test="param.data_type != null and param.data_type != ''">
		and p4.data_id = v.tsy_id			
	</if>
	order by v.data_name
  </select>
  
  
</mapper>