From 503aa1118a2452841183ba42e8b7fb8e93a19e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 27 Nov 2020 10:41:19 +0800 Subject: [PATCH] =?UTF-8?q?[=E9=9B=86=E7=BE=A4]=E6=98=BE=E7=A4=BA=E9=9B=86?= =?UTF-8?q?=E7=BE=A4=E6=9C=89=E8=8A=82=E7=82=B9=E9=9C=80=E8=A6=81=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_dao.go | 15 +++++++++++++++ internal/rpc/services/service_node.go | 23 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index 9d459bcc..3ae07f42 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -575,6 +575,21 @@ func (this *NodeDAO) FindAllNotInstalledNodesWithClusterId(clusterId int64) (res return } +// 计算所有低于某个版本的节点数量 +func (this *NodeDAO) CountAllLowerVersionNodesWithClusterId(clusterId int64, os string, arch string, version string) (int64, error) { + return this.Query(). + State(NodeStateEnabled). + Attr("clusterId", clusterId). + Where("status IS NOT NULL"). + Where("JSON_EXTRACT(status, '$.os')=:os"). + Where("JSON_EXTRACT(status, '$.arch')=:arch"). + Where("INET_ATON(JSON_UNQUOTE(JSON_EXTRACT(status, '$.buildVersion')))