From 2531ea7b37bf69482f58ff1a19cd575c6ef972a8 Mon Sep 17 00:00:00 2001 From: sunxiaolong Date: Thu, 27 Jun 2024 03:22:24 +0800 Subject: [PATCH] =?UTF-8?q?:rocket:=20=E6=B7=BB=E5=8A=A0ci/cd=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E9=83=A8=E7=BD=B2=E7=A8=8B=E5=BA=8F=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E9=9D=A2=E9=A2=9D=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 42 ++------------------------- Jenkinsfile.bak | 63 ++++++++++++++++++++++++++++++++++++++++ controllers/user_info.go | 22 ++++++++++++-- 3 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 Jenkinsfile.bak diff --git a/Jenkinsfile b/Jenkinsfile index 9c22562..e51a268 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,46 +7,10 @@ pipeline { script { try { echo 'Start Build' - sh 'docker compose -f docker-compose.yaml down' - sh 'docker compose -f docker-compose.yaml up -d --build' - echo 'Build success' - } catch (err) { - echo err.getMessage() - } - } - } - post { // 添加post指令处理阶段完成后的情况 - failure { - echo 'Build failed, but continuing to the next stage...' - } - } - } - stage('Build Image With rabbit') { - agent { label '流氓兔' } // 在标签为'linux-build'的节点上执行 - steps { - script { - try { - echo 'Start Build' - sh 'docker compose -f docker-compose.yaml up -d --build' - echo 'Build success' - } catch (err) { - echo err.getMessage() - } - } - } - post { // 添加post指令处理阶段完成后的情况 - failure { - echo 'Build failed, but continuing to the next stage...' - } - } - } - stage('Build Image With L') { - agent { label 'L' } // 在标签为'linux-build'的节点上执行 - steps { - script { - try { - echo 'Start Build' + sh "docker ps -a --format '{{.ID}} {{.Names}}' | awk '{if (\$2 !~ /^1Panel-jenkins/) print \$1}' | xargs -r docker stop" sh 'docker compose -f docker-compose.yaml up -d --build' + sh 'docker start \$(docker ps -a -q)' + sh "docker restart \$(docker ps -a | grep kami_ | awk '{print \$1}')" echo 'Build success' } catch (err) { echo err.getMessage() diff --git a/Jenkinsfile.bak b/Jenkinsfile.bak new file mode 100644 index 0000000..7dd877e --- /dev/null +++ b/Jenkinsfile.bak @@ -0,0 +1,63 @@ +pipeline { + agent none + stages { + stage('Build Image With localhost') { + agent { label 'LocalHost' } // 在标签为'linux-build'的节点上执行 + steps { + script { + try { + echo 'Start Build' + sh 'docker stop $(docker ps -q --filter "status=running" --filter "name!=jenkins*")' + sh 'docker compose -f docker-compose.yaml up -d --build' + echo 'Build success' + } catch (err) { + echo err.getMessage() + } + } + } + post { // 添加post指令处理阶段完成后的情况 + failure { + echo 'Build failed, but continuing to the next stage...' + } + } + } + stage('Build Image With rabbit') { + agent { label '流氓兔' } // 在标签为'linux-build'的节点上执行 + steps { + script { + try { + echo 'Start Build' + sh 'docker compose -f docker-compose.yaml up -d --build' + echo 'Build success' + } catch (err) { + echo err.getMessage() + } + } + } + post { // 添加post指令处理阶段完成后的情况 + failure { + echo 'Build failed, but continuing to the next stage...' + } + } + } + stage('Build Image With L') { + agent { label 'L' } // 在标签为'linux-build'的节点上执行 + steps { + script { + try { + echo 'Start Build' + sh 'docker compose -f docker-compose.yaml up -d --build' + echo 'Build success' + } catch (err) { + echo err.getMessage() + } + } + } + post { // 添加post指令处理阶段完成后的情况 + failure { + echo 'Build failed, but continuing to the next stage...' + } + } + } + } +} \ No newline at end of file diff --git a/controllers/user_info.go b/controllers/user_info.go index bd637fd..04f103a 100644 --- a/controllers/user_info.go +++ b/controllers/user_info.go @@ -266,7 +266,6 @@ func (c *UserInfo) QueryAllowedMM() { _ = c.ServeJSON() return } - us := c.GetSession(enum.UserSession) u := us.(merchant.MerchantInfo) if u.Id == 0 { @@ -278,12 +277,31 @@ func (c *UserInfo) QueryAllowedMM() { return } result := service.QueryAllowedDeployInfoMM(u.MerchantUid, roadPool.RoadUid) + returnList := make([]struct { + ShowLabel float64 `json:"showLabel"` + }, 0) + for _, margin := range result { + isInList := false + for _, s := range returnList { + if s.ShowLabel == margin.ShowLabel { + // 存在 + isInList = true + } + } + if !isInList { + returnList = append(returnList, struct { + ShowLabel float64 `json:"showLabel"` + }{ + ShowLabel: margin.ShowLabel, + }) + } + } c.Data["json"] = response.CommonResWithData{ CommonRes: response.CommonRes{ Msg: "成功", Code: 0, }, - Data: result, + Data: returnList, } _ = c.ServeJSON() }