package controller

import (
	"git.wanbits.cc/sin/flytalk/models"
	"github.com/gin-gonic/gin"
)

func GetConfigs(c *gin.Context) {
	configs := models.FindConfigs()
	c.JSON(200, gin.H{
		"code":   200,
		"msg":    "ok",
		"result": configs,
	})
}

func PostConfig(c *gin.Context) {
	key := c.PostForm("key")
	value := c.PostForm("value")
	if key == "" || value == "" {
		c.JSON(200, gin.H{
			"code": 400,
			"msg":  "error",
		})
		return
	}
	models.UpdateConfig(key, value)

	c.JSON(200, gin.H{
		"code":   200,
		"msg":    "ok",
		"result": "",
	})
}
