Quellcode durchsuchen

缓存bug修复

yxh vor 4 Jahren
Ursprung
Commit
8deac7238e

+ 0 - 0
apiv1/common/captcha.go → api/v1/common/captcha.go


+ 0 - 0
apiv1/demo/demo.go → api/v1/demo/demo.go


+ 0 - 0
apiv1/system/user.go → api/v1/system/user.go


+ 2 - 1
go.mod

@@ -3,8 +3,9 @@ module github.com/tiger1103/gfast/v3
 go 1.15
 go 1.15
 
 
 require (
 require (
-	github.com/gogf/gf/v2 v2.0.0-rc3
+	github.com/gogf/gf/v2 v2.0.3
 	github.com/mojocn/base64Captcha v1.3.5
 	github.com/mojocn/base64Captcha v1.3.5
 	github.com/mssola/user_agent v0.5.3
 	github.com/mssola/user_agent v0.5.3
+	github.com/tiger1103/gfast-cache v0.0.3 // indirect
 	github.com/tiger1103/gfast-token v0.0.4
 	github.com/tiger1103/gfast-token v0.0.4
 )
 )

+ 9 - 2
go.sum

@@ -20,8 +20,13 @@ github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Px
 github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
 github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
 github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
 github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
+github.com/gogf/gf/v2 v2.0.0-rc.0.20220117131058-9345eb5e946f/go.mod h1:apktt6TleWtCIwpz63vBqUnw8MX8gWKoZyxgDpXFtgM=
 github.com/gogf/gf/v2 v2.0.0-rc3 h1:FkmLFhgOCZnyr24H/Yj9V1psS7fJ79DtPuSz+l/kwsc=
 github.com/gogf/gf/v2 v2.0.0-rc3 h1:FkmLFhgOCZnyr24H/Yj9V1psS7fJ79DtPuSz+l/kwsc=
 github.com/gogf/gf/v2 v2.0.0-rc3/go.mod h1:apktt6TleWtCIwpz63vBqUnw8MX8gWKoZyxgDpXFtgM=
 github.com/gogf/gf/v2 v2.0.0-rc3/go.mod h1:apktt6TleWtCIwpz63vBqUnw8MX8gWKoZyxgDpXFtgM=
+github.com/gogf/gf/v2 v2.0.2 h1:XB8QavORTCYDV0Ko7m/LmXm3leWjcqyL6Ql2pcRNZmw=
+github.com/gogf/gf/v2 v2.0.2/go.mod h1:apktt6TleWtCIwpz63vBqUnw8MX8gWKoZyxgDpXFtgM=
+github.com/gogf/gf/v2 v2.0.3 h1:T/PSaaE+N/czwC3/fYGv6bvbJZsK6Em2DsNNLbyqQ4w=
+github.com/gogf/gf/v2 v2.0.3/go.mod h1:apktt6TleWtCIwpz63vBqUnw8MX8gWKoZyxgDpXFtgM=
 github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
 github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
 github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
 github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
@@ -77,8 +82,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/tiger1103/gfast-token v0.0.3 h1:uXZMeNXSb5j/GNLHAgkhwzhG/1M3eL3Ho0RNfl5LUpw=
-github.com/tiger1103/gfast-token v0.0.3/go.mod h1:RnVRqmWD3h4qfTU1vJNXNhQjh2L5ht1vxLnjwShwGuY=
+github.com/tiger1103/gfast-cache v0.0.2 h1:MLQrFooBRV5IvSoHyChB3Wcarhfsxo4oGa95ZB9vLmM=
+github.com/tiger1103/gfast-cache v0.0.2/go.mod h1:s6cRWyr87wz6IJNGKRV6Ahq9hcuVz8h2PAtGrO66JO8=
+github.com/tiger1103/gfast-cache v0.0.3 h1:8iK1dNib35pDdGherjSoPKWiKV0fyQHi03DDfcltsnA=
+github.com/tiger1103/gfast-cache v0.0.3/go.mod h1:s6cRWyr87wz6IJNGKRV6Ahq9hcuVz8h2PAtGrO66JO8=
 github.com/tiger1103/gfast-token v0.0.4 h1:h59pbFd/VyORNunsDdzIdqJkZIHYHsYCzdmPbcqGkZs=
 github.com/tiger1103/gfast-token v0.0.4 h1:h59pbFd/VyORNunsDdzIdqJkZIHYHsYCzdmPbcqGkZs=
 github.com/tiger1103/gfast-token v0.0.4/go.mod h1:RnVRqmWD3h4qfTU1vJNXNhQjh2L5ht1vxLnjwShwGuY=
 github.com/tiger1103/gfast-token v0.0.4/go.mod h1:RnVRqmWD3h4qfTU1vJNXNhQjh2L5ht1vxLnjwShwGuY=
 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

+ 13 - 0
internal/app/common/consts/cache.go

@@ -0,0 +1,13 @@
+/*
+* @desc:缓存相关
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/3/9 11:25
+ */
+
+package consts
+
+const (
+	CacheModelMem   = "memory"
+	CacheModelRedis = "redis"
+)

+ 1 - 1
internal/app/common/controller/captcah.go

@@ -9,7 +9,7 @@ package controller
 
 
 import (
 import (
 	"context"
 	"context"
-	"github.com/tiger1103/gfast/v3/apiv1/common"
+	"github.com/tiger1103/gfast/v3/api/v1/common"
 	"github.com/tiger1103/gfast/v3/internal/app/common/service"
 	"github.com/tiger1103/gfast/v3/internal/app/common/service"
 )
 )
 
 

+ 0 - 5
internal/app/common/model/token.go

@@ -11,11 +11,6 @@ import (
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/frame/g"
 )
 )
 
 
-const (
-	CacheModelMem   = "memory"
-	CacheModelRedis = "redis"
-)
-
 type TokenOptions struct {
 type TokenOptions struct {
 	//  server name
 	//  server name
 	ServerName string `json:"serverName"`
 	ServerName string `json:"serverName"`

+ 39 - 0
internal/app/common/service/cache.go

@@ -0,0 +1,39 @@
+/*
+* @desc:缓存处理
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/3/9 11:15
+ */
+
+package service
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/tiger1103/gfast-cache/cache"
+	"github.com/tiger1103/gfast/v3/internal/app/common/consts"
+)
+
+type ICache interface {
+	cache.IGCache
+}
+
+type cacheImpl struct {
+	*cache.GfCache
+	prefix string
+}
+
+var c = cacheImpl{}
+
+func Cache(ctx context.Context) ICache {
+	ch := c
+	prefix := g.Cfg().MustGet(ctx, "system.cache.prefix").String()
+	model := g.Cfg().MustGet(ctx, "system.cache.model").String()
+	if model == consts.CacheModelRedis {
+		// redis
+		ch.GfCache = cache.NewRedis(prefix)
+	} else {
+		ch.GfCache = cache.New(prefix)
+	}
+	return ICache(&ch)
+}

+ 2 - 1
internal/app/common/service/token.go

@@ -11,6 +11,7 @@ import (
 	"context"
 	"context"
 	"github.com/gogf/gf/v2/net/ghttp"
 	"github.com/gogf/gf/v2/net/ghttp"
 	"github.com/tiger1103/gfast-token/gftoken"
 	"github.com/tiger1103/gfast-token/gftoken"
+	"github.com/tiger1103/gfast/v3/internal/app/common/consts"
 	"github.com/tiger1103/gfast/v3/internal/app/common/model"
 	"github.com/tiger1103/gfast/v3/internal/app/common/model"
 )
 )
 
 
@@ -30,7 +31,7 @@ var gT = gfTokenImpl{
 
 
 func GfToken(options *model.TokenOptions) IGfToken {
 func GfToken(options *model.TokenOptions) IGfToken {
 	var fun gftoken.OptionFunc
 	var fun gftoken.OptionFunc
-	if options.CacheModel == model.CacheModelRedis {
+	if options.CacheModel == consts.CacheModelRedis {
 		fun = gftoken.WithGRedis()
 		fun = gftoken.WithGRedis()
 	} else {
 	} else {
 		fun = gftoken.WithGCache()
 		fun = gftoken.WithGCache()

+ 1 - 1
internal/app/demo/controller/demo.go

@@ -9,7 +9,7 @@ package controller
 
 
 import (
 import (
 	"context"
 	"context"
-	"github.com/tiger1103/gfast/v3/apiv1/demo"
+	"github.com/tiger1103/gfast/v3/api/v1/demo"
 )
 )
 
 
 var Demo = cDemo{}
 var Demo = cDemo{}

+ 32 - 0
internal/app/system/consts/cache.go

@@ -0,0 +1,32 @@
+/*
+* @desc:缓存键
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/3/9 12:06
+ */
+
+package consts
+
+const (
+	// SysAuthMenu 缓存菜单KEY
+	SysAuthMenu = "sysAuthMenu"
+	// SysDict 字典缓存菜单KEY
+	SysDict = "sysDict"
+	// SysRole 角色缓存key
+	SysRole = "sysRole"
+	// SysWebSet 站点配置缓存key
+	SysWebSet = "sysWebSet"
+	// SysCmsMenu cms缓存key
+	SysCmsMenu = "sysCmsMenu"
+
+	// SysAuthTag 权限缓存TAG标签
+	SysAuthTag = "sysAuthTag"
+	// SysDictTag 字典缓存标签
+	SysDictTag = "sysDictTag"
+	// SysConfigTag 系统参数配置
+	SysConfigTag = "sysConfigTag"
+	// SysModelTag 模型缓存标签
+	SysModelTag = "sysModelTag"
+	// SysCmsTag cms缓存标签
+	SysCmsTag = "sysCmsTag"
+)

+ 7 - 1
internal/app/system/controller/user.go

@@ -7,7 +7,7 @@ import (
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/os/genv"
 	"github.com/gogf/gf/v2/os/genv"
 	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/gogf/gf/v2/util/gconv"
-	"github.com/tiger1103/gfast/v3/apiv1/system"
+	"github.com/tiger1103/gfast/v3/api/v1/system"
 	commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
 	commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
 	"github.com/tiger1103/gfast/v3/internal/app/system/model"
 	"github.com/tiger1103/gfast/v3/internal/app/system/model"
 	"github.com/tiger1103/gfast/v3/internal/app/system/service"
 	"github.com/tiger1103/gfast/v3/internal/app/system/service"
@@ -71,6 +71,12 @@ func (c *UserController) Login(ctx context.Context, req *system.UserLoginReq) (r
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}
+	//获取用户菜单数据
+	roleList, err := service.Role().GetRoleList(ctx)
+	if err != nil {
+		return
+	}
+	g.Log().Debug(ctx, roleList)
 	res = &system.UserLoginRes{
 	res = &system.UserLoginRes{
 		UserInfo: user,
 		UserInfo: user,
 		Token:    token,
 		Token:    token,

+ 32 - 0
internal/app/system/model/entity/sys_auth_rule.go

@@ -0,0 +1,32 @@
+// =================================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38
+// =================================================================================
+
+package entity
+
+import (
+	"github.com/gogf/gf/v2/os/gtime"
+)
+
+// SysAuthRule is the golang structure for table sys_auth_rule.
+type SysAuthRule struct {
+	Id         uint        `json:"id"         description:""`
+	Pid        uint        `json:"pid"        description:"父ID"`
+	Name       string      `json:"name"       description:"规则名称"`
+	Title      string      `json:"title"      description:"规则名称"`
+	Icon       string      `json:"icon"       description:"图标"`
+	Condition  string      `json:"condition"  description:"条件"`
+	Remark     string      `json:"remark"     description:"备注"`
+	MenuType   uint        `json:"menuType"   description:"类型 0目录 1菜单 2按钮"`
+	Weigh      int         `json:"weigh"      description:"权重"`
+	Status     uint        `json:"status"     description:"状态"`
+	AlwaysShow uint        `json:"alwaysShow" description:"显示状态"`
+	Path       string      `json:"path"       description:"路由地址"`
+	JumpPath   string      `json:"jumpPath"   description:"跳转路由"`
+	Component  string      `json:"component"  description:"组件路径"`
+	IsFrame    uint        `json:"isFrame"    description:"是否外链 1是 0否"`
+	ModuleType string      `json:"moduleType" description:"所属模块"`
+	ModelId    uint        `json:"modelId"    description:"模型ID"`
+	CreatedAt  *gtime.Time `json:"createdAt"  description:"创建日期"`
+	UpdatedAt  *gtime.Time `json:"updatedAt"  description:"修改日期"`
+}

+ 15 - 0
internal/app/system/model/entity/sys_role.go

@@ -0,0 +1,15 @@
+// =================================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38
+// =================================================================================
+
+package entity
+
+// SysRole is the golang structure for table sys_role.
+type SysRole struct {
+	Id        uint    `json:"id"        description:""`
+	Status    uint    `json:"status"    description:"状态;0:禁用;1:正常"`
+	ListOrder float64 `json:"listOrder" description:"排序"`
+	Name      string  `json:"name"      description:"角色名称"`
+	Remark    string  `json:"remark"    description:"备注"`
+	DataScope uint    `json:"dataScope" description:"数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)"`
+}

+ 108 - 0
internal/app/system/service/internal/dao/internal/sys_auth_rule.go

@@ -0,0 +1,108 @@
+// ==========================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/database/gdb"
+	"github.com/gogf/gf/v2/frame/g"
+)
+
+// SysAuthRuleDao is the data access object for table sys_auth_rule.
+type SysAuthRuleDao 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 SysAuthRuleColumns // columns contains all the column names of Table for convenient usage.
+}
+
+// SysAuthRuleColumns defines and stores column names for table sys_auth_rule.
+type SysAuthRuleColumns struct {
+	Id         string //
+	Pid        string // 父ID
+	Name       string // 规则名称
+	Title      string // 规则名称
+	Icon       string // 图标
+	Condition  string // 条件
+	Remark     string // 备注
+	MenuType   string // 类型 0目录 1菜单 2按钮
+	Weigh      string // 权重
+	Status     string // 状态
+	AlwaysShow string // 显示状态
+	Path       string // 路由地址
+	JumpPath   string // 跳转路由
+	Component  string // 组件路径
+	IsFrame    string // 是否外链 1是 0否
+	ModuleType string // 所属模块
+	ModelId    string // 模型ID
+	CreatedAt  string // 创建日期
+	UpdatedAt  string // 修改日期
+}
+
+//  sysAuthRuleColumns holds the columns for table sys_auth_rule.
+var sysAuthRuleColumns = SysAuthRuleColumns{
+	Id:         "id",
+	Pid:        "pid",
+	Name:       "name",
+	Title:      "title",
+	Icon:       "icon",
+	Condition:  "condition",
+	Remark:     "remark",
+	MenuType:   "menu_type",
+	Weigh:      "weigh",
+	Status:     "status",
+	AlwaysShow: "always_show",
+	Path:       "path",
+	JumpPath:   "jump_path",
+	Component:  "component",
+	IsFrame:    "is_frame",
+	ModuleType: "module_type",
+	ModelId:    "model_id",
+	CreatedAt:  "created_at",
+	UpdatedAt:  "updated_at",
+}
+
+// NewSysAuthRuleDao creates and returns a new DAO object for table data access.
+func NewSysAuthRuleDao() *SysAuthRuleDao {
+	return &SysAuthRuleDao{
+		group:   "default",
+		table:   "sys_auth_rule",
+		columns: sysAuthRuleColumns,
+	}
+}
+
+// DB retrieves and returns the underlying raw database management object of current DAO.
+func (dao *SysAuthRuleDao) DB() gdb.DB {
+	return g.DB(dao.group)
+}
+
+// Table returns the table name of current dao.
+func (dao *SysAuthRuleDao) Table() string {
+	return dao.table
+}
+
+// Columns returns all column names of current dao.
+func (dao *SysAuthRuleDao) Columns() SysAuthRuleColumns {
+	return dao.columns
+}
+
+// Group returns the configuration group name of database of current dao.
+func (dao *SysAuthRuleDao) Group() string {
+	return dao.group
+}
+
+// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
+func (dao *SysAuthRuleDao) 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 *SysAuthRuleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
+	return dao.Ctx(ctx).Transaction(ctx, f)
+}

+ 82 - 0
internal/app/system/service/internal/dao/internal/sys_role.go

@@ -0,0 +1,82 @@
+// ==========================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/database/gdb"
+	"github.com/gogf/gf/v2/frame/g"
+)
+
+// SysRoleDao is the data access object for table sys_role.
+type SysRoleDao 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 SysRoleColumns // columns contains all the column names of Table for convenient usage.
+}
+
+// SysRoleColumns defines and stores column names for table sys_role.
+type SysRoleColumns struct {
+	Id        string //
+	Status    string // 状态;0:禁用;1:正常
+	ListOrder string // 排序
+	Name      string // 角色名称
+	Remark    string // 备注
+	DataScope string // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
+}
+
+//  sysRoleColumns holds the columns for table sys_role.
+var sysRoleColumns = SysRoleColumns{
+	Id:        "id",
+	Status:    "status",
+	ListOrder: "list_order",
+	Name:      "name",
+	Remark:    "remark",
+	DataScope: "data_scope",
+}
+
+// NewSysRoleDao creates and returns a new DAO object for table data access.
+func NewSysRoleDao() *SysRoleDao {
+	return &SysRoleDao{
+		group:   "default",
+		table:   "sys_role",
+		columns: sysRoleColumns,
+	}
+}
+
+// DB retrieves and returns the underlying raw database management object of current DAO.
+func (dao *SysRoleDao) DB() gdb.DB {
+	return g.DB(dao.group)
+}
+
+// Table returns the table name of current dao.
+func (dao *SysRoleDao) Table() string {
+	return dao.table
+}
+
+// Columns returns all column names of current dao.
+func (dao *SysRoleDao) Columns() SysRoleColumns {
+	return dao.columns
+}
+
+// Group returns the configuration group name of database of current dao.
+func (dao *SysRoleDao) Group() string {
+	return dao.group
+}
+
+// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
+func (dao *SysRoleDao) 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 *SysRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
+	return dao.Ctx(ctx).Transaction(ctx, f)
+}

+ 24 - 0
internal/app/system/service/internal/dao/sys_auth_rule.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/system/service/internal/dao/internal"
+)
+
+// sysAuthRuleDao is the data access object for table sys_auth_rule.
+// You can define custom methods on it to extend its functionality as you wish.
+type sysAuthRuleDao struct {
+	*internal.SysAuthRuleDao
+}
+
+var (
+	// SysAuthRule is globally public accessible object for table sys_auth_rule operations.
+	SysAuthRule = sysAuthRuleDao{
+		internal.NewSysAuthRuleDao(),
+	}
+)
+
+// Fill with you ideas below.

+ 24 - 0
internal/app/system/service/internal/dao/sys_role.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/system/service/internal/dao/internal"
+)
+
+// sysRoleDao is the data access object for table sys_role.
+// You can define custom methods on it to extend its functionality as you wish.
+type sysRoleDao struct {
+	*internal.SysRoleDao
+}
+
+var (
+	// SysRole is globally public accessible object for table sys_role operations.
+	SysRole = sysRoleDao{
+		internal.NewSysRoleDao(),
+	}
+)
+
+// Fill with you ideas below.

+ 34 - 0
internal/app/system/service/internal/do/sys_auth_rule.go

@@ -0,0 +1,34 @@
+// =================================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38
+// =================================================================================
+
+package do
+
+import (
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gtime"
+)
+
+// SysAuthRule is the golang structure of table sys_auth_rule for DAO operations like Where/Data.
+type SysAuthRule struct {
+	g.Meta     `orm:"table:sys_auth_rule, do:true"`
+	Id         interface{} //
+	Pid        interface{} // 父ID
+	Name       interface{} // 规则名称
+	Title      interface{} // 规则名称
+	Icon       interface{} // 图标
+	Condition  interface{} // 条件
+	Remark     interface{} // 备注
+	MenuType   interface{} // 类型 0目录 1菜单 2按钮
+	Weigh      interface{} // 权重
+	Status     interface{} // 状态
+	AlwaysShow interface{} // 显示状态
+	Path       interface{} // 路由地址
+	JumpPath   interface{} // 跳转路由
+	Component  interface{} // 组件路径
+	IsFrame    interface{} // 是否外链 1是 0否
+	ModuleType interface{} // 所属模块
+	ModelId    interface{} // 模型ID
+	CreatedAt  *gtime.Time // 创建日期
+	UpdatedAt  *gtime.Time // 修改日期
+}

+ 20 - 0
internal/app/system/service/internal/do/sys_role.go

@@ -0,0 +1,20 @@
+// =================================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-09 10:18:38
+// =================================================================================
+
+package do
+
+import (
+	"github.com/gogf/gf/v2/frame/g"
+)
+
+// SysRole is the golang structure of table sys_role for DAO operations like Where/Data.
+type SysRole struct {
+	g.Meta    `orm:"table:sys_role, do:true"`
+	Id        interface{} //
+	Status    interface{} // 状态;0:禁用;1:正常
+	ListOrder interface{} // 排序
+	Name      interface{} // 角色名称
+	Remark    interface{} // 备注
+	DataScope interface{} // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
+}

+ 55 - 0
internal/app/system/service/sys_role.go

@@ -0,0 +1,55 @@
+/*
+* @desc:角色处理
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/3/9 10:31
+ */
+
+package service
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/errors/gerror"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+	commonService "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/entity"
+	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/dao"
+)
+
+type IRole interface {
+	GetRoleList(ctx context.Context) (list []*entity.SysRole, err error)
+}
+
+type roleImpl struct {
+}
+
+var role = roleImpl{}
+
+func Role() IRole {
+	return IRole(&role)
+}
+
+// GetRoleList 获取角色列表
+func (s *roleImpl) GetRoleList(ctx context.Context) (list []*entity.SysRole, err error) {
+	cache := commonService.Cache(ctx)
+	//从缓存获取
+	iList := cache.GetOrSetFuncLock(ctx, consts.SysRole, func(ctx context.Context) (value interface{}, err error) {
+		var v []*entity.SysRole
+		//从数据库获取
+		err = dao.SysRole.Ctx(ctx).
+			Order(dao.SysRole.Columns().ListOrder + " asc," + dao.SysRole.Columns().Id + " asc").
+			Scan(&v)
+		if err != nil {
+			g.Log().Error(ctx, err)
+			err = gerror.New("获取角色数据失败")
+		}
+		value = v
+		return
+	}, 0, consts.SysAuthTag)
+	if iList != nil {
+		err = gconv.Struct(iList, &list)
+	}
+	return
+}

+ 19 - 9
internal/app/system/service/sys_user.go

@@ -9,11 +9,12 @@ package service
 
 
 import (
 import (
 	"context"
 	"context"
+	"github.com/gogf/gf/v2/container/gset"
 	"github.com/gogf/gf/v2/errors/gerror"
 	"github.com/gogf/gf/v2/errors/gerror"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/os/gtime"
 	"github.com/gogf/gf/v2/os/gtime"
 	"github.com/mssola/user_agent"
 	"github.com/mssola/user_agent"
-	"github.com/tiger1103/gfast/v3/apiv1/system"
+	"github.com/tiger1103/gfast/v3/api/v1/system"
 	"github.com/tiger1103/gfast/v3/internal/app/system/model"
 	"github.com/tiger1103/gfast/v3/internal/app/system/model"
 	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/dao"
 	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/dao"
 	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/do"
 	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/do"
@@ -21,21 +22,30 @@ import (
 	"github.com/tiger1103/gfast/v3/library/liberr"
 	"github.com/tiger1103/gfast/v3/library/liberr"
 )
 )
 
 
+type IUser interface {
+	GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model.LoginUserRes, err error)
+	LoginLog(ctx context.Context, params *model.LoginLogParams)
+	UpdateLoginInfo(ctx context.Context, id uint64, ip string) (err error)
+	NotCheckAuthAdminIds(ctx context.Context) *gset.Set
+}
+
+type userImpl struct{}
+
 var (
 var (
-	user = userImpl{}
+	notCheckAuthAdminIds *gset.Set //无需验证权限的用户id
+	user                 = userImpl{}
 )
 )
 
 
 func User() IUser {
 func User() IUser {
 	return IUser(&user)
 	return IUser(&user)
 }
 }
 
 
-type IUser interface {
-	GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model.LoginUserRes, err error)
-	LoginLog(ctx context.Context, params *model.LoginLogParams)
-	UpdateLoginInfo(ctx context.Context, id uint64, ip string) (err error)
-}
-
-type userImpl struct {
+func (s *userImpl) NotCheckAuthAdminIds(ctx context.Context) *gset.Set {
+	ids := g.Cfg().MustGet(ctx, "system.notCheckAuthAdminIds")
+	if !g.IsNil(ids) {
+		notCheckAuthAdminIds = gset.NewFrom(ids)
+	}
+	return notCheckAuthAdminIds
 }
 }
 
 
 func (s *userImpl) GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model.LoginUserRes, err error) {
 func (s *userImpl) GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model.LoginUserRes, err error) {

+ 8 - 3
manifest/config/config.yaml

@@ -49,21 +49,26 @@ gfToken:
 
 
 # Redis 配置示例
 # Redis 配置示例
 redis:
 redis:
-  # 单实例配置示例1
+  # 单实例配置
   default:
   default:
     address: 127.0.0.1:6379
     address: 127.0.0.1:6379
     db: 1
     db: 1
     idleTimeout: 600
     idleTimeout: 600
     maxActive: 100
     maxActive: 100
 
 
-
+system:
+  notCheckAuthAdminIds: [1,2,31]  #无需验证后台权限的用户id
+  dataDir: "./data"
+  cache:
+    model: "redis"  #缓存模式 memory OR redis
+    prefix: "gFastV3Cache_" #缓存前缀
 
 
 # CLI.
 # CLI.
 gfcli:
 gfcli:
   gen:
   gen:
     dao:
     dao:
       - link:            "mysql:root:123456@tcp(127.0.0.1:3306)/gfast-v3"
       - link:            "mysql:root:123456@tcp(127.0.0.1:3306)/gfast-v3"
-        tables:          "sys_login_log"
+        tables:          "sys_auth_rule,sys_role"
         removePrefix:    "gf_"
         removePrefix:    "gf_"
         descriptionTag:  true
         descriptionTag:  true
         noModelComment:  true
         noModelComment:  true