HostInfoDao.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xunmei.deploy.dao.HostInfoDao">
  4. <select id="selectHostInfoPage" parameterType="com.xunmei.deploy.vo.HostInfoVo" resultType="com.xunmei.deploy.vo.HostInfoVo">
  5. SELECT * FROM
  6. (
  7. SELECT t.id,t.hostName,t.hostIp,t.hostMac,t.hostStatus,t.agentVersion,
  8. h.org_id AS hostOrg,h.org_name AS hostOrgName,h.coreTimeStamp,
  9. t.register_date as registerDateTime,t.encryption,
  10. z.zip_version as zipVersion,z.target_version as targetVersion,z.status as updateStatus,
  11. IF ((( SELECT COUNT(*) FROM deploy_app_run_info WHERE app_type != 'Tool' and host_id = t.id AND running = 0 ) &lt; 1), 1, 0) AS serverStatus
  12. FROM deploy_host_info t
  13. LEFT JOIN hv_host_org h ON t.id = h.register_code
  14. LEFT JOIN deploy_host_zip_info z on t.id = z.host_id
  15. <where>
  16. <if test="infoVo.zipVersion != '' and infoVo.zipVersion != null">
  17. z.zip_version = #{infoVo.zipVersion}
  18. </if>
  19. <if test="infoVo.updateStatus != null">
  20. and z.status = #{infoVo.updateStatus}
  21. </if>
  22. <if test="infoVo.targetVersion != '' and infoVo.targetVersion != null">
  23. and z.target_version = #{infoVo.targetVersion}
  24. </if>
  25. <if test="infoVo.hostIp != '' and infoVo.hostIp != null">
  26. and t.hostIp LIKE CONCAT('%', #{infoVo.hostIp}, '%' )
  27. </if>
  28. <!-- <if test="infoVo.mirrorVersion != '' and infoVo.mirrorVersion != null">
  29. and h.mirror_version LIKE CONCAT('%', #{infoVo.mirrorVersion}, '%' )
  30. </if>-->
  31. <if test="infoVo.hostOrg != '' and infoVo.hostOrg != null">
  32. and h.PATH LIKE CONCAT('%#', #{infoVo.hostOrg}, '#%' )
  33. </if>
  34. <if test="infoVo.hostName != '' and infoVo.hostName != null">
  35. and t.hostName LIKE CONCAT('%', #{infoVo.hostName}, '%' )
  36. </if>
  37. <if test="infoVo.hostStatus != null">
  38. and t.hostStatus = #{infoVo.hostStatus}
  39. </if>
  40. <if test="infoVo.agentVersion != '' and infoVo.agentVersion != null">
  41. and t.agentVersion = #{infoVo.agentVersion}
  42. </if>
  43. <if test="infoVo.orgName != '' and infoVo.orgName != null">
  44. and h.organize_name LIKE CONCAT('%', #{infoVo.orgName}, '%' )
  45. </if>
  46. <if test="infoVo.showNoOrgNameFlag != '' and infoVo.showNoOrgNameFlag != null">
  47. and h.organize_name is null
  48. </if>
  49. <if test="infoVo.encryption != null">
  50. and t.encryption = #{infoVo.encryption}
  51. </if>
  52. </where>
  53. ) h
  54. <where>
  55. <if test="infoVo.serverStatus != null">
  56. h.serverStatus = #{infoVo.serverStatus}
  57. </if>
  58. </where>
  59. order by h.serverStatus asc
  60. </select>
  61. <select id="getInfoById" resultType="com.xunmei.deploy.vo.HostInfoVo">
  62. SELECT
  63. t.id,
  64. t.hostName,
  65. t.hostIp,
  66. t.hostMac,
  67. t.hostStatus,
  68. t.agentVersion,
  69. h.org_id AS hostOrg,
  70. h.org_name AS hostOrgName,
  71. h.coreTimeStamp ,
  72. t.register_date as registerDateTime,
  73. z.zip_version as zipVersion,
  74. z.target_version as targetVersion,
  75. z.status as updateStatus,
  76. t.encryption,
  77. IF ((( SELECT COUNT(*) FROM deploy_app_run_info WHERE app_type != 'Tool' and host_id = t.id AND running = 0 ) &lt; 1), 1, 0) AS serverStatus
  78. FROM
  79. deploy_host_info t
  80. LEFT JOIN hv_host_org h ON t.id = h.register_code
  81. LEFT JOIN deploy_host_zip_info z on t.id = z.host_id
  82. where t.id = #{id}
  83. </select>
  84. <delete id="deleteAppInfo">
  85. delete from deploy_app_info where host_info_id = #{hostId};
  86. </delete>
  87. <delete id="deleteFrontTask">
  88. delete from deploy_front_task where host_id = #{hostId};
  89. </delete>
  90. <delete id="deleteHostZipInfo">
  91. delete from deploy_host_zip_info where host_id = #{hostId};
  92. </delete>
  93. <delete id="deleteUpgradeTask">
  94. delete from deploy_upgrade_task where host_id = #{hostId};
  95. </delete>
  96. <delete id="deleteUpgradeTaskHis">
  97. delete from deploy_upgrade_task_his where host_id = #{hostId};
  98. </delete>
  99. <delete id="deleteAppInfoExtend">
  100. delete from deploy_app_info_extend where host_info_id = #{hostId};
  101. </delete>
  102. <delete id="deleteAppRunInfo">
  103. delete from deploy_app_run_info where host_id = #{hostId};
  104. </delete>
  105. <delete id="deleteAppRunInfoExtend">
  106. delete from deploy_app_run_info_extend where host_id = #{hostId};
  107. </delete>
  108. <delete id="deleteBatchHostInfo">
  109. delete from deploy_batch_host_info where host_id = #{hostId};
  110. </delete>
  111. <select id="selectByOrg" resultType="com.xunmei.deploy.domain.HostInfo">
  112. select h.id,h.hostName,h.hostIp,h.hostSystem,h.hostFrame,h.hostMac,h.hostOrg,
  113. h.hostStatus,h.accessToken,h.expiresIn,h.tokenType,h.scope,h.agentVersion,
  114. h.isPush,h.tokenCreateTime,h.coreTimeStamp,h.frontTimeStamp,h.upload_version,h.encryption
  115. from deploy_host_info h
  116. left join hv_host_org v on h.id = v.register_code
  117. left join hv_org o on v.org_id = o.org_id
  118. where 1 =1
  119. <if test="orgId != '' and orgId != null">
  120. and o.is_deleted = 0 and o.path like concat('%#', #{orgId}, '#%' )
  121. </if>
  122. <if test="agentVersion != '' and agentVersion != null">
  123. and h.agentVersion = #{agentVersion}
  124. </if>
  125. <if test="hostStatus != '' and hostStatus != null">
  126. and h.hostStatus = #{hostStatus}
  127. </if>
  128. <if test="uploadVersion != '' and uploadVersion != null">
  129. and h.upload_version = #{uploadVersion}
  130. </if>
  131. <if test="hostIp != '' and hostIp != null">
  132. and h.hostIp like CONCAT('%', #{hostIp}, '%' )
  133. </if>
  134. </select>
  135. <select id="selectPage" resultType="com.xunmei.deploy.vo.HostInfoVo">
  136. SELECT
  137. h.id,h.hostName,h.hostIp,h.hostSystem,h.hostFrame,h.hostMac,h.hostOrg,h.hostStatus,h.accessToken,h.expiresIn,h.tokenType,h.scope,h.agentVersion,
  138. if(h.agentVersion=(SELECT h.agentVersion as version FROM deploy_host_info UNION SELECT package_version as version FROM deploy_package_info order by version DESC limit 1 ),0,1) as upgradeFlag,
  139. h.isPush,h.tokenCreateTime, h.coreTimeStamp,h.frontTimeStamp,h.upload_version,h.encryption,v.org_name AS orgName
  140. FROM deploy_host_info h
  141. LEFT JOIN hv_host_org v ON h.id = v.register_code
  142. LEFT JOIN hv_org o ON v.org_id = o.org_id
  143. <where>
  144. <if test="info.hostOrg != '' and info.hostOrg != null">
  145. o.IS_DELETED = 0 AND o.PATH LIKE CONCAT('%#', #{info.hostOrg}, '#%' )
  146. </if>
  147. <if test="info.agentVersion != '' and info.agentVersion != null">
  148. AND h.agentVersion = #{info.agentVersion}
  149. </if>
  150. <if test="info.uploadVersion != '' and info.uploadVersion != null">
  151. AND h.upload_version = #{info.uploadVersion}
  152. </if>
  153. <if test="info.hostIp != '' and info.hostIp != null">
  154. AND h.hostIp LIKE CONCAT('%', #{info.hostIp}, '%' )
  155. </if>
  156. <if test="info.hostStatus != '' and info.hostStatus != null">
  157. AND h.hostStatus = #{info.hostStatus}
  158. </if>
  159. </where>
  160. </select>
  161. </mapper>