Skip to content

Commit 2326a95

Browse files
committed
Fix settings data
1 parent 93721ef commit 2326a95

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

backend/embed/api_docs/components/SettingObject.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
"type": "object",
33
"description": "SettingObject",
44
"additionalProperties": false,
5-
"required": [
6-
"id",
7-
"name",
8-
"value"
9-
],
5+
"required": ["id", "name", "value"],
106
"properties": {
117
"id": {
128
"type": "integer",
@@ -25,6 +21,11 @@
2521
"minLength": 2,
2622
"maxLength": 100
2723
},
24+
"description": {
25+
"type": "string",
26+
"minLength": 0,
27+
"maxLength": 100
28+
},
2829
"value": {
2930
"oneOf": [
3031
{
@@ -38,8 +39,11 @@
3839
},
3940
{
4041
"type": "integer"
42+
},
43+
{
44+
"type": "string"
4145
}
4246
]
4347
}
4448
}
45-
}
49+
}

backend/embed/migrations/20201013035318_initial_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `setting`
3232
created_on INTEGER NOT NULL DEFAULT 0,
3333
modified_on INTEGER NOT NULL DEFAULT 0,
3434
name TEXT NOT NULL,
35-
description TEXT NOT NULL,
35+
description TEXT NOT NULL DEFAULT "",
3636
value TEXT NOT NULL,
3737
UNIQUE (name)
3838
);

backend/embed/migrations/20201013035839_initial_data.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ INSERT INTO `setting` (
1111
strftime('%s', 'now'),
1212
strftime('%s', 'now'),
1313
"error-reporting",
14-
"If enabled, any application errors are reported to Sentry. Sensitive information is not sent. All information sent is also private.",
15-
"true"
14+
"If enabled, any application errors are reported to Sentry. Sensitive information is not sent.",
15+
"true" -- remember this is json
1616
);
1717

1818
-- Default site
@@ -27,7 +27,7 @@ INSERT INTO `setting` (
2727
strftime('%s', 'now'),
2828
"default-site",
2929
"What to show users who hit your Nginx server by default",
30-
"welcome"
30+
'"welcome"' -- remember this is json
3131
);
3232

3333
-- Default Certificate Authorities

backend/internal/entity/setting/methods.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"npm/internal/database"
99
"npm/internal/entity"
1010
"npm/internal/errors"
11+
"npm/internal/logger"
1112
"npm/internal/model"
1213
)
1314

@@ -100,6 +101,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (ListResponse, error)
100101
var totalRows int
101102
queryErr := countRow.Scan(&totalRows)
102103
if queryErr != nil && queryErr != sql.ErrNoRows {
104+
logger.Debug("%+v", queryErr)
103105
return result, queryErr
104106
}
105107

@@ -108,6 +110,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (ListResponse, error)
108110
query, params = entity.ListQueryBuilder(exampleModel, tableName, &pageInfo, defaultSort, filters, getFilterMapFunctions(), false)
109111
err := db.Select(&items, query, params...)
110112
if err != nil {
113+
logger.Debug("%+v", err)
111114
return result, err
112115
}
113116

backend/internal/entity/setting/structs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"npm/internal/model"
55
)
66

7-
// ListResponse is the JSON response for users list
7+
// ListResponse is the JSON response for settings list
88
type ListResponse struct {
99
Total int `json:"total"`
1010
Offset int `json:"offset"`

0 commit comments

Comments
 (0)