Skip to content

Commit

Permalink
Merge pull request #41 from nicelizhi/dev-1.2.0
Browse files Browse the repository at this point in the history
Dev 1.2.0
  • Loading branch information
xxl4 authored Nov 7, 2023
2 parents 90da71a + 6779aa8 commit 8b82366
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 13 deletions.
33 changes: 33 additions & 0 deletions app/admin/apis/sys_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,39 @@ func (e SysMenu) GetPage(c *gin.Context) {
e.OK(list, ginI18n.MustGetMessage(c, "Query successful"))
}

// GetPage Menu自定义列表列表数据
// @Summary Menu列表数据
// @Description 获取JSON
// @Tags 菜单
// @Param menuName query string false "menuName"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/cusmenu [get]
// @Security Bearer
func (e SysMenu) CusGetPage(c *gin.Context) {
s := service.SysMenu{}
req := dto.SysMenuGetPageReq{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req, binding.Form).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
var list = make([]models.SysMenu, 0)
err = s.GetPage(&req, &list).Error
if err != nil {
e.Error(500, err, ginI18n.MustGetMessage(c, "Query failed"))
return
}

list2 := make(map[string]interface{}, 0)

e.OK(list2, ginI18n.MustGetMessage(c, "Query successful"))
}

// Get 获取菜单详情
// @Summary Menu详情数据
// @Description 获取JSON
Expand Down
1 change: 1 addition & 0 deletions app/admin/router/sys_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func registerSysMenuRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
r1 := v1.Group("").Use(authMiddleware.MiddlewareFunc())
{
r1.GET("/menurole", api.GetMenuRole)
r1.GET("/cusmenu", api.CusGetPage)
//r1.GET("/menuids", api.GetMenuIDS)
}

Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (e *SysApi) Get(d *dto.SysApiGetReq, p *actions.DataPermission, model *mode
).
First(model, d.GetId()).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("Service GetSysApi error:%s", err)
_ = e.AddError(err)
return e
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (e *SysConfig) GetPage(c *dto.SysConfigGetPageReq, list *[]models.SysConfig
func (e *SysConfig) Get(d *dto.SysConfigGetReq, model *models.SysConfig) error {
err := e.Orm.First(model, d.GetId()).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("Service GetSysConfigPage error:%s", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_dept.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (e *SysDept) Get(d *dto.SysDeptGetReq, model *models.SysDept) error {
First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error:%s", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_dict_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (e *SysDictData) Get(d *dto.SysDictDataGetReq, model *models.SysDictData) e
First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error: %s", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (e *SysDictType) Get(d *dto.SysDictTypeGetReq, model *models.SysDictType) e
db := e.Orm.First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error: %s", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_login_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (e *SysLoginLog) Get(d *dto.SysLoginLogGetReq, model *models.SysLoginLog) e
db := e.Orm.First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error:%s", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (e *SysMenu) Get(d *dto.SysMenuGetReq, model *models.SysMenu) *SysMenu {
First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("GetSysMenu error:%s", err)
_ = e.AddError(err)
return e
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_opera_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (e *SysOperaLog) Get(d *dto.SysOperaLogGetReq, model *models.SysOperaLog) e
err := e.Orm.Model(&data).
First(model, d.GetId()).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("Service GetSysOperaLog error:%s", err.Error())
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (e *SysPost) Get(d *dto.SysPostGetReq, model *models.SysPost) error {
First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error:%s", err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions app/admin/service/sys_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (e *SysRole) Get(d *dto.SysRoleGetReq, model *models.SysRole) error {
db := e.Orm.First(model, d.GetId())
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error:%s", err)
return err
}
Expand Down Expand Up @@ -317,7 +317,7 @@ func (e *SysRole) GetWithName(d *dto.SysRoleByName, model *models.SysRole) *SysR
db := e.Orm.Where("role_name = ?", d.RoleName).First(model)
err = db.Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error:%s", err)
_ = e.AddError(err)
return e
Expand Down
2 changes: 1 addition & 1 deletion app/admin/service/sys_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (e *SysUser) Get(d *dto.SysUserById, p *actions.DataPermission, model *mode
).
First(model, d.GetId()).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看")
err = errors.New("the object being viewed does not exist or does not have permission to view it")
e.Log.Errorf("db error: %s", err)
return err
}
Expand Down
6 changes: 5 additions & 1 deletion config/settings.demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ settings:
port: 8000
readtimeout: 10000
writertimeout: 20000
# timezone
timezone: "Africa/Cairo"
# local
local: "en"
database:
driver: mysql
source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
gen:
dbname: testhhh
dbname: dbname
frontpath: ../ui/src
jwt:
secret: easy-admin
Expand Down
59 changes: 59 additions & 0 deletions config/settings.full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
settings:
application:
# dev test prod
mode: dev
# host IP ,default 0.0.0.0
host: 0.0.0.0
# application name
name: easy-admin
# application port
port: 8000
readtimeout: 1
writertimeout: 2
# enable dp
enabledp: false
# timezone
timezone: "Africa/Cairo"
# local
local: "en"
ssl:
# https domain
domain: localhost:8000
# https enable
enable: false
# ssl key
key: keystring
# ssl pem path
pem: temp/pem.pem
logger:
# log save path
path: temp/logs
# file / default
stdout: ''
# trace, debug, info, warn, error, fatal
level: trace
# enable db log
enableddb: false
jwt:
# token secret
secret: easy-admin
# token timeout (S)
timeout: 3600
database:
# mysql,sqlite3, postgres
driver: mysql
source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
# source: sqlite3.db
# source: host=myhost port=myport user=gorm dbname=gorm password=mypassword
registers:
- sources:
- user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
gen:
dbname: dbname
frontpath: ../ui/src
queue:
memory:
poolSize: 100
extend: # ext config
demo:
name: data

0 comments on commit 8b82366

Please sign in to comment.