From 8a3be4ea780d1fb8dbce2dd74dee9aef3fa1a5e3 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 18 Nov 2023 09:31:58 +0800 Subject: [PATCH 01/12] add dev 1.4.0 for easy-admin --- .github/workflows/build.yml | 2 +- common/global/adm.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7790f0f..e12b0e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,7 +101,7 @@ jobs: context: . file: ./Dockerfile push: true - tags: nicesteven/easy-admin:1.3.0 + tags: nicesteven/easy-admin:1.4.0 - name: Build and push Docker image uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 diff --git a/common/global/adm.go b/common/global/adm.go index 2d16ea5..f8acfa4 100644 --- a/common/global/adm.go +++ b/common/global/adm.go @@ -2,8 +2,8 @@ package global const ( // Version easy-admin version info - Version = "1.3.0" - VersionNum = 130 // version number + Version = "1.4.0" + VersionNum = 140 // version number HomePage = "https://github.com/nicelizhi/easy-admin/" //project home page TemplateVer = "v1" ) From 5d5553c939582576c6394dd911c2d00bf7de3bec Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 18 Nov 2023 09:32:36 +0800 Subject: [PATCH 02/12] add changelog for 1.4.0 --- docs/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 699dacd..d8304d0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,9 @@ # Easy Admin Change log > All notable changes to this project will be documented in this file. +## [v1.4.0](https://github.com/nicelizhi/easy-admin/releases/tag/1.4.0) + + ## [v1.3.0](https://github.com/nicelizhi/easy-admin/releases/tag/1.3.0) . fix the lang support . add gzip support and gzip config From 3da5be738240d17527f388db8b7f66b8cb99f14d Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 18 Nov 2023 09:38:10 +0800 Subject: [PATCH 03/12] upgrade 1.4.0 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8ef2129..0b42e8b 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ LDFLAGS := -s -w # application name PROJECT:=easy-admin # application version -VERSION := 1.3.0 +VERSION := 1.4.0 # application url URL := https://github.com/nicelizhi/easy-admin From efce3adf3b16e9c2407aea67f2093e45891b66dd Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 18 Nov 2023 13:50:07 +0800 Subject: [PATCH 04/12] add test for index --- easy-admin_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 easy-admin_test.go diff --git a/easy-admin_test.go b/easy-admin_test.go new file mode 100644 index 0000000..06e5ce1 --- /dev/null +++ b/easy-admin_test.go @@ -0,0 +1,31 @@ +package main + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/gin-gonic/gin" + "github.com/nicelizhi/easy-admin/app/admin/apis" + "github.com/stretchr/testify/assert" +) + +func HomepageHandler(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "Welcome golang"}) +} + +func SetUpRouter() *gin.Engine { + router := gin.Default() + return router +} +func TestHomepageHandler(t *testing.T) { + // mockResponse := `{"message":"Welcome goland"}` + r := SetUpRouter() + r.GET("/", apis.EasyAdminStart) + req, _ := http.NewRequest("GET", "/", nil) + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + // responseData, _ := ioutil.ReadAll(w.Body) + // assert.Equal(t, mockResponse, string(responseData)) + assert.Equal(t, http.StatusOK, w.Code) +} From 0a794fc575c31a99f93177065d4cd1ed7c0a52c4 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 18 Nov 2023 14:00:45 +0800 Subject: [PATCH 05/12] add test case --- go.mod | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go.mod b/go.mod index f2c40e9..2fe5e28 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil/v3 v3.23.10 github.com/spf13/cobra v1.0.0 + github.com/stretchr/testify v1.8.4 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.2 @@ -57,6 +58,7 @@ require ( github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.7.0 // indirect @@ -114,6 +116,7 @@ require ( github.com/nsqio/go-nsq v1.1.0 // indirect github.com/nyaruka/phonenumbers v1.0.55 // indirect github.com/pelletier/go-toml/v2 v2.0.9 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect github.com/prometheus/common v0.44.0 // indirect @@ -121,6 +124,7 @@ require ( github.com/redis/go-redis/v9 v9.3.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230126093431-47fa9a501578 // indirect github.com/robinjoseph08/redisqueue/v2 v2.1.0 // indirect + github.com/rs/xid v1.5.0 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shamsher31/goimgext v1.0.0 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect From 0002845e09c93caa483b765e9c7ed356edbd49d3 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 18 Nov 2023 18:37:08 +0800 Subject: [PATCH 06/12] upgrade test case --- easy-admin_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/easy-admin_test.go b/easy-admin_test.go index 06e5ce1..7c94817 100644 --- a/easy-admin_test.go +++ b/easy-admin_test.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "net/http" "net/http/httptest" "testing" @@ -15,7 +16,9 @@ func HomepageHandler(c *gin.Context) { } func SetUpRouter() *gin.Engine { + gin.SetMode(gin.TestMode) router := gin.Default() + fmt.Println(router.Routes()) return router } func TestHomepageHandler(t *testing.T) { @@ -29,3 +32,9 @@ func TestHomepageHandler(t *testing.T) { // assert.Equal(t, mockResponse, string(responseData)) assert.Equal(t, http.StatusOK, w.Code) } + +func TestUserLoginHandler(t *testing.T) { + // r := SetUpRouter() + // r.GET("/api/v1/getinfo", apis.SysUser.GetInfo) + +} From 65371dbc0caa3a364e1e42dbe2fef044f8ab6d47 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 19 Nov 2023 07:24:56 +0800 Subject: [PATCH 07/12] Update lang --- app/admin/apis/sys_role.go | 20 ++++++++++---------- lang/localizeJSON/zh.json | 6 ++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/admin/apis/sys_role.go b/app/admin/apis/sys_role.go index add2aab..3ab1a58 100644 --- a/app/admin/apis/sys_role.go +++ b/app/admin/apis/sys_role.go @@ -131,13 +131,13 @@ func (e SysRole) Insert(c *gin.Context) { err = s.Insert(&req, cb) if err != nil { e.Logger.Error(err) - e.Error(500, err, "创建失败,"+err.Error()) + e.Error(500, err, ginI18n.MustGetMessage(c, "Creation failed")+err.Error()) return } _, err = global.LoadPolicy(c) if err != nil { e.Logger.Error(err) - e.Error(500, err, "创建失败,"+err.Error()) + e.Error(500, err, ginI18n.MustGetMessage(c, "Creation failed")+err.Error()) return } e.OK(req.GetId(), ginI18n.MustGetMessage(c, "Created successfully")) @@ -179,7 +179,7 @@ func (e SysRole) Update(c *gin.Context) { _, err = global.LoadPolicy(c) if err != nil { e.Logger.Error(err) - e.Error(500, err, "更新失败,"+err.Error()) + e.Error(500, err, ginI18n.MustGetMessage(c, "Update failed")+err.Error()) return } @@ -204,7 +204,7 @@ func (e SysRole) Delete(c *gin.Context) { Errors if err != nil { e.Logger.Error(err) - e.Error(500, err, fmt.Sprintf("删除角色 %v 失败,\r\n失败信息 %s", req.Ids, err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Delete role failed failure message"), req.Ids, err.Error())) return } @@ -216,7 +216,7 @@ func (e SysRole) Delete(c *gin.Context) { return } - e.OK(req.GetId(), fmt.Sprintf("删除角色角色 %v 状态成功!", req.GetId())) + e.OK(req.GetId(), fmt.Sprintf(ginI18n.MustGetMessage(c, "Delete role role status successful"), req.GetId())) } // Update2Status 修改用户角色状态 @@ -239,16 +239,16 @@ func (e SysRole) Update2Status(c *gin.Context) { Errors if err != nil { e.Logger.Error(err) - e.Error(500, err, fmt.Sprintf("更新角色状态失败,失败原因:%s ", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Failed to update role status reason for failure"), err.Error())) return } req.SetUpdateBy(user.GetUserId(c)) err = s.UpdateStatus(&req) if err != nil { - e.Error(500, err, fmt.Sprintf("更新角色状态失败,失败原因:%s ", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Failed to update role status reason for failure"), err.Error())) return } - e.OK(req.GetId(), fmt.Sprintf("更新角色 %v 状态成功!", req.GetId())) + e.OK(req.GetId(), fmt.Sprintf(ginI18n.MustGetMessage(c, "Update role status successful"), req.GetId())) } // Update2DataScope 更新角色数据权限 @@ -282,8 +282,8 @@ func (e SysRole) Update2DataScope(c *gin.Context) { data.UpdateBy = user.GetUserId(c) err = s.UpdateDataScope(&req).Error if err != nil { - e.Error(500, err, fmt.Sprintf("更新角色数据权限失败!错误详情:%s", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Failed to update role data permission! Error details"), err.Error())) return } - e.OK(nil, "操作成功") + e.OK(nil, ginI18n.MustGetMessage(c, "Options Success")) } diff --git a/lang/localizeJSON/zh.json b/lang/localizeJSON/zh.json index 5e2f81c..8d2834e 100644 --- a/lang/localizeJSON/zh.json +++ b/lang/localizeJSON/zh.json @@ -37,6 +37,12 @@ "Upload Success": "上传成功", "Login failed": "登录失败", "Verification code error": "验证码错误", + "Options Success": "操作成功", + "Failed to update role data permission! Error details": "更新角色数据权限失败!错误详情:%s", + "Update role status successful": "更新角色 %v 状态成功!", + "Failed to update role status reason for failure": "更新角色状态失败,失败原因:%s", + "Delete role role status successful": "删除角色角色 %v 状态成功!", + "Delete role failed failure message": "删除角色 %v 失败,\r\n失败信息 %s", From 418a0c21bf5009c263b0b6116c16d03720b78608 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 19 Nov 2023 07:54:50 +0800 Subject: [PATCH 08/12] add k8s deploy --- .../easy-admin-deployment-and-service.yaml | 48 +++++++++++++++++++ deploy/k8s/easy-admin-storage.yml | 13 +++++ 2 files changed, 61 insertions(+) create mode 100644 deploy/k8s/easy-admin-deployment-and-service.yaml create mode 100644 deploy/k8s/easy-admin-storage.yml diff --git a/deploy/k8s/easy-admin-deployment-and-service.yaml b/deploy/k8s/easy-admin-deployment-and-service.yaml new file mode 100644 index 0000000..d68e5c3 --- /dev/null +++ b/deploy/k8s/easy-admin-deployment-and-service.yaml @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: easy-admin +spec: + selector: + matchLabels: + app: easy-admin + template: + metadata: + labels: + app: easy-admin + spec: + containers: + - name: easy-admin + image: nicesteven/easy-admin:latest + resources: + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 8080 + volumeMounts: + - name: easy-admin + mountPath: /temp + - name: easy-admin + mountPath: /static + - name: easy-admin-config + mountPath: /config/ + readOnly: true + volumes: + - name: easy-admin + persistentVolumeClaim: + claimName: easy-admin + - name: easy-admin-config + configMap: + name: settings-admin +--- +apiVersion: v1 +kind: Service +metadata: + name: easy-admin-svc +spec: + selector: + app: easy-admin-port + ports: + - port: 8080 + targetPort: 8080 \ No newline at end of file diff --git a/deploy/k8s/easy-admin-storage.yml b/deploy/k8s/easy-admin-storage.yml new file mode 100644 index 0000000..6400349 --- /dev/null +++ b/deploy/k8s/easy-admin-storage.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: easy-admin + namespace: easy-admin +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: "1Mi" + volumeName: + storageClassName: nfs-csi \ No newline at end of file From 4dc14ae9a93a62bf4b0a3abd46a0f9120fc7f2b1 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 19 Nov 2023 07:56:31 +0800 Subject: [PATCH 09/12] upgrade k8s document --- docs/guide/install/k8s.md | 45 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/docs/guide/install/k8s.md b/docs/guide/install/k8s.md index 235c7e3..21b075c 100644 --- a/docs/guide/install/k8s.md +++ b/docs/guide/install/k8s.md @@ -14,46 +14,28 @@ ### 3、Start It ``` --- -apiVersion: v1 -kind: Service -metadata: - name: easy-admin - labels: - app: easy-admin - service: easy-admin -spec: - ports: - - port: 8000 - name: http - protocol: TCP - selector: - app: easy-admin ---- apiVersion: apps/v1 kind: Deployment metadata: - name: easy-admin-v1 - labels: - app: easy-admin - version: v1 + name: easy-admin spec: - replicas: 1 selector: matchLabels: app: easy-admin - version: v1 template: metadata: labels: app: easy-admin - version: v1 spec: containers: - name: easy-admin - image: registry.ap-southeast-1.aliyuncs.com/kuops/easy-admin:1.10 - imagePullPolicy: IfNotPresent + image: nicesteven/easy-admin:latest + resources: + limits: + memory: "128Mi" + cpu: "500m" ports: - - containerPort: 8000 + - containerPort: 8080 volumeMounts: - name: easy-admin mountPath: /temp @@ -62,7 +44,7 @@ spec: - name: easy-admin-config mountPath: /config/ readOnly: true - volumes: + volumes: - name: easy-admin persistentVolumeClaim: claimName: easy-admin @@ -70,6 +52,17 @@ spec: configMap: name: settings-admin --- +apiVersion: v1 +kind: Service +metadata: + name: easy-admin-svc +spec: + selector: + app: easy-admin-port + ports: + - port: 8080 + targetPort: 8080 +--- ```` ``` apiVersion: v1 From e43d5db737f2f95372508ebd54cef86eaf16dafc Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 19 Nov 2023 08:55:04 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E5=AE=8C=E5=96=84=20=E4=BA=8C=E8=BF=9B?= =?UTF-8?q?=E5=88=B6=E9=83=A8=E7=BD=B2=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh/guide/install/binary.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/zh/guide/install/binary.md b/docs/zh/guide/install/binary.md index 2d95905..9387adc 100644 --- a/docs/zh/guide/install/binary.md +++ b/docs/zh/guide/install/binary.md @@ -1,9 +1,12 @@ # 二进制下载安装 > 通过此方案,简单的通过下载对应平台的可执行文件,做下简单的文件配置就可以完成应用的开启使用 + + [English](https://nicelizhi.github.io/easy-admin/guide/install/binary) | 简体中文 ### 1、准备 +> [在线教学视频](https://www.youtube.com/watch?v=i6g7AoLhrUQ) > [Easy Admin 官方下载页面](https://github.com/nicelizhi/easy-admin/releases) 下载可执行文件 @@ -27,5 +30,4 @@ netstat -an | grep 8000 ``` ### 提交BUG与建议 -https://github.com/nicelizhi/easy-admin/issues - +[提交](https://github.com/nicelizhi/easy-admin/issues) \ No newline at end of file From 7cc63e95bd2c3cc6c3bd6a26a43e02a0fdf8fa3c Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 19 Nov 2023 09:37:07 +0800 Subject: [PATCH 11/12] update lang --- app/admin/apis/sys_post.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/admin/apis/sys_post.go b/app/admin/apis/sys_post.go index ef4754c..a3e7fc7 100644 --- a/app/admin/apis/sys_post.go +++ b/app/admin/apis/sys_post.go @@ -82,7 +82,7 @@ func (e SysPost) Get(c *gin.Context) { err = s.Get(&req, &object) if err != nil { - e.Error(500, err, fmt.Sprintf("岗位信息获取失败!错误详情:%s", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Failed to obtain position information Error details"), err.Error())) return } @@ -115,7 +115,7 @@ func (e SysPost) Insert(c *gin.Context) { req.SetCreateBy(user.GetUserId(c)) err = s.Insert(&req) if err != nil { - e.Error(500, err, fmt.Sprintf("新建岗位失败!错误详情:%s", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Failed to create new position Error details"), err.Error())) return } e.OK(req.GetId(), ginI18n.MustGetMessage(c, "Created successfully")) @@ -149,7 +149,7 @@ func (e SysPost) Update(c *gin.Context) { err = s.Update(&req) if err != nil { - e.Error(500, err, fmt.Sprintf("岗位更新失败!错误详情:%s", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Position update failed error details"), err.Error())) return } e.OK(req.GetId(), ginI18n.MustGetMessage(c, "Update completed")) @@ -179,7 +179,7 @@ func (e SysPost) Delete(c *gin.Context) { req.SetUpdateBy(user.GetUserId(c)) err = s.Remove(&req) if err != nil { - e.Error(500, err, fmt.Sprintf("岗位删除失败!错误详情:%s", err.Error())) + e.Error(500, err, fmt.Sprintf(ginI18n.MustGetMessage(c, "Position update failed error details"), err.Error())) return } e.OK(req.GetId(), ginI18n.MustGetMessage(c, "Successfully deleted")) From cf0ca1845d0cbb5c8f52d84c1d9949cd82190b0b Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 5 Dec 2023 15:22:13 +0800 Subject: [PATCH 12/12] upgrade --- lang/localizeJSON/zh.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lang/localizeJSON/zh.json b/lang/localizeJSON/zh.json index 8d2834e..b2ccac8 100644 --- a/lang/localizeJSON/zh.json +++ b/lang/localizeJSON/zh.json @@ -43,6 +43,9 @@ "Failed to update role status reason for failure": "更新角色状态失败,失败原因:%s", "Delete role role status successful": "删除角色角色 %v 状态成功!", "Delete role failed failure message": "删除角色 %v 失败,\r\n失败信息 %s", + "Failed to obtain position information Error details": "岗位信息获取失败!错误详情:%s", + "Failed to create new position Error details": "新建岗位失败!错误详情:%s", + "Position update failed error details": "岗位更新失败!错误详情:%s",