From abc5c41952056f9647e9abc5305549c27d5700c9 Mon Sep 17 00:00:00 2001 From: yxh Date: Fri, 18 Mar 2022 18:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=95=B0=E6=8D=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/system/sys_auth_rule.go | 35 ++++++ api/v1/system/sys_dict_data.go | 27 +++++ api/v1/system/{user.go => sys_user.go} | 0 internal/app/common/consts/cache.go | 8 ++ .../app/common/model/entity/sys_config.go | 24 +++++ .../app/common/model/entity/sys_dict_data.go | 28 +++++ .../app/common/model/entity/sys_dict_type.go | 23 ++++ internal/app/common/model/sys_config.go | 8 ++ internal/app/common/model/sys_dict_data.go | 21 ++++ internal/app/common/model/sys_dict_type.go | 8 ++ .../internal/dao/internal/sys_config.go | 92 ++++++++++++++++ .../internal/dao/internal/sys_dict_data.go | 100 ++++++++++++++++++ .../internal/dao/internal/sys_dict_type.go | 90 ++++++++++++++++ .../common/service/internal/dao/sys_config.go | 24 +++++ .../service/internal/dao/sys_dict_data.go | 24 +++++ .../service/internal/dao/sys_dict_type.go | 24 +++++ .../common/service/internal/do/sys_config.go | 26 +++++ .../service/internal/do/sys_dict_data.go | 30 ++++++ .../service/internal/do/sys_dict_type.go | 25 +++++ internal/app/common/service/sys_config.go | 8 ++ internal/app/common/service/sys_dict_data.go | 76 +++++++++++++ internal/app/common/service/sys_dict_type.go | 8 ++ internal/app/system/consts/cache.go | 7 +- internal/app/system/controller/base.go | 4 +- internal/app/system/controller/menu.go | 8 -- .../app/system/controller/sys_auth_rule.go | 24 +++++ .../app/system/controller/sys_dict_data.go | 25 +++++ .../app/system/controller/sys_dict_type.go | 8 ++ .../controller/{user.go => sys_user.go} | 10 +- .../app/system/model/entity/sys_auth_rule.go | 6 +- internal/app/system/router/router.go | 2 + .../internal/dao/internal/sys_auth_rule.go | 10 +- .../service/internal/do/sys_auth_rule.go | 6 +- internal/app/system/service/sys_auth_rule.go | 11 ++ manifest/config/config.yaml | 2 +- 35 files changed, 803 insertions(+), 29 deletions(-) create mode 100644 api/v1/system/sys_auth_rule.go create mode 100644 api/v1/system/sys_dict_data.go rename api/v1/system/{user.go => sys_user.go} (100%) create mode 100644 internal/app/common/model/entity/sys_config.go create mode 100644 internal/app/common/model/entity/sys_dict_data.go create mode 100644 internal/app/common/model/entity/sys_dict_type.go create mode 100644 internal/app/common/model/sys_config.go create mode 100644 internal/app/common/model/sys_dict_data.go create mode 100644 internal/app/common/model/sys_dict_type.go create mode 100644 internal/app/common/service/internal/dao/internal/sys_config.go create mode 100644 internal/app/common/service/internal/dao/internal/sys_dict_data.go create mode 100644 internal/app/common/service/internal/dao/internal/sys_dict_type.go create mode 100644 internal/app/common/service/internal/dao/sys_config.go create mode 100644 internal/app/common/service/internal/dao/sys_dict_data.go create mode 100644 internal/app/common/service/internal/dao/sys_dict_type.go create mode 100644 internal/app/common/service/internal/do/sys_config.go create mode 100644 internal/app/common/service/internal/do/sys_dict_data.go create mode 100644 internal/app/common/service/internal/do/sys_dict_type.go create mode 100644 internal/app/common/service/sys_config.go create mode 100644 internal/app/common/service/sys_dict_data.go create mode 100644 internal/app/common/service/sys_dict_type.go delete mode 100644 internal/app/system/controller/menu.go create mode 100644 internal/app/system/controller/sys_auth_rule.go create mode 100644 internal/app/system/controller/sys_dict_data.go create mode 100644 internal/app/system/controller/sys_dict_type.go rename internal/app/system/controller/{user.go => sys_user.go} (93%) diff --git a/api/v1/system/sys_auth_rule.go b/api/v1/system/sys_auth_rule.go new file mode 100644 index 0000000..25f3b10 --- /dev/null +++ b/api/v1/system/sys_auth_rule.go @@ -0,0 +1,35 @@ +/* +* @desc:菜单api +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 10:27 + */ + +package system + +import "github.com/gogf/gf/v2/frame/g" + +type RuleAddReq struct { + g.Meta `path:"/menu/add" tags:"menu add" method:"post" summary:"添加菜单"` + Authorization string `p:"Authorization" in:"header" dc:"Bearer {{token}}"` + MenuType uint `p:"menuType" v:"min:0|max:2#菜单类型最小值为:min|菜单类型最大值为:max"` + Pid uint `p:"parentId" v:"min:0"` + Name string `p:"name" v:"required#请填写规则名称"` + Title string `p:"menuName" v:"required|length:1,100#请填写标题|标题长度在:min到:max位"` + Icon string `p:"icon"` + Weigh int `p:"orderNum" ` + Condition string `p:"condition" ` + Remark string `p:"remark" ` + Status uint `p:"status" ` + AlwaysShow uint `p:"visible"` + Path string `p:"path"` + Component string `p:"component" v:"required-if:menuType,1#组件路径不能为空"` + IsLink uint `p:"isLink"` + IsIframe uint `p:"isIframe"` + IsCached uint `p:"isCached"` + ModuleType string `p:"moduleType"` + ModelId uint `p:"modelId"` +} + +type RuleAddRes struct { +} diff --git a/api/v1/system/sys_dict_data.go b/api/v1/system/sys_dict_data.go new file mode 100644 index 0000000..c15faae --- /dev/null +++ b/api/v1/system/sys_dict_data.go @@ -0,0 +1,27 @@ +/* +* @desc:字典数据api +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:59 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonModel "github.com/tiger1103/gfast/v3/internal/app/common/model" +) + +// GetDictReq 获取字典信息请求参数 +type GetDictReq struct { + g.Meta `path:"/dict/data/getDictData" tags:"get dict data" method:"get" summary:"获取字典数据公共方法"` + DictType string `p:"dictType" v:"required#字典类型不能为空"` + DefaultValue string `p:"defaultValue"` +} + +// GetDictRes 完整的一个字典信息 +type GetDictRes struct { + g.Meta `mime:"application/json" example:""` + Info *commonModel.DictTypeRes `json:"info"` + Values []*commonModel.DictDataRes `json:"values"` +} diff --git a/api/v1/system/user.go b/api/v1/system/sys_user.go similarity index 100% rename from api/v1/system/user.go rename to api/v1/system/sys_user.go diff --git a/internal/app/common/consts/cache.go b/internal/app/common/consts/cache.go index ee8dfe2..cb1b3b8 100644 --- a/internal/app/common/consts/cache.go +++ b/internal/app/common/consts/cache.go @@ -10,4 +10,12 @@ package consts const ( CacheModelMem = "memory" CacheModelRedis = "redis" + + // CacheSysDict 字典缓存菜单KEY + CacheSysDict = "sysDict" + + // CacheSysDictTag 字典缓存标签 + CacheSysDictTag = "sysDictTag" + // CacheSysConfigTag 系统参数配置 + CacheSysConfigTag = "sysConfigTag" ) diff --git a/internal/app/common/model/entity/sys_config.go b/internal/app/common/model/entity/sys_config.go new file mode 100644 index 0000000..831f83c --- /dev/null +++ b/internal/app/common/model/entity/sys_config.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysConfig is the golang structure for table sys_config. +type SysConfig struct { + ConfigId uint `json:"configId" description:"参数主键"` + ConfigName string `json:"configName" description:"参数名称"` + ConfigKey string `json:"configKey" description:"参数键名"` + ConfigValue string `json:"configValue" description:"参数键值"` + ConfigType int `json:"configType" description:"系统内置(Y是 N否)"` + CreateBy uint `json:"createBy" description:"创建者"` + UpdateBy uint `json:"updateBy" description:"更新者"` + Remark string `json:"remark" description:"备注"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` +} diff --git a/internal/app/common/model/entity/sys_dict_data.go b/internal/app/common/model/entity/sys_dict_data.go new file mode 100644 index 0000000..9ca7806 --- /dev/null +++ b/internal/app/common/model/entity/sys_dict_data.go @@ -0,0 +1,28 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictData is the golang structure for table sys_dict_data. +type SysDictData struct { + DictCode int64 `json:"dictCode" description:"字典编码"` + DictSort int `json:"dictSort" description:"字典排序"` + DictLabel string `json:"dictLabel" description:"字典标签"` + DictValue string `json:"dictValue" description:"字典键值"` + DictType string `json:"dictType" description:"字典类型"` + CssClass string `json:"cssClass" description:"样式属性(其他样式扩展)"` + ListClass string `json:"listClass" description:"表格回显样式"` + IsDefault int `json:"isDefault" description:"是否默认(1是 0否)"` + Status int `json:"status" description:"状态(0正常 1停用)"` + CreateBy uint64 `json:"createBy" description:"创建者"` + UpdateBy uint64 `json:"updateBy" description:"更新者"` + Remark string `json:"remark" description:"备注"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` +} diff --git a/internal/app/common/model/entity/sys_dict_type.go b/internal/app/common/model/entity/sys_dict_type.go new file mode 100644 index 0000000..9a52692 --- /dev/null +++ b/internal/app/common/model/entity/sys_dict_type.go @@ -0,0 +1,23 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictType is the golang structure for table sys_dict_type. +type SysDictType struct { + DictId uint64 `json:"dictId" description:"字典主键"` + DictName string `json:"dictName" description:"字典名称"` + DictType string `json:"dictType" description:"字典类型"` + Status uint `json:"status" description:"状态(0正常 1停用)"` + CreateBy uint `json:"createBy" description:"创建者"` + UpdateBy uint `json:"updateBy" description:"更新者"` + Remark string `json:"remark" description:"备注"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建日期"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改日期"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除日期"` +} diff --git a/internal/app/common/model/sys_config.go b/internal/app/common/model/sys_config.go new file mode 100644 index 0000000..737fb8f --- /dev/null +++ b/internal/app/common/model/sys_config.go @@ -0,0 +1,8 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:56 + */ + +package model diff --git a/internal/app/common/model/sys_dict_data.go b/internal/app/common/model/sys_dict_data.go new file mode 100644 index 0000000..ce8434c --- /dev/null +++ b/internal/app/common/model/sys_dict_data.go @@ -0,0 +1,21 @@ +/* +* @desc:字典数据 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:56 + */ + +package model + +type DictTypeRes struct { + DictName string `json:"name"` + Remark string `json:"remark"` +} + +// DictDataRes 字典数据 +type DictDataRes struct { + DictValue string `json:"key"` + DictLabel string `json:"value"` + IsDefault int `json:"isDefault"` + Remark string `json:"remark"` +} diff --git a/internal/app/common/model/sys_dict_type.go b/internal/app/common/model/sys_dict_type.go new file mode 100644 index 0000000..737fb8f --- /dev/null +++ b/internal/app/common/model/sys_dict_type.go @@ -0,0 +1,8 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:56 + */ + +package model diff --git a/internal/app/common/service/internal/dao/internal/sys_config.go b/internal/app/common/service/internal/dao/internal/sys_config.go new file mode 100644 index 0000000..c93057b --- /dev/null +++ b/internal/app/common/service/internal/dao/internal/sys_config.go @@ -0,0 +1,92 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysConfigDao is the data access object for table sys_config. +type SysConfigDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns SysConfigColumns // columns contains all the column names of Table for convenient usage. +} + +// SysConfigColumns defines and stores column names for table sys_config. +type SysConfigColumns struct { + ConfigId string // 参数主键 + ConfigName string // 参数名称 + ConfigKey string // 参数键名 + ConfigValue string // 参数键值 + ConfigType string // 系统内置(Y是 N否) + CreateBy string // 创建者 + UpdateBy string // 更新者 + Remark string // 备注 + CreatedAt string // 创建时间 + UpdatedAt string // 修改时间 + DeletedAt string // 删除时间 +} + +// sysConfigColumns holds the columns for table sys_config. +var sysConfigColumns = SysConfigColumns{ + ConfigId: "config_id", + ConfigName: "config_name", + ConfigKey: "config_key", + ConfigValue: "config_value", + ConfigType: "config_type", + CreateBy: "create_by", + UpdateBy: "update_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewSysConfigDao creates and returns a new DAO object for table data access. +func NewSysConfigDao() *SysConfigDao { + return &SysConfigDao{ + group: "default", + table: "sys_config", + columns: sysConfigColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysConfigDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysConfigDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysConfigDao) Columns() SysConfigColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysConfigDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysConfigDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *SysConfigDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/app/common/service/internal/dao/internal/sys_dict_data.go b/internal/app/common/service/internal/dao/internal/sys_dict_data.go new file mode 100644 index 0000000..6b50b91 --- /dev/null +++ b/internal/app/common/service/internal/dao/internal/sys_dict_data.go @@ -0,0 +1,100 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysDictDataDao is the data access object for table sys_dict_data. +type SysDictDataDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns SysDictDataColumns // columns contains all the column names of Table for convenient usage. +} + +// SysDictDataColumns defines and stores column names for table sys_dict_data. +type SysDictDataColumns struct { + DictCode string // 字典编码 + DictSort string // 字典排序 + DictLabel string // 字典标签 + DictValue string // 字典键值 + DictType string // 字典类型 + CssClass string // 样式属性(其他样式扩展) + ListClass string // 表格回显样式 + IsDefault string // 是否默认(1是 0否) + Status string // 状态(0正常 1停用) + CreateBy string // 创建者 + UpdateBy string // 更新者 + Remark string // 备注 + CreatedAt string // 创建时间 + UpdatedAt string // 修改时间 + DeletedAt string // 删除时间 +} + +// sysDictDataColumns holds the columns for table sys_dict_data. +var sysDictDataColumns = SysDictDataColumns{ + DictCode: "dict_code", + DictSort: "dict_sort", + DictLabel: "dict_label", + DictValue: "dict_value", + DictType: "dict_type", + CssClass: "css_class", + ListClass: "list_class", + IsDefault: "is_default", + Status: "status", + CreateBy: "create_by", + UpdateBy: "update_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewSysDictDataDao creates and returns a new DAO object for table data access. +func NewSysDictDataDao() *SysDictDataDao { + return &SysDictDataDao{ + group: "default", + table: "sys_dict_data", + columns: sysDictDataColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysDictDataDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysDictDataDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysDictDataDao) Columns() SysDictDataColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysDictDataDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysDictDataDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *SysDictDataDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/app/common/service/internal/dao/internal/sys_dict_type.go b/internal/app/common/service/internal/dao/internal/sys_dict_type.go new file mode 100644 index 0000000..4af2fc2 --- /dev/null +++ b/internal/app/common/service/internal/dao/internal/sys_dict_type.go @@ -0,0 +1,90 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysDictTypeDao is the data access object for table sys_dict_type. +type SysDictTypeDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns SysDictTypeColumns // columns contains all the column names of Table for convenient usage. +} + +// SysDictTypeColumns defines and stores column names for table sys_dict_type. +type SysDictTypeColumns struct { + DictId string // 字典主键 + DictName string // 字典名称 + DictType string // 字典类型 + Status string // 状态(0正常 1停用) + CreateBy string // 创建者 + UpdateBy string // 更新者 + Remark string // 备注 + CreatedAt string // 创建日期 + UpdatedAt string // 修改日期 + DeletedAt string // 删除日期 +} + +// sysDictTypeColumns holds the columns for table sys_dict_type. +var sysDictTypeColumns = SysDictTypeColumns{ + DictId: "dict_id", + DictName: "dict_name", + DictType: "dict_type", + Status: "status", + CreateBy: "create_by", + UpdateBy: "update_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewSysDictTypeDao creates and returns a new DAO object for table data access. +func NewSysDictTypeDao() *SysDictTypeDao { + return &SysDictTypeDao{ + group: "default", + table: "sys_dict_type", + columns: sysDictTypeColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysDictTypeDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysDictTypeDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysDictTypeDao) Columns() SysDictTypeColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysDictTypeDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysDictTypeDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *SysDictTypeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/app/common/service/internal/dao/sys_config.go b/internal/app/common/service/internal/dao/sys_config.go new file mode 100644 index 0000000..375a3c6 --- /dev/null +++ b/internal/app/common/service/internal/dao/sys_config.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/service/internal/dao/internal" +) + +// sysConfigDao is the data access object for table sys_config. +// You can define custom methods on it to extend its functionality as you wish. +type sysConfigDao struct { + *internal.SysConfigDao +} + +var ( + // SysConfig is globally public accessible object for table sys_config operations. + SysConfig = sysConfigDao{ + internal.NewSysConfigDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/service/internal/dao/sys_dict_data.go b/internal/app/common/service/internal/dao/sys_dict_data.go new file mode 100644 index 0000000..fa7fc03 --- /dev/null +++ b/internal/app/common/service/internal/dao/sys_dict_data.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/service/internal/dao/internal" +) + +// sysDictDataDao is the data access object for table sys_dict_data. +// You can define custom methods on it to extend its functionality as you wish. +type sysDictDataDao struct { + *internal.SysDictDataDao +} + +var ( + // SysDictData is globally public accessible object for table sys_dict_data operations. + SysDictData = sysDictDataDao{ + internal.NewSysDictDataDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/service/internal/dao/sys_dict_type.go b/internal/app/common/service/internal/dao/sys_dict_type.go new file mode 100644 index 0000000..3c16af1 --- /dev/null +++ b/internal/app/common/service/internal/dao/sys_dict_type.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/service/internal/dao/internal" +) + +// sysDictTypeDao is the data access object for table sys_dict_type. +// You can define custom methods on it to extend its functionality as you wish. +type sysDictTypeDao struct { + *internal.SysDictTypeDao +} + +var ( + // SysDictType is globally public accessible object for table sys_dict_type operations. + SysDictType = sysDictTypeDao{ + internal.NewSysDictTypeDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/service/internal/do/sys_config.go b/internal/app/common/service/internal/do/sys_config.go new file mode 100644 index 0000000..84fa651 --- /dev/null +++ b/internal/app/common/service/internal/do/sys_config.go @@ -0,0 +1,26 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysConfig is the golang structure of table sys_config for DAO operations like Where/Data. +type SysConfig struct { + g.Meta `orm:"table:sys_config, do:true"` + ConfigId interface{} // 参数主键 + ConfigName interface{} // 参数名称 + ConfigKey interface{} // 参数键名 + ConfigValue interface{} // 参数键值 + ConfigType interface{} // 系统内置(Y是 N否) + CreateBy interface{} // 创建者 + UpdateBy interface{} // 更新者 + Remark interface{} // 备注 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 修改时间 + DeletedAt *gtime.Time // 删除时间 +} diff --git a/internal/app/common/service/internal/do/sys_dict_data.go b/internal/app/common/service/internal/do/sys_dict_data.go new file mode 100644 index 0000000..1d8528d --- /dev/null +++ b/internal/app/common/service/internal/do/sys_dict_data.go @@ -0,0 +1,30 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictData is the golang structure of table sys_dict_data for DAO operations like Where/Data. +type SysDictData struct { + g.Meta `orm:"table:sys_dict_data, do:true"` + DictCode interface{} // 字典编码 + DictSort interface{} // 字典排序 + DictLabel interface{} // 字典标签 + DictValue interface{} // 字典键值 + DictType interface{} // 字典类型 + CssClass interface{} // 样式属性(其他样式扩展) + ListClass interface{} // 表格回显样式 + IsDefault interface{} // 是否默认(1是 0否) + Status interface{} // 状态(0正常 1停用) + CreateBy interface{} // 创建者 + UpdateBy interface{} // 更新者 + Remark interface{} // 备注 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 修改时间 + DeletedAt *gtime.Time // 删除时间 +} diff --git a/internal/app/common/service/internal/do/sys_dict_type.go b/internal/app/common/service/internal/do/sys_dict_type.go new file mode 100644 index 0000000..58500d4 --- /dev/null +++ b/internal/app/common/service/internal/do/sys_dict_type.go @@ -0,0 +1,25 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictType is the golang structure of table sys_dict_type for DAO operations like Where/Data. +type SysDictType struct { + g.Meta `orm:"table:sys_dict_type, do:true"` + DictId interface{} // 字典主键 + DictName interface{} // 字典名称 + DictType interface{} // 字典类型 + Status interface{} // 状态(0正常 1停用) + CreateBy interface{} // 创建者 + UpdateBy interface{} // 更新者 + Remark interface{} // 备注 + CreatedAt *gtime.Time // 创建日期 + UpdatedAt *gtime.Time // 修改日期 + DeletedAt *gtime.Time // 删除日期 +} diff --git a/internal/app/common/service/sys_config.go b/internal/app/common/service/sys_config.go new file mode 100644 index 0000000..6bf2701 --- /dev/null +++ b/internal/app/common/service/sys_config.go @@ -0,0 +1,8 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:55 + */ + +package service diff --git a/internal/app/common/service/sys_dict_data.go b/internal/app/common/service/sys_dict_data.go new file mode 100644 index 0000000..7ad6d7f --- /dev/null +++ b/internal/app/common/service/sys_dict_data.go @@ -0,0 +1,76 @@ +/* +* @desc:字典数据 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:55 + */ + +package service + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonConsts "github.com/tiger1103/gfast/v3/internal/app/common/consts" + commonModel "github.com/tiger1103/gfast/v3/internal/app/common/model" + commonDao "github.com/tiger1103/gfast/v3/internal/app/common/service/internal/dao" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +type IDictData interface { + GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes, err error) +} + +type dictDataImpl struct { +} + +var dictData = dictDataImpl{} + +func DictData() IDictData { + return IDictData(&dictData) +} + +// GetDictWithDataByType 通过字典键类型获取选项 +func (s dictDataImpl) GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes, + err error) { + cache := Cache(ctx) + cacheKey := commonConsts.CacheSysDict + "_" + req.DictType + //从缓存获取 + iDict := cache.GetOrSetFuncLock(ctx, cacheKey, func(ctx context.Context) (value interface{}, err error) { + err = g.Try(func() { + //从数据库获取 + dict = &system.GetDictRes{} + //获取类型数据 + err = commonDao.SysDictType.Ctx(ctx).Where(commonDao.SysDictType.Columns().DictType, req.DictType). + Where(commonDao.SysDictType.Columns().Status, 1).Fields(commonModel.DictTypeRes{}).Scan(&dict.Info) + liberr.ErrIsNil(ctx, err, "获取字典类型失败") + err = commonDao.SysDictData.Ctx(ctx).Fields(commonModel.DictDataRes{}). + Where(commonDao.SysDictData.Columns().DictType, req.DictType). + Order(commonDao.SysDictData.Columns().DictSort + " asc," + + commonDao.SysDictData.Columns().DictCode + " asc"). + Scan(&dict.Values) + liberr.ErrIsNil(ctx, err, "获取字典数据失败") + }) + value = dict + return + }, 0, commonConsts.CacheSysDictTag) + if iDict != nil { + err = gconv.Struct(iDict, &dict) + if err != nil { + return + } + } + //设置给定的默认值 + for _, v := range dict.Values { + if req.DefaultValue != "" { + if gstr.Equal(req.DefaultValue, v.DictValue) { + v.IsDefault = 1 + } else { + v.IsDefault = 0 + } + } + } + return +} diff --git a/internal/app/common/service/sys_dict_type.go b/internal/app/common/service/sys_dict_type.go new file mode 100644 index 0000000..6bf2701 --- /dev/null +++ b/internal/app/common/service/sys_dict_type.go @@ -0,0 +1,8 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:55 + */ + +package service diff --git a/internal/app/system/consts/cache.go b/internal/app/system/consts/cache.go index d95845d..3cf9764 100644 --- a/internal/app/system/consts/cache.go +++ b/internal/app/system/consts/cache.go @@ -10,8 +10,7 @@ package consts const ( // CacheSysAuthMenu 缓存菜单KEY CacheSysAuthMenu = "sysAuthMenu" - // CacheSysDict 字典缓存菜单KEY - CacheSysDict = "sysDict" + // CacheSysRole 角色缓存key CacheSysRole = "sysRole" // CacheSysWebSet 站点配置缓存key @@ -21,10 +20,6 @@ const ( // CacheSysAuthTag 权限缓存TAG标签 CacheSysAuthTag = "sysAuthTag" - // CacheSysDictTag 字典缓存标签 - CacheSysDictTag = "sysDictTag" - // CacheSysConfigTag 系统参数配置 - CacheSysConfigTag = "sysConfigTag" // CacheSysModelTag 模型缓存标签 CacheSysModelTag = "sysModelTag" // CacheSysCmsTag cms缓存标签 diff --git a/internal/app/system/controller/base.go b/internal/app/system/controller/base.go index e4dbd38..5dae69a 100644 --- a/internal/app/system/controller/base.go +++ b/internal/app/system/controller/base.go @@ -12,11 +12,11 @@ import ( commonController "github.com/tiger1103/gfast/v3/internal/app/common/controller" ) -type baseController struct { +type BaseController struct { commonController.BaseController } // Init 自动执行的初始化方法 -func (c *baseController) Init(r *ghttp.Request) { +func (c *BaseController) Init(r *ghttp.Request) { c.BaseController.Init(r) } diff --git a/internal/app/system/controller/menu.go b/internal/app/system/controller/menu.go deleted file mode 100644 index 11ae099..0000000 --- a/internal/app/system/controller/menu.go +++ /dev/null @@ -1,8 +0,0 @@ -/* -* @desc:菜单 -* @company:云南奇讯科技有限公司 -* @Author: yixiaohu -* @Date: 2022/3/16 10:36 - */ - -package controller diff --git a/internal/app/system/controller/sys_auth_rule.go b/internal/app/system/controller/sys_auth_rule.go new file mode 100644 index 0000000..e36eb4e --- /dev/null +++ b/internal/app/system/controller/sys_auth_rule.go @@ -0,0 +1,24 @@ +/* +* @desc:菜单 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/16 10:36 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Menu = menuController{} + +type menuController struct { +} + +func (c *menuController) Add(ctx context.Context, req *system.RuleAddReq) (res *system.RuleAddRes, err error) { + err = service.Rule().Add(ctx, req) + return +} diff --git a/internal/app/system/controller/sys_dict_data.go b/internal/app/system/controller/sys_dict_data.go new file mode 100644 index 0000000..cd8b596 --- /dev/null +++ b/internal/app/system/controller/sys_dict_data.go @@ -0,0 +1,25 @@ +/* +* @desc:字典数据管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:57 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +var DictData = dictDataController{} + +type dictDataController struct { +} + +// GetDictData 获取字典数据 +func (c *dictDataController) GetDictData(ctx context.Context, req *system.GetDictReq) (res *system.GetDictRes, err error) { + res, err = commonService.DictData().GetDictWithDataByType(ctx, req) + return +} diff --git a/internal/app/system/controller/sys_dict_type.go b/internal/app/system/controller/sys_dict_type.go new file mode 100644 index 0000000..c55d213 --- /dev/null +++ b/internal/app/system/controller/sys_dict_type.go @@ -0,0 +1,8 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:57 + */ + +package controller diff --git a/internal/app/system/controller/user.go b/internal/app/system/controller/sys_user.go similarity index 93% rename from internal/app/system/controller/user.go rename to internal/app/system/controller/sys_user.go index 38eefec..5256ecc 100644 --- a/internal/app/system/controller/user.go +++ b/internal/app/system/controller/sys_user.go @@ -15,14 +15,14 @@ import ( ) var ( - User = UserController{} + User = userController{} ) -type UserController struct { - baseController +type userController struct { + BaseController } -func (c *UserController) Login(ctx context.Context, req *system.UserLoginReq) (res *system.UserLoginRes, err error) { +func (c *userController) Login(ctx context.Context, req *system.UserLoginReq) (res *system.UserLoginRes, err error) { var ( user *model.LoginUserRes token string @@ -89,7 +89,7 @@ func (c *UserController) Login(ctx context.Context, req *system.UserLoginReq) (r } // GetUserMenus 获取用户菜单及按钮权限 -func (c *UserController) GetUserMenus(ctx context.Context, req *system.UserMenusReq) (res *system.UserMenusRes, err error) { +func (c *userController) GetUserMenus(ctx context.Context, req *system.UserMenusReq) (res *system.UserMenusRes, err error) { var ( permissions []string menuList []*model.UserMenus diff --git a/internal/app/system/model/entity/sys_auth_rule.go b/internal/app/system/model/entity/sys_auth_rule.go index c8930eb..e9a0e56 100644 --- a/internal/app/system/model/entity/sys_auth_rule.go +++ b/internal/app/system/model/entity/sys_auth_rule.go @@ -1,5 +1,5 @@ // ================================================================================= -// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38 +// Code generated by GoFrame CLI tool. DO NOT EDIT. // ================================================================================= package entity @@ -24,9 +24,11 @@ type SysAuthRule struct { Path string `json:"path" description:"路由地址"` JumpPath string `json:"jumpPath" description:"跳转路由"` Component string `json:"component" description:"组件路径"` - IsFrame uint `json:"isFrame" description:"是否外链 1是 0否"` + IsLink uint `json:"isLink" description:"是否外链 1是 0否"` ModuleType string `json:"moduleType" description:"所属模块"` ModelId uint `json:"modelId" description:"模型ID"` + IsIframe uint `json:"isIframe" description:"是否内嵌iframe"` + IsCached uint `json:"isCached" description:"是否缓存"` CreatedAt *gtime.Time `json:"createdAt" description:"创建日期"` UpdatedAt *gtime.Time `json:"updatedAt" description:"修改日期"` } diff --git a/internal/app/system/router/router.go b/internal/app/system/router/router.go index e32c4b6..1385c86 100644 --- a/internal/app/system/router/router.go +++ b/internal/app/system/router/router.go @@ -24,6 +24,8 @@ func BindController(group *ghttp.RouterGroup) { group.Middleware(service.Middleware().Ctx, service.Middleware().Auth) group.Bind( controller.User, + controller.Menu, + controller.DictData, ) }) } diff --git a/internal/app/system/service/internal/dao/internal/sys_auth_rule.go b/internal/app/system/service/internal/dao/internal/sys_auth_rule.go index 03327e1..4923c6b 100644 --- a/internal/app/system/service/internal/dao/internal/sys_auth_rule.go +++ b/internal/app/system/service/internal/dao/internal/sys_auth_rule.go @@ -1,5 +1,5 @@ // ========================================================================== -// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38 +// Code generated by GoFrame CLI tool. DO NOT EDIT. // ========================================================================== package internal @@ -33,9 +33,11 @@ type SysAuthRuleColumns struct { Path string // 路由地址 JumpPath string // 跳转路由 Component string // 组件路径 - IsFrame string // 是否外链 1是 0否 + IsLink string // 是否外链 1是 0否 ModuleType string // 所属模块 ModelId string // 模型ID + IsIframe string // 是否内嵌iframe + IsCached string // 是否缓存 CreatedAt string // 创建日期 UpdatedAt string // 修改日期 } @@ -56,9 +58,11 @@ var sysAuthRuleColumns = SysAuthRuleColumns{ Path: "path", JumpPath: "jump_path", Component: "component", - IsFrame: "is_frame", + IsLink: "is_link", ModuleType: "module_type", ModelId: "model_id", + IsIframe: "is_iframe", + IsCached: "is_cached", CreatedAt: "created_at", UpdatedAt: "updated_at", } diff --git a/internal/app/system/service/internal/do/sys_auth_rule.go b/internal/app/system/service/internal/do/sys_auth_rule.go index 1f6618f..b509bfd 100644 --- a/internal/app/system/service/internal/do/sys_auth_rule.go +++ b/internal/app/system/service/internal/do/sys_auth_rule.go @@ -1,5 +1,5 @@ // ================================================================================= -// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38 +// Code generated by GoFrame CLI tool. DO NOT EDIT. // ================================================================================= package do @@ -26,9 +26,11 @@ type SysAuthRule struct { Path interface{} // 路由地址 JumpPath interface{} // 跳转路由 Component interface{} // 组件路径 - IsFrame interface{} // 是否外链 1是 0否 + IsLink interface{} // 是否外链 1是 0否 ModuleType interface{} // 所属模块 ModelId interface{} // 模型ID + IsIframe interface{} // 是否内嵌iframe + IsCached interface{} // 是否缓存 CreatedAt *gtime.Time // 创建日期 UpdatedAt *gtime.Time // 修改日期 } diff --git a/internal/app/system/service/sys_auth_rule.go b/internal/app/system/service/sys_auth_rule.go index 0c89b86..ebe6772 100644 --- a/internal/app/system/service/sys_auth_rule.go +++ b/internal/app/system/service/sys_auth_rule.go @@ -11,6 +11,7 @@ import ( "context" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" "github.com/tiger1103/gfast/v3/internal/app/common/service" "github.com/tiger1103/gfast/v3/internal/app/system/consts" "github.com/tiger1103/gfast/v3/internal/app/system/model" @@ -22,6 +23,7 @@ type IRule interface { GetIsMenuStatusList(ctx context.Context) ([]*model.SysAuthRuleInfoRes, error) GetMenuList(ctx context.Context) (list []*model.SysAuthRuleInfoRes, err error) GetIsButtonStatusList(ctx context.Context) ([]*model.SysAuthRuleInfoRes, error) + Add(ctx context.Context, req *system.RuleAddReq) (err error) } type ruleImpl struct { @@ -86,3 +88,12 @@ func (s *ruleImpl) GetIsButtonStatusList(ctx context.Context) ([]*model.SysAuthR } return gList, nil } + +// Add 添加菜单 +func (s *ruleImpl) Add(ctx context.Context, req *system.RuleAddReq) (err error) { + err = g.Try(func() { + _, err = dao.SysAuthRule.Ctx(ctx).Insert(req) + liberr.ErrIsNil(ctx, err, "添加菜单失败") + }) + return +} diff --git a/manifest/config/config.yaml b/manifest/config/config.yaml index e18e862..c56ff64 100644 --- a/manifest/config/config.yaml +++ b/manifest/config/config.yaml @@ -76,7 +76,7 @@ gfcli: gen: dao: - link: "mysql:root:123456@tcp(127.0.0.1:3306)/gfast-v3" - tables: "casbin_rule" + tables: "sys_dict_type,sys_dict_data,sys_config" removePrefix: "gf_" descriptionTag: true noModelComment: true