More work on portfolio
This commit is contained in:
@@ -157,3 +157,27 @@ Return:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Portfolio
|
||||||
|
|
||||||
|
#### Get Projects
|
||||||
|
|
||||||
|
> GET: /portfolio?lang=go
|
||||||
|
|
||||||
|
Return:
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
title: "title",
|
||||||
|
repository: "https://github.com/CalebQ42/darkstorm-server",
|
||||||
|
description: "The backend that runs runs my website and APIs",
|
||||||
|
language: [
|
||||||
|
{
|
||||||
|
language: "go",
|
||||||
|
dates: "September 2021"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ type BlogApp struct {
|
|||||||
back *backend.Backend
|
back *backend.Backend
|
||||||
blogCol *mongo.Collection
|
blogCol *mongo.Collection
|
||||||
authCol *mongo.Collection
|
authCol *mongo.Collection
|
||||||
|
portfolioCol *mongo.Collection
|
||||||
conv *bbConvert.HTMLConverter
|
conv *bbConvert.HTMLConverter
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ func NewBlogApp(b *backend.Backend, db *mongo.Database, mux *http.ServeMux) *Blo
|
|||||||
back: b,
|
back: b,
|
||||||
blogCol: db.Collection("blog"),
|
blogCol: db.Collection("blog"),
|
||||||
authCol: db.Collection("author"),
|
authCol: db.Collection("author"),
|
||||||
|
portfolioCol: db.Collection("portfolio"),
|
||||||
conv: &bbConvert.HTMLConverter{},
|
conv: &bbConvert.HTMLConverter{},
|
||||||
}
|
}
|
||||||
out.conv.ImplementDefaults()
|
out.conv.ImplementDefaults()
|
||||||
@@ -33,6 +35,8 @@ func NewBlogApp(b *backend.Backend, db *mongo.Database, mux *http.ServeMux) *Blo
|
|||||||
mux.HandleFunc("GET /author/{authorID}", out.reqAuthorInfo)
|
mux.HandleFunc("GET /author/{authorID}", out.reqAuthorInfo)
|
||||||
mux.HandleFunc("POST /author", out.addAuthorInfo)
|
mux.HandleFunc("POST /author", out.addAuthorInfo)
|
||||||
mux.HandleFunc("POST /author/{authorID}", out.updateAuthorInfo)
|
mux.HandleFunc("POST /author/{authorID}", out.updateAuthorInfo)
|
||||||
|
|
||||||
|
mux.HandleFunc("GET /portfolio", out.reqPortfolio)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package blog
|
package blog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type project struct {
|
type PortfolioProject struct {
|
||||||
Title string `bson:"_id"`
|
Title string `bson:"_id"`
|
||||||
Repository string `bson:"respository"`
|
Repository string `bson:"repository"`
|
||||||
Description string `bson:"description"`
|
Description string `bson:"description"`
|
||||||
Languages []struct {
|
Languages []struct {
|
||||||
Language string `bson:"language"`
|
Language string `bson:"language"`
|
||||||
@@ -14,6 +17,20 @@ type project struct {
|
|||||||
} `bson:"language"`
|
} `bson:"language"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func portfolio(client *mongo.Client) {
|
func (b *BlogApp) Projects(languageFilter string) ([]PortfolioProject, error) {
|
||||||
|
filter := bson.M{}
|
||||||
|
if languageFilter != "" {
|
||||||
|
filter["language.language"] = languageFilter
|
||||||
|
}
|
||||||
|
res, err := b.portfolioCol.Find(context.Background(), filter)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var out []PortfolioProject
|
||||||
|
err = res.All(context.Background(), &out)
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BlogApp) reqPortfolio(w http.ResponseWriter, r *http.Request) {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user