Compare commits
19 Commits
update-cou
...
master
Author | SHA1 | Date |
---|---|---|
sinhluu | fca744f17a | |
Sinh | cd94018a17 | |
sinhluu | 3d1c1d7538 | |
sinhluu | 7dff7ac4e0 | |
Sinh | b2ee21527a | |
Sinh | 645d38f7ce | |
Sinh | 29157b2530 | |
trunglt251292 | 6db4919231 | |
trunglt251292 | 4bb62759b0 | |
nguyenphamquangtue | e87f36995b | |
Tue | fb660c6715 | |
nguyenphamquangtue | 0e6bd566a5 | |
Tue | 2224a68c98 | |
nguyenphamquangtue | 7a268b4027 | |
Tue | f41786dd27 | |
nguyenphamquangtue | a6a6fb66cb | |
Tue | b80e8054d5 | |
nguyenphamquangtue | a83e938deb | |
Tue | 848ffb8ff2 |
15
action.go
15
action.go
|
@ -69,11 +69,6 @@ func (s Service) GetUsersByPermission(query model.UserByPermissionQuery) model.U
|
||||||
return user.GetUsersByPermission(query)
|
return user.GetUsersByPermission(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountByCondition ...
|
|
||||||
func (s Service) CountByCondition(filter interface{}) int64 {
|
|
||||||
return user.CountByCondition(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CountAllUsers ...
|
// CountAllUsers ...
|
||||||
func (s Service) CountAllUsers(query model.UserCountQuery) int64 {
|
func (s Service) CountAllUsers(query model.UserCountQuery) int64 {
|
||||||
return user.Count(query)
|
return user.Count(query)
|
||||||
|
@ -171,6 +166,16 @@ func (s Service) DeletePermission(permissionID string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindAndDeletePermission ...
|
||||||
|
func (s Service) FindAndDeletePermission(permissionID string) (*model.Permission, error) {
|
||||||
|
p, err := permission.FindByIDAndDelete(permissionID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cache.Roles()
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetAllPermissions ...
|
// GetAllPermissions ...
|
||||||
func (s Service) GetAllPermissions(query model.PermissionAllQuery) model.PermissionAll {
|
func (s Service) GetAllPermissions(query model.PermissionAllQuery) model.PermissionAll {
|
||||||
return permission.All(query)
|
return permission.All(query)
|
||||||
|
|
|
@ -54,3 +54,14 @@ func GetValueByKey(key string) ([]byte, error) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
return c.Get(ctx, key).Bytes()
|
return c.Get(ctx, key).Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetJSON(key string, result interface{}) bool {
|
||||||
|
v, err := GetValueByKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(v, result); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ package cache
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/database"
|
"git.selly.red/Selly-Modules/usermngmt/database"
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func roleFindByCondition(ctx context.Context, cond interface{}, opts ...*options.FindOptions) (docs []model.DBRole) {
|
func roleFindByCondition(ctx context.Context, cond interface{}, opts ...*options.FindOptions) (docs []model.DBRole) {
|
||||||
|
@ -17,20 +17,10 @@ func roleFindByCondition(ctx context.Context, cond interface{}, opts ...*options
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - Find", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - Role - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -44,20 +34,10 @@ func permissionFindByCondition(ctx context.Context, cond interface{}, opts ...*o
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - Find", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - Permission - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package cache
|
||||||
|
|
||||||
|
const (
|
||||||
|
keyPrefix = "usermngmt_"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
KeyLoginFailedTimes = keyPrefix + "login_failed_time"
|
||||||
|
)
|
|
@ -3,11 +3,12 @@ package cache
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Roles ...
|
// Roles ...
|
||||||
|
@ -41,9 +42,6 @@ func Roles() {
|
||||||
Permissions: rolePermissions,
|
Permissions: rolePermissions,
|
||||||
}
|
}
|
||||||
if err := SetKeyValue(role.ID.Hex(), entry, 0); err != nil {
|
if err := SetKeyValue(role.ID.Hex(), entry, 0); err != nil {
|
||||||
logger.Error("usermngmt - CacheRole", logger.LogData{
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}(value)
|
}(value)
|
||||||
|
@ -64,9 +62,7 @@ func GetCachedRole(key string) CachedRole {
|
||||||
// Unmarshal data
|
// Unmarshal data
|
||||||
var cachedRole CachedRole
|
var cachedRole CachedRole
|
||||||
if err := json.Unmarshal(value, &cachedRole); err != nil {
|
if err := json.Unmarshal(value, &cachedRole); err != nil {
|
||||||
logger.Error("usermngmt - GetCachedRole - Unmarshal", logger.LogData{
|
log.Println("usermngmt - GetCachedRole - Unmarshal: ", err)
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return cachedRole
|
return cachedRole
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
const (
|
||||||
|
MaximumLoginFailedTime = 5
|
||||||
|
LoginFailedBlockedDuration = time.Hour
|
||||||
|
)
|
||||||
|
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
EmailIsUnique bool
|
EmailIsUnique bool
|
||||||
PhoneNumberIsUnique bool
|
PhoneNumberIsUnique bool
|
||||||
|
|
25
go.mod
25
go.mod
|
@ -3,7 +3,6 @@ module git.selly.red/Selly-Modules/usermngmt
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.selly.red/Selly-Modules/logger v0.0.2-0.20221010053254-567df039afdb
|
|
||||||
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2
|
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2
|
||||||
github.com/go-redis/redis/v8 v8.11.4
|
github.com/go-redis/redis/v8 v8.11.4
|
||||||
github.com/logrusorgru/aurora v2.0.3+incompatible
|
github.com/logrusorgru/aurora v2.0.3+incompatible
|
||||||
|
@ -13,36 +12,20 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/armon/go-radix v1.0.0 // indirect
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/elastic/go-licenser v0.4.1 // indirect
|
|
||||||
github.com/elastic/go-sysinfo v1.1.1 // indirect
|
|
||||||
github.com/elastic/go-windows v1.0.1 // indirect
|
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/jcchavezs/porto v0.4.0 // indirect
|
github.com/google/go-cmp v0.5.8 // indirect
|
||||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
|
|
||||||
github.com/klauspost/compress v1.13.6 // indirect
|
github.com/klauspost/compress v1.13.6 // indirect
|
||||||
github.com/montanaflynn/stats v0.6.6 // indirect
|
github.com/montanaflynn/stats v0.6.6 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect
|
github.com/stretchr/testify v1.8.0 // indirect
|
||||||
github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
|
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
github.com/xdg-go/scram v1.1.1 // indirect
|
github.com/xdg-go/scram v1.1.1 // indirect
|
||||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
github.com/xdg-go/stringprep v1.0.3 // indirect
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||||
go.elastic.co/apm v1.15.0 // indirect
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||||
go.elastic.co/apm/module/apmzap v1.15.0 // indirect
|
|
||||||
go.elastic.co/fastjson v1.1.0 // indirect
|
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
|
||||||
go.uber.org/multierr v1.8.0 // indirect
|
|
||||||
go.uber.org/zap v1.18.1 // indirect
|
|
||||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
|
|
||||||
golang.org/x/mod v0.5.1 // indirect
|
|
||||||
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
|
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20211102192858-4dd72447c267 // indirect
|
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
golang.org/x/tools v0.1.7 // indirect
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
|
||||||
howett.net/plist v1.0.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
93
go.sum
93
go.sum
|
@ -1,12 +1,6 @@
|
||||||
git.selly.red/Selly-Modules/logger v0.0.2-0.20221010053254-567df039afdb h1:AmcYd88IcdSkH+NEvKyJLT7psidSkjJQT/nAg/KuzFk=
|
|
||||||
git.selly.red/Selly-Modules/logger v0.0.2-0.20221010053254-567df039afdb/go.mod h1:Q1//Z6HRmfa7VyjH2J6YyT0YV2jT8+K6SIgwnYuS4II=
|
|
||||||
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2 h1:bePzcMN/j4V1fvz6UUrN01ey1tkE0w+m5Qj3LtoZs4E=
|
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2 h1:bePzcMN/j4V1fvz6UUrN01ey1tkE0w+m5Qj3LtoZs4E=
|
||||||
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2/go.mod h1:Xvs3E6YbTPI5I4+I1aXrY0A79XaCfw+0tqV8dihvheE=
|
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2/go.mod h1:Xvs3E6YbTPI5I4+I1aXrY0A79XaCfw+0tqV8dihvheE=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
|
|
||||||
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
@ -14,14 +8,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ=
|
|
||||||
github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN48x4=
|
|
||||||
github.com/elastic/go-licenser v0.4.1/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
|
|
||||||
github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQmMI=
|
|
||||||
github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
|
|
||||||
github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
|
|
||||||
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
|
|
||||||
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
|
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
@ -70,16 +56,11 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
|
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6E9EZF4A=
|
|
||||||
github.com/jcchavezs/porto v0.4.0 h1:Zj7RligrxmDdKGo6fBO2xYAHxEgrVBfs1YAja20WbV4=
|
|
||||||
github.com/jcchavezs/porto v0.4.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6E9EZF4A=
|
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=
|
|
||||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak=
|
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
|
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
|
||||||
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||||
|
@ -116,13 +97,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 h1:c8R11WC8m7KNMkTv/0+Be8vvwo4I3/Ut9AC2FW8fX3U=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
|
||||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis=
|
|
||||||
github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4=
|
|
||||||
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
|
@ -130,13 +107,15 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3
|
||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
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.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
||||||
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
|
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
|
||||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||||
|
@ -152,32 +131,10 @@ github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgk
|
||||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
|
||||||
go.elastic.co/apm v1.13.1/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY=
|
|
||||||
go.elastic.co/apm v1.15.0 h1:uPk2g/whK7c7XiZyz/YCUnAUBNPiyNeE3ARX3G6Gx7Q=
|
|
||||||
go.elastic.co/apm v1.15.0/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY=
|
|
||||||
go.elastic.co/apm/module/apmzap v1.13.1/go.mod h1:Tu8/TwffpBoNGmI05VcL1Ye2AC8oXrlMKNaKD1TIQy0=
|
|
||||||
go.elastic.co/apm/module/apmzap v1.15.0 h1:SjXslnImV3jaK2BtNqRl994H9mpG8+6qqPAahbzwIys=
|
|
||||||
go.elastic.co/apm/module/apmzap v1.15.0/go.mod h1:eowOIqa+vS+BZ9YOCztd8poYGxSxXh8YfVuOHTMhKQs=
|
|
||||||
go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4=
|
|
||||||
go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI=
|
|
||||||
go.mongodb.org/mongo-driver v1.7.1/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8=
|
go.mongodb.org/mongo-driver v1.7.1/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8=
|
||||||
go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA=
|
go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA=
|
||||||
go.mongodb.org/mongo-driver v1.10.3/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
|
go.mongodb.org/mongo-driver v1.10.3/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
|
||||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|
||||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
|
||||||
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
|
|
||||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
|
||||||
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
|
|
||||||
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
|
||||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
|
||||||
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
|
|
||||||
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||||
|
@ -186,29 +143,18 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
|
|
||||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
|
||||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
@ -225,22 +171,20 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211102192858-4dd72447c267 h1:7zYaz3tjChtpayGDzu6H0hDAUM5zIGA2XW7kRNgQ0jc=
|
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
|
||||||
golang.org/x/sys v0.0.0-20211102192858-4dd72447c267/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
@ -248,22 +192,15 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
|
||||||
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
|
||||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ=
|
|
||||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
@ -279,8 +216,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
@ -288,9 +223,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
|
|
||||||
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
|
||||||
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
|
||||||
|
|
|
@ -28,5 +28,7 @@ const (
|
||||||
|
|
||||||
// Incorrect
|
// Incorrect
|
||||||
|
|
||||||
ErrorIncorrectPassword = "mật khẩu không chính xác"
|
ErrorIncorrectPassword = "mật khẩu không chính xác"
|
||||||
|
ErrorInvalidLogin = "thông tin đăng nhập không đúng"
|
||||||
|
ErrorExceedMaximumLoginFail = "bạn đã đăng nhập sai thông tin quá số lần cho phép"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,8 @@ package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/thoas/go-funk"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/mongodb"
|
"git.selly.red/Selly-Modules/mongodb"
|
||||||
|
@ -46,3 +48,10 @@ func GenerateCode(s string) string {
|
||||||
)
|
)
|
||||||
return strings.ReplaceAll(mongodb.NonAccentVietnamese(s), emptySpace, underscore)
|
return strings.ReplaceAll(mongodb.NonAccentVietnamese(s), emptySpace, underscore)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConvertObjectIDsToStrings ...
|
||||||
|
func ConvertObjectIDsToStrings(ids []primitive.ObjectID) []string {
|
||||||
|
return funk.Map(ids, func(item primitive.ObjectID) string {
|
||||||
|
return item.Hex()
|
||||||
|
}).([]string)
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package model
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/mongodb"
|
"git.selly.red/Selly-Modules/mongodb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,25 +34,16 @@ type PermissionAllQuery struct {
|
||||||
func (co PermissionCreateOptions) Validate() error {
|
func (co PermissionCreateOptions) Validate() error {
|
||||||
// Name
|
// Name
|
||||||
if co.Name == "" {
|
if co.Name == "" {
|
||||||
logger.Error("usermngmt - Permission - Create: no name data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no name data")
|
return errors.New("no name data")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code
|
// Code
|
||||||
if co.Code == "" {
|
if co.Code == "" {
|
||||||
logger.Error("usermngmt - Permission - Create: no code data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no code data")
|
return errors.New("no code data")
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleID
|
// RoleID
|
||||||
if co.RoleID == "" {
|
if co.RoleID == "" {
|
||||||
logger.Error("usermngmt - Permission - Create: no roleID data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no role id data")
|
return errors.New("no role id data")
|
||||||
}
|
}
|
||||||
if _, isValid := mongodb.NewIDFromString(co.RoleID); !isValid {
|
if _, isValid := mongodb.NewIDFromString(co.RoleID); !isValid {
|
||||||
|
@ -62,9 +52,6 @@ func (co PermissionCreateOptions) Validate() error {
|
||||||
|
|
||||||
// Desc
|
// Desc
|
||||||
if co.Desc == "" {
|
if co.Desc == "" {
|
||||||
logger.Error("usermngmt - Permission - Create: no desc data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no desc data")
|
return errors.New("no desc data")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -74,25 +61,16 @@ func (co PermissionCreateOptions) Validate() error {
|
||||||
func (co PermissionUpdateOptions) Validate() error {
|
func (co PermissionUpdateOptions) Validate() error {
|
||||||
// Name
|
// Name
|
||||||
if co.Name == "" {
|
if co.Name == "" {
|
||||||
logger.Error("usermngmt - Permission - Update: no name data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no name data")
|
return errors.New("no name data")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code
|
// Code
|
||||||
if co.Code == "" {
|
if co.Code == "" {
|
||||||
logger.Error("usermngmt - Permission - Update: no code data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no code data")
|
return errors.New("no code data")
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleID
|
// RoleID
|
||||||
if co.RoleID == "" {
|
if co.RoleID == "" {
|
||||||
logger.Error("usermngmt - Permission - Update: no roleID data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no role id data")
|
return errors.New("no role id data")
|
||||||
}
|
}
|
||||||
if _, isValid := mongodb.NewIDFromString(co.RoleID); !isValid {
|
if _, isValid := mongodb.NewIDFromString(co.RoleID); !isValid {
|
||||||
|
@ -101,9 +79,6 @@ func (co PermissionUpdateOptions) Validate() error {
|
||||||
|
|
||||||
// Desc
|
// Desc
|
||||||
if co.Desc == "" {
|
if co.Desc == "" {
|
||||||
logger.Error("usermngmt - Permission - Update: no desc data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New("no desc data")
|
return errors.New("no desc data")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const maxLimit = 500
|
||||||
|
|
||||||
// CommonQuery ...
|
// CommonQuery ...
|
||||||
type CommonQuery struct {
|
type CommonQuery struct {
|
||||||
Page int64
|
Page int64
|
||||||
|
@ -78,9 +80,12 @@ func (q *CommonQuery) GetFindOptionsUsingPage() *options.FindOptions {
|
||||||
|
|
||||||
// SetDefaultLimit ...
|
// SetDefaultLimit ...
|
||||||
func (q *CommonQuery) SetDefaultLimit() {
|
func (q *CommonQuery) SetDefaultLimit() {
|
||||||
if q.Limit <= 0 || q.Limit > 20 {
|
if q.Limit <= 0 {
|
||||||
q.Limit = 20
|
q.Limit = 20
|
||||||
}
|
}
|
||||||
|
if q.Limit > maxLimit {
|
||||||
|
q.Limit = 500
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssignOther ...
|
// AssignOther ...
|
||||||
|
|
|
@ -3,7 +3,6 @@ package model
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/internal"
|
"git.selly.red/Selly-Modules/usermngmt/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,9 +31,6 @@ type RoleAllQuery struct {
|
||||||
func (co RoleCreateOptions) Validate() error {
|
func (co RoleCreateOptions) Validate() error {
|
||||||
// Name
|
// Name
|
||||||
if co.Name == "" {
|
if co.Name == "" {
|
||||||
logger.Error("usermngmt - Role - Create: no name data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidName)
|
return errors.New(internal.ErrorInvalidName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +41,6 @@ func (co RoleCreateOptions) Validate() error {
|
||||||
func (co RoleUpdateOptions) Validate() error {
|
func (co RoleUpdateOptions) Validate() error {
|
||||||
// Name
|
// Name
|
||||||
if co.Name == "" {
|
if co.Name == "" {
|
||||||
logger.Error("usermngmt - Role - Update: no name data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidName)
|
return errors.New(internal.ErrorInvalidName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package model
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/internal"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserCreateOptions ...
|
// UserCreateOptions ...
|
||||||
|
@ -70,49 +70,31 @@ type UserCountQuery struct {
|
||||||
func (co UserCreateOptions) Validate() error {
|
func (co UserCreateOptions) Validate() error {
|
||||||
// Name
|
// Name
|
||||||
if co.Name == "" {
|
if co.Name == "" {
|
||||||
logger.Error("usermngmt - User - Create: no name data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidName)
|
return errors.New(internal.ErrorInvalidName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phone
|
// Phone
|
||||||
if co.Phone == "" {
|
if co.Phone == "" {
|
||||||
logger.Error("usermngmt - User - Create: no phone data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidPhoneNumber)
|
return errors.New(internal.ErrorInvalidPhoneNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email
|
// Email
|
||||||
if co.Email == "" {
|
if co.Email == "" {
|
||||||
logger.Error("usermngmt - User - Create: no email data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidEmail)
|
return errors.New(internal.ErrorInvalidEmail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
if co.Password == "" {
|
if co.Password == "" {
|
||||||
logger.Error("usermngmt - User - Create: no password data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidPassword)
|
return errors.New(internal.ErrorInvalidPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
if co.Status == "" {
|
if co.Status == "" {
|
||||||
logger.Error("usermngmt - User - Create: no status data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidStatus)
|
return errors.New(internal.ErrorInvalidStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleID
|
// RoleID
|
||||||
if co.RoleID == "" {
|
if co.RoleID == "" {
|
||||||
logger.Error("usermngmt - User - Create: no roleID data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidRole)
|
return errors.New(internal.ErrorInvalidRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,33 +105,21 @@ func (co UserCreateOptions) Validate() error {
|
||||||
func (uo UserUpdateOptions) Validate() error {
|
func (uo UserUpdateOptions) Validate() error {
|
||||||
// Name
|
// Name
|
||||||
if uo.Name == "" {
|
if uo.Name == "" {
|
||||||
logger.Error("usermngmt - User - Update: no name data", logger.LogData{
|
|
||||||
"payload": uo,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidName)
|
return errors.New(internal.ErrorInvalidName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phone
|
// Phone
|
||||||
if uo.Phone == "" {
|
if uo.Phone == "" {
|
||||||
logger.Error("usermngmt - User - Update: no phone data", logger.LogData{
|
|
||||||
"payload": uo,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidPhoneNumber)
|
return errors.New(internal.ErrorInvalidPhoneNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email
|
// Email
|
||||||
if uo.Email == "" {
|
if uo.Email == "" {
|
||||||
logger.Error("usermngmt - User - Update: no email data", logger.LogData{
|
|
||||||
"payload": uo,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidEmail)
|
return errors.New(internal.ErrorInvalidEmail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleID
|
// RoleID
|
||||||
if uo.RoleID == "" {
|
if uo.RoleID == "" {
|
||||||
logger.Error("usermngmt - User - Update: no roleID data", logger.LogData{
|
|
||||||
"payload": uo,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidRole)
|
return errors.New(internal.ErrorInvalidRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,16 +130,10 @@ func (uo UserUpdateOptions) Validate() error {
|
||||||
func (co ChangePasswordOptions) Validate() error {
|
func (co ChangePasswordOptions) Validate() error {
|
||||||
// OldPassword, NewPassword
|
// OldPassword, NewPassword
|
||||||
if co.OldPassword == "" {
|
if co.OldPassword == "" {
|
||||||
logger.Error("usermngmt - User - ChangePassword: no old password data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidOldPassword)
|
return errors.New(internal.ErrorInvalidOldPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
if co.NewPassword == "" {
|
if co.NewPassword == "" {
|
||||||
logger.Error("usermngmt - User - ChangePassword: no new password data", logger.LogData{
|
|
||||||
"payload": co,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidNewPassword)
|
return errors.New(internal.ErrorInvalidNewPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,9 +144,6 @@ func (co ChangePasswordOptions) Validate() error {
|
||||||
func (q UserByPermissionQuery) Validate() error {
|
func (q UserByPermissionQuery) Validate() error {
|
||||||
// OldPassword, NewPassword
|
// OldPassword, NewPassword
|
||||||
if q.Permission == "" {
|
if q.Permission == "" {
|
||||||
logger.Error("usermngmt - User - GetUsersByPermission : invalid permission", logger.LogData{
|
|
||||||
"payload": q,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidPermission)
|
return errors.New(internal.ErrorInvalidPermission)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/internal"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,6 +22,32 @@ type User struct {
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserOtherBson ...
|
||||||
|
type UserOtherBson struct {
|
||||||
|
Supplier primitive.ObjectID `bson:"supplier"`
|
||||||
|
Inventories []primitive.ObjectID `bson:"inventories"`
|
||||||
|
IsPresident bool `bson:"isPresident"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserOther struct {
|
||||||
|
Supplier string `json:"supplier"`
|
||||||
|
Inventories []string `json:"inventories"`
|
||||||
|
IsPresident bool `json:"isPresident"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m User) GetUserOther() UserOther {
|
||||||
|
var (
|
||||||
|
userOtherBson UserOtherBson
|
||||||
|
)
|
||||||
|
bsonBytes, _ := bson.Marshal(m.Other)
|
||||||
|
bson.Unmarshal(bsonBytes, &userOtherBson)
|
||||||
|
return UserOther{
|
||||||
|
Supplier: userOtherBson.Supplier.Hex(),
|
||||||
|
Inventories: internal.ConvertObjectIDsToStrings(userOtherBson.Inventories),
|
||||||
|
IsPresident: userOtherBson.IsPresident,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// UserAll ...
|
// UserAll ...
|
||||||
UserAll struct {
|
UserAll struct {
|
||||||
|
|
|
@ -3,13 +3,14 @@ package permission
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/database"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/database"
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func findByID(ctx context.Context, id primitive.ObjectID) (model.DBPermission, error) {
|
func findByID(ctx context.Context, id primitive.ObjectID) (model.DBPermission, error) {
|
||||||
|
@ -27,10 +28,6 @@ func create(ctx context.Context, doc model.DBPermission) error {
|
||||||
)
|
)
|
||||||
_, err := col.InsertOne(ctx, doc)
|
_, err := col.InsertOne(ctx, doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - InsertOne", logger.LogData{
|
|
||||||
"doc": doc,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when create permission: %s", err.Error())
|
return fmt.Errorf("error when create permission: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +40,6 @@ func updateOneByCondition(ctx context.Context, cond interface{}, payload interfa
|
||||||
)
|
)
|
||||||
_, err := col.UpdateOne(ctx, cond, payload)
|
_, err := col.UpdateOne(ctx, cond, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - UpdateOne", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"payload": payload,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when update permission: %s", err.Error())
|
return fmt.Errorf("error when update permission: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,16 +52,24 @@ func deleteOneByCondition(ctx context.Context, cond interface{}) error {
|
||||||
)
|
)
|
||||||
_, err := col.DeleteOne(ctx, cond)
|
_, err := col.DeleteOne(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - DeleteOne", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when delete permission: %s", err.Error())
|
return fmt.Errorf("error when delete permission: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findOneAndDelete(ctx context.Context, cond interface{}) (doc model.DBPermission, err error) {
|
||||||
|
var (
|
||||||
|
col = database.GetPermissionCol()
|
||||||
|
)
|
||||||
|
err = col.FindOneAndDelete(ctx, cond).Decode(&doc)
|
||||||
|
if err != nil {
|
||||||
|
return doc, fmt.Errorf("error when findOneAndDelete permission: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func findByCondition(ctx context.Context, cond interface{}, opts ...*options.FindOptions) (docs []model.DBPermission) {
|
func findByCondition(ctx context.Context, cond interface{}, opts ...*options.FindOptions) (docs []model.DBPermission) {
|
||||||
var (
|
var (
|
||||||
col = database.GetPermissionCol()
|
col = database.GetPermissionCol()
|
||||||
|
@ -78,20 +78,10 @@ func findByCondition(ctx context.Context, cond interface{}, opts ...*options.Fin
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - Find", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - Permission - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -104,10 +94,7 @@ func countByCondition(ctx context.Context, cond interface{}) int64 {
|
||||||
)
|
)
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - CountDocuments", logger.LogData{
|
log.Println("permission - countByCondition", err)
|
||||||
"err": err.Error(),
|
|
||||||
"cond": cond,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
@ -122,10 +109,6 @@ func isPermissionIDExisted(ctx context.Context, permissionID primitive.ObjectID)
|
||||||
}
|
}
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - CountDocuments", logger.LogData{
|
|
||||||
"condition": cond,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return total != 0
|
return total != 0
|
||||||
|
|
|
@ -6,9 +6,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/mongodb"
|
"git.selly.red/Selly-Modules/mongodb"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/internal"
|
"git.selly.red/Selly-Modules/usermngmt/internal"
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create ...
|
// Create ...
|
||||||
|
@ -117,6 +118,25 @@ func Delete(permissionID string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FindByIDAndDelete(permissionID string) (*model.Permission, error) {
|
||||||
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
|
)
|
||||||
|
|
||||||
|
// Find permissionID exists or not
|
||||||
|
id, isValid := mongodb.NewIDFromString(permissionID)
|
||||||
|
if !isValid {
|
||||||
|
return nil, errors.New(internal.ErrorInvalidPermission)
|
||||||
|
}
|
||||||
|
cond := bson.M{"_id": id}
|
||||||
|
doc, err := findOneAndDelete(ctx, cond)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res := getResponse(doc)
|
||||||
|
return &res, nil
|
||||||
|
}
|
||||||
|
|
||||||
// All ...
|
// All ...
|
||||||
func All(queryParams model.PermissionAllQuery) (r model.PermissionAll) {
|
func All(queryParams model.PermissionAllQuery) (r model.PermissionAll) {
|
||||||
var (
|
var (
|
||||||
|
@ -157,16 +177,20 @@ func All(queryParams model.PermissionAllQuery) (r model.PermissionAll) {
|
||||||
func getResponseList(permissions []model.DBPermission) []model.Permission {
|
func getResponseList(permissions []model.DBPermission) []model.Permission {
|
||||||
res := make([]model.Permission, 0)
|
res := make([]model.Permission, 0)
|
||||||
for _, permission := range permissions {
|
for _, permission := range permissions {
|
||||||
res = append(res, model.Permission{
|
res = append(res, getResponse(permission))
|
||||||
ID: permission.ID.Hex(),
|
|
||||||
Name: permission.Name,
|
|
||||||
Code: permission.Code,
|
|
||||||
RoleID: permission.RoleID.Hex(),
|
|
||||||
Desc: permission.Desc,
|
|
||||||
CreatedAt: permission.CreatedAt,
|
|
||||||
UpdatedAt: permission.UpdatedAt,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getResponse(permission model.DBPermission) model.Permission {
|
||||||
|
return model.Permission{
|
||||||
|
ID: permission.ID.Hex(),
|
||||||
|
Name: permission.Name,
|
||||||
|
Code: permission.Code,
|
||||||
|
RoleID: permission.RoleID.Hex(),
|
||||||
|
Desc: permission.Desc,
|
||||||
|
CreatedAt: permission.CreatedAt,
|
||||||
|
UpdatedAt: permission.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
36
role/db.go
36
role/db.go
|
@ -3,13 +3,14 @@ package role
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/database"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/database"
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func create(ctx context.Context, doc model.DBRole) error {
|
func create(ctx context.Context, doc model.DBRole) error {
|
||||||
|
@ -18,10 +19,6 @@ func create(ctx context.Context, doc model.DBRole) error {
|
||||||
)
|
)
|
||||||
_, err := col.InsertOne(ctx, doc)
|
_, err := col.InsertOne(ctx, doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - InsertOne", logger.LogData{
|
|
||||||
"doc": doc,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when create role: %s", err.Error())
|
return fmt.Errorf("error when create role: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +31,6 @@ func updateOneByCondition(ctx context.Context, cond interface{}, payload interfa
|
||||||
)
|
)
|
||||||
_, err := col.UpdateOne(ctx, cond, payload)
|
_, err := col.UpdateOne(ctx, cond, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - UpdateOne", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"payload": payload,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when update role: %s", err.Error())
|
return fmt.Errorf("error when update role: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,20 +45,11 @@ func findByCondition(ctx context.Context, cond interface{}, opts ...*options.Fin
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - Find", logger.LogData{
|
log.Printf("usermngmt.findByCondition - Role - Find cond: %v, opts: %v\n", cond, opts)
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - Role - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -79,10 +62,7 @@ func countByCondition(ctx context.Context, cond interface{}) int64 {
|
||||||
)
|
)
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - CountDocuments", logger.LogData{
|
log.Println("usermngmt.countByCondition - Role: ", err)
|
||||||
"err": err.Error(),
|
|
||||||
"cond": cond,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
@ -97,10 +77,6 @@ func isRoleIDExisted(ctx context.Context, roleID primitive.ObjectID) bool {
|
||||||
}
|
}
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - CountDocuments", logger.LogData{
|
|
||||||
"condition": cond,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return total != 0
|
return total != 0
|
||||||
|
|
84
user/db.go
84
user/db.go
|
@ -3,13 +3,14 @@ package user
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/database"
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/database"
|
||||||
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isPhoneNumberExisted(ctx context.Context, phone string) bool {
|
func isPhoneNumberExisted(ctx context.Context, phone string) bool {
|
||||||
|
@ -23,10 +24,6 @@ func isPhoneNumberExisted(ctx context.Context, phone string) bool {
|
||||||
}
|
}
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - User - CountDocuments", logger.LogData{
|
|
||||||
"condition": cond,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return total != 0
|
return total != 0
|
||||||
|
@ -43,10 +40,6 @@ func isEmailExisted(ctx context.Context, email string) bool {
|
||||||
}
|
}
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - User - CountDocuments", logger.LogData{
|
|
||||||
"condition": cond,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return total != 0
|
return total != 0
|
||||||
|
@ -62,10 +55,7 @@ func isRoleExisted(ctx context.Context, roleID primitive.ObjectID) bool {
|
||||||
}
|
}
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - CountDocuments", logger.LogData{
|
log.Println("isRoleExisted - count: ", err)
|
||||||
"condition": cond,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return total != 0
|
return total != 0
|
||||||
}
|
}
|
||||||
|
@ -87,20 +77,10 @@ func roleFindByCondition(ctx context.Context, cond interface{}, opts ...*options
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Role - Find", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - Role - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -114,50 +94,21 @@ func permissionFindByCondition(ctx context.Context, cond interface{}, opts ...*o
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Permission - Find", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - Permission - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// permissionCountByCondition ...
|
|
||||||
func permissionCountByCondition(ctx context.Context, cond interface{}) int64 {
|
|
||||||
var (
|
|
||||||
col = database.GetPermissionCol()
|
|
||||||
)
|
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("usermngmt - Permission - CountDocuments", logger.LogData{
|
|
||||||
"err": err.Error(),
|
|
||||||
"cond": cond,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return total
|
|
||||||
}
|
|
||||||
|
|
||||||
func create(ctx context.Context, doc model.DBUser) error {
|
func create(ctx context.Context, doc model.DBUser) error {
|
||||||
var (
|
var (
|
||||||
col = database.GetUserCol()
|
col = database.GetUserCol()
|
||||||
)
|
)
|
||||||
_, err := col.InsertOne(ctx, doc)
|
_, err := col.InsertOne(ctx, doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - User - InsertOne", logger.LogData{
|
|
||||||
"doc": doc,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when create user: %s", err.Error())
|
return fmt.Errorf("error when create user: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,11 +121,6 @@ func updateOneByCondition(ctx context.Context, cond interface{}, payload interfa
|
||||||
)
|
)
|
||||||
_, err := col.UpdateOne(ctx, cond, payload)
|
_, err := col.UpdateOne(ctx, cond, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - User - UpdateOne", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"payload": payload,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when update user: %s", err.Error())
|
return fmt.Errorf("error when update user: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,11 +133,6 @@ func updateManyByCondition(ctx context.Context, cond interface{}, payload interf
|
||||||
)
|
)
|
||||||
_, err := col.UpdateMany(ctx, cond, payload)
|
_, err := col.UpdateMany(ctx, cond, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - User - UpdateMany", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"payload": payload,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return fmt.Errorf("error when update user: %s", err.Error())
|
return fmt.Errorf("error when update user: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,20 +156,10 @@ func findByCondition(ctx context.Context, cond interface{}, opts ...*options.Fin
|
||||||
|
|
||||||
cursor, err := col.Find(ctx, cond, opts...)
|
cursor, err := col.Find(ctx, cond, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - User - Find", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer cursor.Close(ctx)
|
defer cursor.Close(ctx)
|
||||||
if err = cursor.All(ctx, &docs); err != nil {
|
if err = cursor.All(ctx, &docs); err != nil {
|
||||||
logger.Error("usermngmt - User - Decode", logger.LogData{
|
|
||||||
"cond": cond,
|
|
||||||
"opts": opts,
|
|
||||||
"err": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -241,10 +172,7 @@ func countByCondition(ctx context.Context, cond interface{}) int64 {
|
||||||
)
|
)
|
||||||
total, err := col.CountDocuments(ctx, cond)
|
total, err := col.CountDocuments(ctx, cond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("usermngmt - Count", logger.LogData{
|
log.Println("user - countByCondition err:", err)
|
||||||
"err": err.Error(),
|
|
||||||
"cond": cond,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,15 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/mongodb"
|
"git.selly.red/Selly-Modules/mongodb"
|
||||||
|
"github.com/thoas/go-funk"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/cache"
|
"git.selly.red/Selly-Modules/usermngmt/cache"
|
||||||
"git.selly.red/Selly-Modules/usermngmt/config"
|
"git.selly.red/Selly-Modules/usermngmt/config"
|
||||||
"git.selly.red/Selly-Modules/usermngmt/internal"
|
"git.selly.red/Selly-Modules/usermngmt/internal"
|
||||||
"git.selly.red/Selly-Modules/usermngmt/model"
|
"git.selly.red/Selly-Modules/usermngmt/model"
|
||||||
"github.com/thoas/go-funk"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create ...
|
// Create ...
|
||||||
|
@ -278,11 +278,6 @@ func GetUsersByPermission(queryParams model.UserByPermissionQuery) (r model.User
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountByCondition ...
|
|
||||||
func CountByCondition(filter interface{}) int64 {
|
|
||||||
return countByCondition(context.Background(), filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count ...
|
// Count ...
|
||||||
func Count(queryParams model.UserCountQuery) int64 {
|
func Count(queryParams model.UserCountQuery) int64 {
|
||||||
var (
|
var (
|
||||||
|
@ -413,10 +408,6 @@ func ChangeUserPassword(userID string, opt model.ChangePasswordOptions) error {
|
||||||
|
|
||||||
// Validate userID
|
// Validate userID
|
||||||
if _, isValid := mongodb.NewIDFromString(userID); !isValid {
|
if _, isValid := mongodb.NewIDFromString(userID); !isValid {
|
||||||
logger.Error("usermngmt - ChangePassword: invalid userID data", logger.LogData{
|
|
||||||
"payload": opt,
|
|
||||||
"userID": userID,
|
|
||||||
})
|
|
||||||
return errors.New(internal.ErrorInvalidUser)
|
return errors.New(internal.ErrorInvalidUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,16 +578,22 @@ func ChangeAllUsersStatus(roleID, status string) error {
|
||||||
// LoginWithEmailAndPassword ...
|
// LoginWithEmailAndPassword ...
|
||||||
func LoginWithEmailAndPassword(email, password string) (result model.User, err error) {
|
func LoginWithEmailAndPassword(email, password string) (result model.User, err error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
|
numOfLoginFail int
|
||||||
)
|
)
|
||||||
|
k := cache.KeyLoginFailedTimes + email
|
||||||
|
// process block if reach maximum of login failed
|
||||||
|
if ok := cache.GetJSON(k, &numOfLoginFail); ok && numOfLoginFail >= config.MaximumLoginFailedTime {
|
||||||
|
return model.User{}, errors.New(internal.ErrorExceedMaximumLoginFail)
|
||||||
|
}
|
||||||
|
|
||||||
// Validate email, password
|
// Validate email, password
|
||||||
if email == "" {
|
if email == "" {
|
||||||
err = errors.New(internal.ErrorInvalidEmail)
|
err = errors.New(internal.ErrorInvalidLogin)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if password == "" {
|
if password == "" {
|
||||||
err = errors.New(internal.ErrorInvalidPassword)
|
err = errors.New(internal.ErrorInvalidLogin)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,13 +603,14 @@ func LoginWithEmailAndPassword(email, password string) (result model.User, err e
|
||||||
"deleted": false,
|
"deleted": false,
|
||||||
})
|
})
|
||||||
if user.ID.IsZero() {
|
if user.ID.IsZero() {
|
||||||
err = errors.New(internal.ErrorNotFoundUser)
|
err = errors.New(internal.ErrorInvalidLogin)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Password
|
// Check Password
|
||||||
if !internal.CheckPasswordHash(password, user.HashedPassword) {
|
if !internal.CheckPasswordHash(password, user.HashedPassword) {
|
||||||
err = errors.New(internal.ErrorIncorrectPassword)
|
err = errors.New(internal.ErrorInvalidLogin)
|
||||||
|
cache.SetKeyValue(k, numOfLoginFail+1, config.LoginFailedBlockedDuration)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,28 +626,16 @@ func HasPermission(userID, permission string) (result bool) {
|
||||||
|
|
||||||
// Validate userID, permission
|
// Validate userID, permission
|
||||||
if userID == "" || permission == "" {
|
if userID == "" || permission == "" {
|
||||||
logger.Error("usermngmt - HasPermission: email or password cannot be empty", logger.LogData{
|
|
||||||
"userID": userID,
|
|
||||||
"permission": permission,
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id, isValid := mongodb.NewIDFromString(userID)
|
id, isValid := mongodb.NewIDFromString(userID)
|
||||||
if !isValid {
|
if !isValid {
|
||||||
logger.Error("usermngmt - HasPermission: invalid user id", logger.LogData{
|
|
||||||
"userID": userID,
|
|
||||||
"permission": permission,
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find user
|
// Find user
|
||||||
user, _ := findByID(ctx, id)
|
user, _ := findByID(ctx, id)
|
||||||
if user.ID.IsZero() {
|
if user.ID.IsZero() {
|
||||||
logger.Error("usermngmt - HasPermission: user not found", logger.LogData{
|
|
||||||
"userID": userID,
|
|
||||||
"permission": permission,
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
usermngmt.go
13
usermngmt.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/logger"
|
|
||||||
"git.selly.red/Selly-Modules/mongodb"
|
"git.selly.red/Selly-Modules/mongodb"
|
||||||
|
|
||||||
"git.selly.red/Selly-Modules/usermngmt/cache"
|
"git.selly.red/Selly-Modules/usermngmt/cache"
|
||||||
|
@ -61,8 +60,6 @@ func Init(config Config) (*Service, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Init(fmt.Sprintf("%s-usermngmt", config.TablePrefix), "")
|
|
||||||
|
|
||||||
// Set database
|
// Set database
|
||||||
database.Set(db, config.TablePrefix)
|
database.Set(db, config.TablePrefix)
|
||||||
|
|
||||||
|
@ -86,3 +83,13 @@ func Init(config Config) (*Service, error) {
|
||||||
func GetInstance() *Service {
|
func GetInstance() *Service {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetConnectOptions ...
|
||||||
|
func GetConnectOptions(Host, DBName string) mongodb.Config {
|
||||||
|
return mongodb.Config{
|
||||||
|
Host: Host,
|
||||||
|
DBName: DBName,
|
||||||
|
Standalone: &mongodb.ConnectStandaloneOpts{},
|
||||||
|
TLS: &mongodb.ConnectTLSOpts{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue