remove slice pointers
This commit is contained in:
parent
543b39f822
commit
a774338ccd
3 changed files with 7 additions and 7 deletions
|
|
@ -20,7 +20,7 @@ var (
|
||||||
|
|
||||||
// AccountStore defines database operations for account management.
|
// AccountStore defines database operations for account management.
|
||||||
type AccountStore interface {
|
type AccountStore interface {
|
||||||
List(f auth.AccountFilter) (*[]auth.Account, int, error)
|
List(f auth.AccountFilter) ([]auth.Account, int, error)
|
||||||
Create(*auth.Account) error
|
Create(*auth.Account) error
|
||||||
Get(id int) (*auth.Account, error)
|
Get(id int) (*auth.Account, error)
|
||||||
Update(*auth.Account) error
|
Update(*auth.Account) error
|
||||||
|
|
@ -87,11 +87,11 @@ func newAccountResponse(a *auth.Account) *accountResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
type accountListResponse struct {
|
type accountListResponse struct {
|
||||||
Accounts *[]auth.Account `json:"accounts"`
|
Accounts []auth.Account `json:"accounts"`
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAccountListResponse(a *[]auth.Account, count int) *accountListResponse {
|
func newAccountListResponse(a []auth.Account, count int) *accountListResponse {
|
||||||
resp := &accountListResponse{
|
resp := &accountListResponse{
|
||||||
Accounts: a,
|
Accounts: a,
|
||||||
Count: count,
|
Count: count,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type Account struct {
|
||||||
Active bool `sql:",notnull" json:"active"`
|
Active bool `sql:",notnull" json:"active"`
|
||||||
Roles []string `pg:",array" json:"roles,omitempty"`
|
Roles []string `pg:",array" json:"roles,omitempty"`
|
||||||
|
|
||||||
Token []*Token `json:"token,omitempty"`
|
Token []Token `json:"token,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeforeInsert hook executed before database insert operation.
|
// BeforeInsert hook executed before database insert operation.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func NewAdmAccountStore(db *pg.DB) *AdmAccountStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
// List applies a filter and returns paginated array of matching results and total count.
|
// List applies a filter and returns paginated array of matching results and total count.
|
||||||
func (s *AdmAccountStore) List(f auth.AccountFilter) (*[]auth.Account, int, error) {
|
func (s *AdmAccountStore) List(f auth.AccountFilter) ([]auth.Account, int, error) {
|
||||||
a := []auth.Account{}
|
a := []auth.Account{}
|
||||||
count, err := s.db.Model(&a).
|
count, err := s.db.Model(&a).
|
||||||
Apply(f.Filter).
|
Apply(f.Filter).
|
||||||
|
|
@ -34,7 +34,7 @@ func (s *AdmAccountStore) List(f auth.AccountFilter) (*[]auth.Account, int, erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
return &a, count, nil
|
return a, count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates a new account.
|
// Create creates a new account.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue