add handlers, storage(Postgres, sqlite) (#3)
Reviewed-on: #3 Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru> Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
This commit is contained in:
@@ -7,38 +7,39 @@ import (
|
||||
)
|
||||
|
||||
type Package struct {
|
||||
ID int64 `db:"id"` // package id
|
||||
Name string `db:"name"` // service name, last component path
|
||||
URL string `db:"url"` // scm url
|
||||
Modules []Module `db:"modules"` // parsed go.mod modules
|
||||
Issues []Issue `db:"issues"` // issues list
|
||||
Comments []int64 `db:"comments"`
|
||||
ID uint64 `db:"id" json:"id"` // package id
|
||||
Name string `db:"name" json:"name"` // service name, last component path
|
||||
URL string `db:"url" json:"url"` // scm url
|
||||
Modules []uint64 `db:"modules" json:"modules"` // parsed go.mod modules
|
||||
Issues []uint64 `db:"issues" json:"issues,omitempty"` // issues list
|
||||
Comments []uint64 `db:"comments" json:"comments,omitempty"`
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
ID int64 `db:"id"`
|
||||
Name string `db:"name"` // module name
|
||||
Version string `db:"version"` // module
|
||||
Package int64 `db:"package"`
|
||||
ID uint64 `db:"id"`
|
||||
Name string `db:"name"` // module name
|
||||
Version string `db:"version"` // module
|
||||
Package uint64 `db:"package"`
|
||||
LastVersion string `db:"last_version"`
|
||||
}
|
||||
|
||||
type Issue struct {
|
||||
ID int64 `db:"id"`
|
||||
Status int64 `db:"status"`
|
||||
ID uint64 `db:"id"`
|
||||
Status uint64 `db:"status"`
|
||||
Desc string `db:"desc"`
|
||||
Package int64 `db:"package"`
|
||||
Modules []int64 `db:"modules"`
|
||||
}
|
||||
|
||||
type Comment struct {
|
||||
ID int64 `db:"id"`
|
||||
Text string `db:"value"`
|
||||
Created pgtype.Date `db:"created"`
|
||||
Updated pgtype.Date `db:"updated"`
|
||||
ID uint64 `db:"id" json:"id"`
|
||||
Text string `db:"value" json:"text"`
|
||||
Created pgtype.Date `db:"created" json:"created"`
|
||||
Updated pgtype.Date `db:"updated" json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
type Dashboard struct {
|
||||
ID int64 `db:"id"`
|
||||
Uuid uuid.UUID `db:"uuid"`
|
||||
Package int64 `db:"package"`
|
||||
ID uint64 `db:"id"`
|
||||
Uuid uuid.UUID `db:"uuid"`
|
||||
Packages []uint64 `db:"package"`
|
||||
}
|
||||
|
@@ -6,8 +6,39 @@ import (
|
||||
|
||||
type ListPackage []*Package
|
||||
|
||||
func (l ListPackage) Mapping() []*pb.Package {
|
||||
func (l ListPackage) Decode() []*pb.Package {
|
||||
result := make([]*pb.Package, 0, len(l))
|
||||
|
||||
for i := range l {
|
||||
temp := &pb.Package{
|
||||
Id: l[i].ID,
|
||||
Name: l[i].Name,
|
||||
Url: l[i].URL,
|
||||
Modules: l[i].Modules,
|
||||
Issues: l[i].Issues,
|
||||
Comments: l[i].Comments,
|
||||
}
|
||||
|
||||
result = append(result, temp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
type ListModule []*Module
|
||||
|
||||
func (l ListModule) Decode() []*pb.Module {
|
||||
result := make([]*pb.Module, 0, len(l))
|
||||
for i := range l {
|
||||
temp := &pb.Module{
|
||||
Id: l[i].ID,
|
||||
Name: l[i].Name,
|
||||
Version: l[i].Version,
|
||||
LastVersion: l[i].LastVersion,
|
||||
}
|
||||
|
||||
result = append(result, temp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
Reference in New Issue
Block a user