add GetComments and update proto
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgtype"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ListPackage []*Package
|
||||
@@ -42,3 +44,28 @@ func (l ListModule) Decode() []*pb.Module {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
type ListComment []*Comment
|
||||
|
||||
func (l ListComment) Decode() []*pb.Comment {
|
||||
result := make([]*pb.Comment, 0, len(l))
|
||||
for i := range l {
|
||||
temp := &pb.Comment{
|
||||
Id: l[i].ID,
|
||||
//Package: l[i].,
|
||||
Text: l[i].Text,
|
||||
}
|
||||
|
||||
if l[i].Created.Status == pgtype.Present {
|
||||
temp.Created = l[i].Created.Time.Format(time.DateTime)
|
||||
}
|
||||
|
||||
if l[i].Updated.Status == pgtype.Present {
|
||||
temp.Updated = l[i].Updated.Time.Format(time.DateTime)
|
||||
}
|
||||
|
||||
result = append(result, temp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
Reference in New Issue
Block a user