Skip to content

Commit

Permalink
Dev 1.4.0 (#79)
Browse files Browse the repository at this point in the history
<!--
First of all, thank you for your contribution! 😄

For requesting to pull a new feature or bugfix, please send it from a
feature/bugfix branch based on the `master` branch.

Before submitting your pull request, please make sure the checklist
below is confirmed.

Your pull requests will be merged after one of the collaborators
approve.

Thank you!

-->

### 🤔 This is a ...

- [x] New feature
- [x] Bug fix
- [ ] Site / documentation update
- [ ] Demo update
- [ ] Component style update
- [ ] TypeScript definition update
- [ ] Bundle size optimization
- [ ] Performance optimization
- [ ] Enhancement feature
- [ ] Internationalization
- [ ] Refactoring
- [ ] Code style optimization
- [ ] Test Case
- [ ] Branch merge
- [ ] Other (about what?)

### 🔗 Related issue link

<!--
1. Put the related issue or discussion links here.
-->

### 💡 Background and solution

<!--
1. Describe the problem and the scenario.
2. GIF or snapshot should be provided if includes UI/interactive
modification.
3. How to fix the problem, and list the final API implementation and
usage sample if that is a new feature.
-->

### 📝 Changelog

<!--
Describe changes from the user side, and list all potential break
changes or other risks.
--->

| Language   | Changelog |
| ---------- | --------- |
| 🇺🇸 English |           |
| 🇨🇳 Chinese |           |

### ☑️ Self-Check before Merge

⚠️ Please check all items below before review. ⚠️

- [x] Doc is updated/provided or not needed
- [ ] Demo is updated/provided or not needed
- [ ] TypeScript's definition is updated/provided or not needed
- [ ] Changelog is provided or not needed
  • Loading branch information
xxl4 authored Dec 5, 2023
2 parents c3edbf6 + cf0ca18 commit 849eea0
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions app/admin/apis/sys_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down
20 changes: 10 additions & 10 deletions app/admin/apis/sys_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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 修改用户角色状态
Expand All @@ -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 更新角色数据权限
Expand Down Expand Up @@ -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"))
}
4 changes: 2 additions & 2 deletions common/global/adm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
48 changes: 48 additions & 0 deletions deploy/k8s/easy-admin-deployment-and-service.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions deploy/k8s/easy-admin-storage.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
45 changes: 19 additions & 26 deletions docs/guide/install/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -62,14 +44,25 @@ spec:
- name: easy-admin-config
mountPath: /config/
readOnly: true
volumes:
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
---
````
```
apiVersion: v1
Expand Down
6 changes: 4 additions & 2 deletions docs/zh/guide/install/binary.md
Original file line number Diff line number Diff line change
@@ -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) 下载可执行文件

Expand All @@ -27,5 +30,4 @@ netstat -an | grep 8000
```

### 提交BUG与建议
https://github.com/nicelizhi/easy-admin/issues

[提交](https://github.com/nicelizhi/easy-admin/issues)
40 changes: 40 additions & 0 deletions easy-admin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"fmt"
"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 {
gin.SetMode(gin.TestMode)
router := gin.Default()
fmt.Println(router.Routes())
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)
}

func TestUserLoginHandler(t *testing.T) {
// r := SetUpRouter()
// r.GET("/api/v1/getinfo", apis.SysUser.GetInfo)

}
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -114,13 +116,15 @@ 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
github.com/prometheus/procfs v0.11.1 // indirect
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
Expand Down
Loading

0 comments on commit 849eea0

Please sign in to comment.