feat: server group api

This commit is contained in:
naiba
2024-10-21 23:00:51 +08:00
parent 5efd995992
commit 9c08ebe956
9 changed files with 223 additions and 43 deletions

View File

@@ -81,20 +81,20 @@ func newDDNS(c *gin.Context) error {
// @Description Edit DDNS profile
// @Tags auth required
// @Accept json
// @param id path string true "Profile ID"
// @param request body model.DDNSForm true "DDNS Request"
// @Produce json
// @Success 200 {object} model.CommonResponse[any]
// @Router /ddns/{id} [patch]
func editDDNS(c *gin.Context) error {
var df model.DDNSForm
var p model.DDNSProfile
idStr := c.Param("id")
id, err := strconv.ParseUint(idStr, 10, 64)
if err != nil {
return err
}
var df model.DDNSForm
if err := c.ShouldBindJSON(&df); err != nil {
return err
}
@@ -103,6 +103,11 @@ func editDDNS(c *gin.Context) error {
return errors.New("重试次数必须为大于 1 且不超过 10 的整数")
}
var p model.DDNSProfile
if err = singleton.DB.First(&p, id).Error; err != nil {
return newGormError("%v", err)
}
p.Name = df.Name
p.ID = id
enableIPv4 := df.EnableIPv4 == "on"