Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade dep versions #59

Open
wants to merge 2 commits into
base: os-v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/v1/common/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ type PageReq struct {

// ListRes 列表公共返回
type ListRes struct {
CurrentPage int `json:"currentPage"`
Total int `json:"total"`
CurrentPage int `json:"currentPage"`
Total int64 `json:"total"`
}
2 changes: 1 addition & 1 deletion api/v1/system/sys_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type RoleAddRes struct {

type RoleGetReq struct {
g.Meta `path:"/role/get" tags:"角色管理" method:"get" summary:"获取角色信息"`
Id uint `p:"id" v:"required#角色id不能为空""`
Id uint `p:"id" v:"required#角色id不能为空"`
}

type RoleGetRes struct {
Expand Down
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ module github.com/tiger1103/gfast/v3
go 1.15

require (
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/casbin/casbin/v2 v2.42.0
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/gogf/gf/v2 v2.0.6
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/casbin/casbin/v2 v2.58.0
github.com/gogf/gf/v2 v2.2.5
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mojocn/base64Captcha v1.3.5
github.com/mssola/user_agent v0.5.3
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/tencentyun/cos-go-sdk-v5 v0.7.34 // indirect
github.com/tiger1103/gfast-cache v0.0.7
github.com/tiger1103/gfast-token v0.1.0
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tencentyun/cos-go-sdk-v5 v0.7.40
github.com/tiger1103/gfast-cache v0.1.1
github.com/tiger1103/gfast-token v1.0.1
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opentelemetry.io/otel/sdk v1.6.1 // indirect
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
go.opentelemetry.io/otel/sdk v1.11.2 // indirect
golang.org/x/sys v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1
)
104 changes: 51 additions & 53 deletions go.sum

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions internal/app/common/service/sys_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package service
import (
"context"
"errors"

"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
Expand Down Expand Up @@ -44,7 +45,7 @@ func Config() IConfig {
// List 系统参数列表
func (s *configTmpl) List(ctx context.Context, req *system.ConfigSearchReq) (res *system.ConfigSearchRes, err error) {
res = new(system.ConfigSearchRes)
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysConfig.Ctx(ctx)
if req != nil {
if req.ConfigName != "" {
Expand Down Expand Up @@ -76,7 +77,7 @@ func (s *configTmpl) List(ctx context.Context, req *system.ConfigSearchReq) (res
}

func (s *configTmpl) Add(ctx context.Context, req *system.ConfigAddReq, userId uint64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = s.CheckConfigKeyUnique(ctx, req.ConfigKey)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysConfig.Ctx(ctx).Insert(do.SysConfig{
Expand All @@ -96,7 +97,7 @@ func (s *configTmpl) Add(ctx context.Context, req *system.ConfigAddReq, userId u

// CheckConfigKeyUnique 验证参数键名是否存在
func (s *configTmpl) CheckConfigKeyUnique(ctx context.Context, configKey string, configId ...int64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
data := (*entity.SysConfig)(nil)
m := dao.SysConfig.Ctx(ctx).Fields(dao.SysConfig.Columns().ConfigId).Where(dao.SysConfig.Columns().ConfigKey, configKey)
if len(configId) > 0 {
Expand All @@ -114,7 +115,7 @@ func (s *configTmpl) CheckConfigKeyUnique(ctx context.Context, configKey string,
// Get 获取系统参数
func (s *configTmpl) Get(ctx context.Context, id int) (res *system.ConfigGetRes, err error) {
res = new(system.ConfigGetRes)
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysConfig.Ctx(ctx).WherePri(id).Scan(&res.Data)
liberr.ErrIsNil(ctx, err, "获取系统参数失败")
})
Expand All @@ -123,7 +124,7 @@ func (s *configTmpl) Get(ctx context.Context, id int) (res *system.ConfigGetRes,

// Edit 修改系统参数
func (s *configTmpl) Edit(ctx context.Context, req *system.ConfigEditReq, userId uint64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = s.CheckConfigKeyUnique(ctx, req.ConfigKey, req.ConfigId)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysConfig.Ctx(ctx).WherePri(req.ConfigId).Update(do.SysConfig{
Expand All @@ -143,7 +144,7 @@ func (s *configTmpl) Edit(ctx context.Context, req *system.ConfigEditReq, userId

// Delete 删除系统参数
func (s *configTmpl) Delete(ctx context.Context, ids []int) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysConfig.Ctx(ctx).Delete(dao.SysConfig.Columns().ConfigId+" in (?)", ids)
liberr.ErrIsNil(ctx, err, "删除失败")
//清除缓存
Expand Down
13 changes: 7 additions & 6 deletions internal/app/common/service/sys_dict_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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"
Expand Down Expand Up @@ -46,7 +47,7 @@ func (s dictDataImpl) GetDictWithDataByType(ctx context.Context, req *system.Get
cacheKey := consts.CacheSysDict + "_" + req.DictType
//从缓存获取
iDict := cache.GetOrSetFuncLock(ctx, cacheKey, func(ctx context.Context) (value interface{}, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
//从数据库获取
dict = &system.GetDictRes{}
//获取类型数据
Expand Down Expand Up @@ -85,7 +86,7 @@ func (s dictDataImpl) GetDictWithDataByType(ctx context.Context, req *system.Get
// List 获取字典数据
func (s dictDataImpl) List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error) {
res = new(system.DictDataSearchRes)
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictData.Ctx(ctx)
if req != nil {
if req.DictLabel != "" {
Expand Down Expand Up @@ -115,7 +116,7 @@ func (s dictDataImpl) List(ctx context.Context, req *system.DictDataSearchReq) (
}

func (s *dictDataImpl) Add(ctx context.Context, req *system.DictDataAddReq, userId uint64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDictData.Ctx(ctx).Insert(do.SysDictData{
DictSort: req.DictSort,
DictLabel: req.DictLabel,
Expand All @@ -138,7 +139,7 @@ func (s *dictDataImpl) Add(ctx context.Context, req *system.DictDataAddReq, user
// Get 获取字典数据
func (s *dictDataImpl) Get(ctx context.Context, dictCode uint) (res *system.DictDataGetRes, err error) {
res = new(system.DictDataGetRes)
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysDictData.Ctx(ctx).WherePri(dictCode).Scan(&res.Dict)
liberr.ErrIsNil(ctx, err, "获取字典数据失败")
})
Expand All @@ -147,7 +148,7 @@ func (s *dictDataImpl) Get(ctx context.Context, dictCode uint) (res *system.Dict

// Edit 修改字典数据
func (s *dictDataImpl) Edit(ctx context.Context, req *system.DictDataEditReq, userId uint64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDictData.Ctx(ctx).WherePri(req.DictCode).Update(do.SysDictData{
DictSort: req.DictSort,
DictLabel: req.DictLabel,
Expand All @@ -169,7 +170,7 @@ func (s *dictDataImpl) Edit(ctx context.Context, req *system.DictDataEditReq, us

// Delete 删除字典数据
func (s *dictDataImpl) Delete(ctx context.Context, ids []int) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDictData.Ctx(ctx).Where(dao.SysDictData.Columns().DictCode+" in(?)", ids).Delete()
liberr.ErrIsNil(ctx, err, "删除字典数据失败")
//清除缓存
Expand Down
13 changes: 7 additions & 6 deletions internal/app/common/service/sys_dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package service

import (
"context"

"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
Expand Down Expand Up @@ -44,7 +45,7 @@ func DictType() IDictType {
// List 字典类型列表
func (s *dictTypeImpl) List(ctx context.Context, req *system.DictTypeSearchReq) (res *system.DictTypeSearchRes, err error) {
res = new(system.DictTypeSearchRes)
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictType.Ctx(ctx)
if req.DictName != "" {
m = m.Where(dao.SysDictType.Columns().DictName+" like ?", "%"+req.DictName+"%")
Expand Down Expand Up @@ -73,7 +74,7 @@ func (s *dictTypeImpl) List(ctx context.Context, req *system.DictTypeSearchReq)

// Add 添加字典类型
func (s *dictTypeImpl) Add(ctx context.Context, req *system.DictTypeAddReq, userId uint64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = s.ExistsDictType(ctx, req.DictType)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysDictType.Ctx(ctx).Insert(do.SysDictType{
Expand All @@ -93,7 +94,7 @@ func (s *dictTypeImpl) Add(ctx context.Context, req *system.DictTypeAddReq, user
// Edit 修改字典类型
func (s *dictTypeImpl) Edit(ctx context.Context, req *system.DictTypeEditReq, userId uint64) (err error) {
err = g.DB().Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = s.ExistsDictType(ctx, req.DictType, req.DictId)
liberr.ErrIsNil(ctx, err)
dictType := (*entity.SysDictType)(nil)
Expand Down Expand Up @@ -122,7 +123,7 @@ func (s *dictTypeImpl) Edit(ctx context.Context, req *system.DictTypeEditReq, us
}

func (s *dictTypeImpl) Get(ctx context.Context, req *system.DictTypeGetReq) (dictType *entity.SysDictType, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictId, req.DictId).Scan(&dictType)
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
})
Expand All @@ -131,7 +132,7 @@ func (s *dictTypeImpl) Get(ctx context.Context, req *system.DictTypeGetReq) (dic

// ExistsDictType 检查类型是否已经存在
func (s *dictTypeImpl) ExistsDictType(ctx context.Context, dictType string, dictId ...int64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictId).
Where(dao.SysDictType.Columns().DictType, dictType)
if len(dictId) > 0 {
Expand All @@ -149,7 +150,7 @@ func (s *dictTypeImpl) ExistsDictType(ctx context.Context, dictType string, dict
// Delete 删除字典类型
func (s *dictTypeImpl) Delete(ctx context.Context, dictIds []int) (err error) {
err = g.DB().Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
discs := ([]*entity.SysDictType)(nil)
err = dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictType).
Where(dao.SysDictType.Columns().DictId+" in (?) ", dictIds).Scan(&discs)
Expand Down
3 changes: 2 additions & 1 deletion internal/app/system/controller/sys_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"

"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/entity"
Expand Down Expand Up @@ -34,7 +35,7 @@ func (c *userController) GetUserMenus(ctx context.Context, req *system.UserMenus
// List 用户列表
func (c *userController) List(ctx context.Context, req *system.UserSearchReq) (res *system.UserSearchRes, err error) {
var (
total int
total int64
userList []*entity.SysUser
)
res = new(system.UserSearchRes)
Expand Down
21 changes: 11 additions & 10 deletions internal/app/system/service/sys_auth_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package service
import (
"context"
"fmt"

"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
Expand Down Expand Up @@ -47,7 +48,7 @@ func Rule() IRule {
}

func (s *ruleImpl) GetMenuListSearch(ctx context.Context, req *system.RuleSearchReq) (res []*model.SysAuthRuleInfoRes, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysAuthRule.Ctx(ctx)
if req.Title != "" {
m = m.Where("title like ?", "%"+req.Title+"%")
Expand Down Expand Up @@ -90,7 +91,7 @@ func (s *ruleImpl) GetMenuList(ctx context.Context) (list []*model.SysAuthRuleIn

// 从数据库获取所有菜单
func (s *ruleImpl) getMenuListFromDb(ctx context.Context) (value interface{}, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
var v []*model.SysAuthRuleInfoRes
//从数据库获取
err = dao.SysAuthRule.Ctx(ctx).
Expand Down Expand Up @@ -123,7 +124,7 @@ func (s *ruleImpl) Add(ctx context.Context, req *system.RuleAddReq) (err error)
return
}
err = g.DB().Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
//菜单数据
data := do.SysAuthRule{
Pid: req.Pid,
Expand Down Expand Up @@ -158,7 +159,7 @@ func (s *ruleImpl) Add(ctx context.Context, req *system.RuleAddReq) (err error)
return
}

//检查菜单规则是否存在
// 检查菜单规则是否存在
func (s *ruleImpl) menuNameExists(ctx context.Context, name string, id uint) bool {
m := dao.SysAuthRule.Ctx(ctx).Where("name=?", name)
if id != 0 {
Expand All @@ -174,7 +175,7 @@ func (s *ruleImpl) menuNameExists(ctx context.Context, name string, id uint) boo

// BindRoleRule 绑定角色权限
func (s *ruleImpl) BindRoleRule(ctx context.Context, ruleId interface{}, roleIds []uint) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
enforcer, e := commonService.CasbinEnforcer(ctx)
liberr.ErrIsNil(ctx, e)
for _, roleId := range roleIds {
Expand All @@ -186,15 +187,15 @@ func (s *ruleImpl) BindRoleRule(ctx context.Context, ruleId interface{}, roleIds
}

func (s *ruleImpl) Get(ctx context.Context, id uint) (rule *entity.SysAuthRule, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysAuthRule.Ctx(ctx).WherePri(id).Scan(&rule)
liberr.ErrIsNil(ctx, err, "获取菜单失败")
})
return
}

func (s *ruleImpl) GetMenuRoles(ctx context.Context, id uint) (roleIds []uint, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
enforcer, e := commonService.CasbinEnforcer(ctx)
liberr.ErrIsNil(ctx, e)
policies := enforcer.GetFilteredNamedPolicy("p", 1, gconv.String(id))
Expand All @@ -211,7 +212,7 @@ func (s *ruleImpl) Update(ctx context.Context, req *system.RuleUpdateReq) (err e
return
}
err = g.DB().Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
//菜单数据
data := do.SysAuthRule{
Pid: req.Pid,
Expand Down Expand Up @@ -247,7 +248,7 @@ func (s *ruleImpl) Update(ctx context.Context, req *system.RuleUpdateReq) (err e
}

func (s *ruleImpl) UpdateRoleRule(ctx context.Context, ruleId uint, roleIds []uint) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
enforcer, e := commonService.CasbinEnforcer(ctx)
liberr.ErrIsNil(ctx, e)
//删除旧权限
Expand Down Expand Up @@ -296,7 +297,7 @@ func (s *ruleImpl) DeleteMenuByIds(ctx context.Context, ids []int) (err error) {
}
ids = append(ids, childrenIds...)
err = g.DB().Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
return g.Try(func() {
return g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysAuthRule.Ctx(ctx).Where("id in (?)", ids).Delete()
liberr.ErrIsNil(ctx, err, "删除失败")
//删除权限
Expand Down
9 changes: 5 additions & 4 deletions internal/app/system/service/sys_dept.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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"
Expand Down Expand Up @@ -63,7 +64,7 @@ func (s *deptImpl) GetList(ctx context.Context, req *system.DeptSearchReq) (list
}

func (s *deptImpl) GetFromCache(ctx context.Context) (list []*entity.SysDept, err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
cache := commonService.Cache()
//从缓存获取
iList := cache.GetOrSetFuncLock(ctx, consts.CacheSysDept, func(ctx context.Context) (value interface{}, err error) {
Expand All @@ -82,7 +83,7 @@ func (s *deptImpl) GetFromCache(ctx context.Context) (list []*entity.SysDept, er

// Add 添加部门
func (s *deptImpl) Add(ctx context.Context, req *system.DeptAddReq) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDept.Ctx(ctx).Insert(do.SysDept{
ParentId: req.ParentID,
DeptName: req.DeptName,
Expand All @@ -102,7 +103,7 @@ func (s *deptImpl) Add(ctx context.Context, req *system.DeptAddReq) (err error)

// Edit 部门修改
func (s *deptImpl) Edit(ctx context.Context, req *system.DeptEditReq) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDept.Ctx(ctx).WherePri(req.DeptId).Update(do.SysDept{
ParentId: req.ParentID,
DeptName: req.DeptName,
Expand All @@ -121,7 +122,7 @@ func (s *deptImpl) Edit(ctx context.Context, req *system.DeptEditReq) (err error
}

func (s *deptImpl) Delete(ctx context.Context, id int64) (err error) {
err = g.Try(func() {
err = g.Try(ctx, func(ctx context.Context) {
var list []*entity.SysDept
err = dao.SysDept.Ctx(ctx).Scan(&list)
liberr.ErrIsNil(ctx, err, "不存在部门信息")
Expand Down
Loading