From 07f63dbeee150f01374056da464c51c3fb19ae15 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 7 Nov 2023 18:27:33 +0800 Subject: [PATCH 1/2] upgrade setting file --- config/settings.demo.yml | 6 +++- config/settings.full.yml | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 config/settings.full.yml diff --git a/config/settings.demo.yml b/config/settings.demo.yml index 812452f..1793ab7 100644 --- a/config/settings.demo.yml +++ b/config/settings.demo.yml @@ -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 diff --git a/config/settings.full.yml b/config/settings.full.yml new file mode 100644 index 0000000..307cc77 --- /dev/null +++ b/config/settings.full.yml @@ -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 From 6779aa82f2b022c6e473263e44ac32f37d15c2d2 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 7 Nov 2023 19:49:51 +0800 Subject: [PATCH 2/2] translate --- app/admin/apis/sys_menu.go | 33 ++++++++++++++++++++++++++++++ app/admin/router/sys_menu.go | 1 + app/admin/service/sys_api.go | 2 +- app/admin/service/sys_config.go | 2 +- app/admin/service/sys_dept.go | 2 +- app/admin/service/sys_dict_data.go | 2 +- app/admin/service/sys_dict_type.go | 2 +- app/admin/service/sys_login_log.go | 2 +- app/admin/service/sys_menu.go | 2 +- app/admin/service/sys_opera_log.go | 2 +- app/admin/service/sys_post.go | 2 +- app/admin/service/sys_role.go | 4 ++-- app/admin/service/sys_user.go | 2 +- 13 files changed, 46 insertions(+), 12 deletions(-) diff --git a/app/admin/apis/sys_menu.go b/app/admin/apis/sys_menu.go index c6fbb85..e6b5f95 100644 --- a/app/admin/apis/sys_menu.go +++ b/app/admin/apis/sys_menu.go @@ -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 diff --git a/app/admin/router/sys_menu.go b/app/admin/router/sys_menu.go index d21537f..d32ce5a 100644 --- a/app/admin/router/sys_menu.go +++ b/app/admin/router/sys_menu.go @@ -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) } diff --git a/app/admin/service/sys_api.go b/app/admin/service/sys_api.go index 1731c4f..182804f 100644 --- a/app/admin/service/sys_api.go +++ b/app/admin/service/sys_api.go @@ -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 diff --git a/app/admin/service/sys_config.go b/app/admin/service/sys_config.go index cbe9c2e..9b60cde 100644 --- a/app/admin/service/sys_config.go +++ b/app/admin/service/sys_config.go @@ -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 } diff --git a/app/admin/service/sys_dept.go b/app/admin/service/sys_dept.go index 8cb323e..c6f81c6 100644 --- a/app/admin/service/sys_dept.go +++ b/app/admin/service/sys_dept.go @@ -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 } diff --git a/app/admin/service/sys_dict_data.go b/app/admin/service/sys_dict_data.go index b0961c4..266bf29 100644 --- a/app/admin/service/sys_dict_data.go +++ b/app/admin/service/sys_dict_data.go @@ -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 } diff --git a/app/admin/service/sys_dict_type.go b/app/admin/service/sys_dict_type.go index 8e26a27..febee47 100644 --- a/app/admin/service/sys_dict_type.go +++ b/app/admin/service/sys_dict_type.go @@ -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 } diff --git a/app/admin/service/sys_login_log.go b/app/admin/service/sys_login_log.go index d3ebced..5be5288 100644 --- a/app/admin/service/sys_login_log.go +++ b/app/admin/service/sys_login_log.go @@ -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 } diff --git a/app/admin/service/sys_menu.go b/app/admin/service/sys_menu.go index 498be6b..66c56ec 100644 --- a/app/admin/service/sys_menu.go +++ b/app/admin/service/sys_menu.go @@ -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 diff --git a/app/admin/service/sys_opera_log.go b/app/admin/service/sys_opera_log.go index 097424a..f5a2de9 100644 --- a/app/admin/service/sys_opera_log.go +++ b/app/admin/service/sys_opera_log.go @@ -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 } diff --git a/app/admin/service/sys_post.go b/app/admin/service/sys_post.go index e8cbd17..e41623e 100644 --- a/app/admin/service/sys_post.go +++ b/app/admin/service/sys_post.go @@ -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 } diff --git a/app/admin/service/sys_role.go b/app/admin/service/sys_role.go index 5917b6a..2f85d58 100644 --- a/app/admin/service/sys_role.go +++ b/app/admin/service/sys_role.go @@ -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 } @@ -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 diff --git a/app/admin/service/sys_user.go b/app/admin/service/sys_user.go index ff19365..62dfe65 100644 --- a/app/admin/service/sys_user.go +++ b/app/admin/service/sys_user.go @@ -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 }