1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-11-03 04:27:16 -05:00

Fix #57, introduce null.* types

This commit is contained in:
マリウス 2024-07-31 17:47:17 -05:00
parent e37b59f0df
commit 666e201dcc
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
4 changed files with 19 additions and 14 deletions

1
go.mod
View File

@ -44,6 +44,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/guregu/null v4.0.0+incompatible // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect

2
go.sum
View File

@ -77,6 +77,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/guregu/null v4.0.0+incompatible h1:4zw0ckM7ECd6FNNddc3Fu4aty9nTlpkkzH7dPn4/4Gw=
github.com/guregu/null v4.0.0+incompatible/go.mod h1:ePGpQaN9cw0tj45IR5E5ehMvsFlLlQZAkkOXZurJ3NM=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=

View File

@ -3,6 +3,8 @@ package api
import (
"context"
"net/http"
"github.com/guregu/null"
)
const CategoriesBaseURL = "/categories"
@ -25,21 +27,21 @@ type CategoryModel struct {
TopicCount int `json:"topic_count"`
PostCount int `json:"post_count"`
Position int `json:"position"`
Description string `json:"description",omitempty`
DescriptionText string `json:"description_text",omitempty`
DescriptionExcerpt string `json:"description_excerpt",omitempty`
TopicUrl string `json:"topic_url",omitempty`
Description null.String `json:"description",omitempty`
DescriptionText null.String `json:"description_text",omitempty`
DescriptionExcerpt null.String `json:"description_excerpt",omitempty`
TopicUrl null.String `json:"topic_url",omitempty`
ReadRestricted bool `json:"read_restricted"`
Permission int `json:"permission",omitempty`
Permission null.Int `json:"permission",omitempty`
NotificationLevel int `json:"notification_level"`
CanEdit bool `json:"can_edit"`
TopicTemplate string `json:"topic_template",omitempty`
HasChildren bool `json:"has_children",omitempty`
SortOrder string `json:"sort_order",omitempty`
SortAscending bool `json:"sort_ascending",omitempty`
TopicTemplate null.String `json:"topic_template",omitempty`
HasChildren null.Bool `json:"has_children",omitempty`
SortOrder null.String `json:"sort_order",omitempty`
SortAscending null.Bool `json:"sort_ascending",omitempty`
ShowSubcategoryList bool `json:"show_subcategory_list"`
NumFeaturedTopics int `json:"num_featured_topics"`
DefaultView string `json:"default_view",omitempty`
DefaultView null.String `json:"default_view",omitempty`
SubcategoryListStyle string `json:"subcategory_list_style"`
DefaultTopPeriod string `json:"default_top_period"`
DefaultListFilter string `json:"default_list_filter"`
@ -53,9 +55,9 @@ type CategoryModel struct {
IsUncategorized bool `json:"is_uncategorized"`
SubcategoryIDs []int `json:"subcategory_ids"`
SubcategoryList []CategoryModel `json:"subcategory_list"`
UploadedLogo string `json:"uploaded_logo",omitempty`
UploadedLogoDark string `json:"uploaded_logo_dark",omitempty`
UploadedBackground string `json:"uploaded_background",omitempty`
UploadedLogo null.String `json:"uploaded_logo",omitempty`
UploadedLogoDark null.String `json:"uploaded_logo_dark",omitempty`
UploadedBackground null.String `json:"uploaded_background",omitempty`
}
type CategoriesService interface {

View File

@ -152,7 +152,7 @@ func (sys *System) recurseForums(cats *[]api.CategoryModel, parent *forum.Forum)
ID: strconv.Itoa((*cats)[i].ID),
Name: name,
Info: (*cats)[i].Description,
Info: (*cats)[i].Description.String,
SysIDX: sys.ID,
}