diff --git a/backend/embed/api_docs/components/SettingObject.json b/backend/embed/api_docs/components/SettingObject.json index a7c6e055..60aab614 100644 --- a/backend/embed/api_docs/components/SettingObject.json +++ b/backend/embed/api_docs/components/SettingObject.json @@ -2,11 +2,7 @@ "type": "object", "description": "SettingObject", "additionalProperties": false, - "required": [ - "id", - "name", - "value" - ], + "required": ["id", "name", "value"], "properties": { "id": { "type": "integer", @@ -25,6 +21,11 @@ "minLength": 2, "maxLength": 100 }, + "description": { + "type": "string", + "minLength": 0, + "maxLength": 100 + }, "value": { "oneOf": [ { @@ -38,8 +39,11 @@ }, { "type": "integer" + }, + { + "type": "string" } ] } } -} \ No newline at end of file +} diff --git a/backend/embed/migrations/20201013035318_initial_schema.sql b/backend/embed/migrations/20201013035318_initial_schema.sql index 74195337..672dea23 100644 --- a/backend/embed/migrations/20201013035318_initial_schema.sql +++ b/backend/embed/migrations/20201013035318_initial_schema.sql @@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `setting` created_on INTEGER NOT NULL DEFAULT 0, modified_on INTEGER NOT NULL DEFAULT 0, name TEXT NOT NULL, - description TEXT NOT NULL, + description TEXT NOT NULL DEFAULT "", value TEXT NOT NULL, UNIQUE (name) ); diff --git a/backend/embed/migrations/20201013035839_initial_data.sql b/backend/embed/migrations/20201013035839_initial_data.sql index 97a7df0c..11fd6ae1 100644 --- a/backend/embed/migrations/20201013035839_initial_data.sql +++ b/backend/embed/migrations/20201013035839_initial_data.sql @@ -11,8 +11,8 @@ INSERT INTO `setting` ( strftime('%s', 'now'), strftime('%s', 'now'), "error-reporting", - "If enabled, any application errors are reported to Sentry. Sensitive information is not sent. All information sent is also private.", - "true" + "If enabled, any application errors are reported to Sentry. Sensitive information is not sent.", + "true" -- remember this is json ); -- Default site @@ -27,7 +27,7 @@ INSERT INTO `setting` ( strftime('%s', 'now'), "default-site", "What to show users who hit your Nginx server by default", - "welcome" + '"welcome"' -- remember this is json ); -- Default Certificate Authorities diff --git a/backend/internal/entity/setting/methods.go b/backend/internal/entity/setting/methods.go index 02211a03..51b75177 100644 --- a/backend/internal/entity/setting/methods.go +++ b/backend/internal/entity/setting/methods.go @@ -8,6 +8,7 @@ import ( "npm/internal/database" "npm/internal/entity" "npm/internal/errors" + "npm/internal/logger" "npm/internal/model" ) @@ -100,6 +101,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (ListResponse, error) var totalRows int queryErr := countRow.Scan(&totalRows) if queryErr != nil && queryErr != sql.ErrNoRows { + logger.Debug("%+v", queryErr) return result, queryErr } @@ -108,6 +110,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (ListResponse, error) query, params = entity.ListQueryBuilder(exampleModel, tableName, &pageInfo, defaultSort, filters, getFilterMapFunctions(), false) err := db.Select(&items, query, params...) if err != nil { + logger.Debug("%+v", err) return result, err } diff --git a/backend/internal/entity/setting/structs.go b/backend/internal/entity/setting/structs.go index d585e9a1..ba9851bd 100644 --- a/backend/internal/entity/setting/structs.go +++ b/backend/internal/entity/setting/structs.go @@ -4,7 +4,7 @@ import ( "npm/internal/model" ) -// ListResponse is the JSON response for users list +// ListResponse is the JSON response for settings list type ListResponse struct { Total int `json:"total"` Offset int `json:"offset"`