<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.opengauss.admin.system.mapper.ops.OpsHostMapper">
<select id="pageHost" resultType="org.opengauss.admin.common.core.domain.model.ops.host.OpsHostVO">
SELECT DISTINCT h.host_id,h.hostname,h.private_ip,h.public_ip,h.port,h.az_id, h.remark,h.create_by,
h.create_time,h.update_by,h.update_time,h.os,h.os_version osVersion, h.cpu_arch,h.name,a.name azName
FROM ops_host h
LEFT JOIN ops_az a ON h.az_id = a.az_id
LEFT JOIN ops_host_tag_rel tr ON h.host_id = tr.host_id
WHERE 1=1
<if test="name!=null and name!=''">
AND (h.public_ip like #{name} OR h.private_ip like #{name})
</if>
<if test="os!=null and os!=''">
AND h.os like #{os}
</if>
<if test="tagIds!=null and tagIds.size()>0">
AND h.host_id IN
(SELECT host_id FROM (SELECT DISTINCT tr.host_id , tr.tag_id FROM ops_host_tag_rel tr WHERE tag_id IN
<foreach
collection="tagIds" item="tagId" open="(" close=")" separator=",">
#{tagId}
</foreach>
) GROUP BY host_id HAVING COUNT(*)>= #{size} )
</if>
ORDER BY h.update_time DESC
</select>
</mapper>