refactor: update setting routes and enhance dependency management

- Changed route parameter from ':id' to ':key' in settings-related routes for better clarity and consistency.
- Updated GetSetting, PostSetting, and PutSetting functions to use the new ':key' parameter.
- Introduced IsAutoInstallEnabled method in DependencyInstallerService to check auto-installation status.
- Enhanced the task runner to check if auto installation is enabled before proceeding with dependency installation.
- Improved initialization of settings data in the system service, ensuring proper insertion of initial settings.
This commit is contained in:
Marvin Zhang
2025-01-01 22:37:44 +08:00
parent b056105246
commit 47094b8e64
5 changed files with 44 additions and 25 deletions

View File

@@ -339,17 +339,17 @@ func InitRoutes(app *gin.Engine) (err error) {
RegisterActions(groups.AuthGroup, "/settings", []Action{
{
Method: http.MethodGet,
Path: "/:id",
Path: "/:key",
HandlerFunc: GetSetting,
},
{
Method: http.MethodPost,
Path: "/:id",
Path: "/:key",
HandlerFunc: PostSetting,
},
{
Method: http.MethodPut,
Path: "/:id",
Path: "/:key",
HandlerFunc: PutSetting,
},
})

View File

@@ -11,7 +11,7 @@ import (
func GetSetting(c *gin.Context) {
// key
key := c.Param("id")
key := c.Param("key")
// setting
s, err := service.NewModelService[models.Setting]().GetOne(bson.M{"key": key}, nil)
@@ -29,7 +29,7 @@ func GetSetting(c *gin.Context) {
func PostSetting(c *gin.Context) {
// key
key := c.Param("id")
key := c.Param("key")
// settings
var s models.Setting
@@ -59,7 +59,7 @@ func PostSetting(c *gin.Context) {
func PutSetting(c *gin.Context) {
// key
key := c.Param("id")
key := c.Param("key")
// settings
var s models.Setting