ci: support husky
feat: fix lint issues
This commit is contained in:
39
.husky.toml
Normal file
39
.husky.toml
Normal file
@@ -0,0 +1,39 @@
|
||||
# version-file which will write or read current semver
|
||||
version-file = "internal/version/version"
|
||||
|
||||
# hook scripts
|
||||
[hooks]
|
||||
|
||||
# after version calc,
|
||||
# with use the {{ .Version }} to upgrade other files.
|
||||
post-version = [
|
||||
"sed -i -e 's/\"version\": \"[^\"]*\"/\"version\": \"{{ .Version }}\"/g' testdata/package.json",
|
||||
"sed -i -e 's/version: [^\\n]*/version: {{ .Version }}/g' testdata/pubspec.yaml"
|
||||
]
|
||||
|
||||
# git hook pre commit
|
||||
pre-commit = [
|
||||
"golangci-lint run",
|
||||
"husky lint-staged",
|
||||
]
|
||||
|
||||
# git hook commit msg
|
||||
commit-msg = [
|
||||
"husky lint-commit",
|
||||
]
|
||||
|
||||
# list staged files do some pre-process and git add
|
||||
[lint-staged]
|
||||
"*.go" = [
|
||||
"goimports -l -w",
|
||||
"gofmt -l -w",
|
||||
]
|
||||
|
||||
# commit msg rule default support conventional commits
|
||||
[lint-commit]
|
||||
# could check if this exists
|
||||
# email = "^(.+@gmail.com|.+@qq.com)$"
|
||||
# optional custom types check regex
|
||||
# types = "^(feat|fix|build|chore|ci|docs|perf|refactor|revert|style|test)$"
|
||||
# optional header check regex
|
||||
# header = "^(?P<type>\w+)(\((?P<scope>[\w/.-]+)\))?(?P<breaking>!)?:( +)?(?P<header>.+)"
|
||||
1
go.mod
1
go.mod
@@ -16,7 +16,6 @@ require (
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rogeecn/fabfile v1.3.0
|
||||
github.com/rogeecn/gen v1.0.11
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/smartystreets/goconvey v1.7.2
|
||||
github.com/spf13/cobra v1.5.0
|
||||
github.com/spf13/viper v1.15.0
|
||||
|
||||
1
go.sum
1
go.sum
@@ -338,7 +338,6 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
|
||||
@@ -36,7 +36,7 @@ func CheckPermission(config *config.Config, rbac rbac.IRbac) gin.HandlerFunc {
|
||||
// 获取用户的角色
|
||||
role := strconv.Itoa(int(claims.Role))
|
||||
|
||||
if rbac.Can(role, method, path) == false {
|
||||
if !rbac.Can(role, method, path) {
|
||||
gen.NewBusError(http.StatusForbidden, http.StatusForbidden, "未登录或非法访问").JSON(c, false)
|
||||
c.Abort()
|
||||
return
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Dict struct {
|
||||
@@ -37,9 +36,8 @@ func NewDictionary(query *query.Query) (*Dict, error) {
|
||||
}
|
||||
|
||||
func (dict *Dict) Load() error {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
dictTable := dict.query.SysDictionary
|
||||
items, err := dictTable.WithContext(ctx).Where(dictTable.Status.Is(true)).Find()
|
||||
items, err := dictTable.WithContext(context.Background()).Where(dictTable.Status.Is(true)).Find()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -50,9 +48,8 @@ func (dict *Dict) Load() error {
|
||||
dict.mapAlias[item.Alias_] = item.ID
|
||||
}
|
||||
|
||||
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
|
||||
dictDetailTable := dict.query.SysDictionaryDetail
|
||||
dictItems, err := dictDetailTable.WithContext(ctx).
|
||||
dictItems, err := dictDetailTable.WithContext(context.Background()).
|
||||
Where(dictDetailTable.Status.Is(true)).
|
||||
Where(dictDetailTable.ID.In(ids...)).
|
||||
Order(dictDetailTable.Weight.Desc()).
|
||||
|
||||
Reference in New Issue
Block a user