46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
|
package routers
|
|||
|
|
|||
|
import (
|
|||
|
"github.com/gin-gonic/gin"
|
|||
|
"strings"
|
|||
|
"wechathook/models"
|
|||
|
)
|
|||
|
|
|||
|
func GetSetting(c *gin.Context) {
|
|||
|
reply, _ := models.FindSettingList()
|
|||
|
c.JSON(200, reply)
|
|||
|
}
|
|||
|
func PostSetting(c *gin.Context) {
|
|||
|
apiBase := c.PostForm("apiBase")
|
|||
|
openaiBase := c.PostForm("openaiBase")
|
|||
|
openaiKey := c.PostForm("openaiKey")
|
|||
|
openaiModel := c.PostForm("openaiModel")
|
|||
|
replyTemplate := c.PostForm("replyTemplate")
|
|||
|
wechatPort := c.PostForm("wechatPort")
|
|||
|
keywords := c.PostForm("keywords")
|
|||
|
keywords = strings.Replace(keywords, ":", ":", -1)
|
|||
|
finalReply := c.PostForm("finalReply")
|
|||
|
loopSpeaks := c.PostForm("loopSpeaks")
|
|||
|
delayTime := c.PostForm("delayTime")
|
|||
|
models.AddSetting("微信端口", "wechatPort", wechatPort)
|
|||
|
models.AddSetting("接口地址", "apiBase", apiBase)
|
|||
|
models.AddSetting("大模型接口地址", "openaiBase", openaiBase)
|
|||
|
models.AddSetting("大模型接口KEY", "openaiKey", openaiKey)
|
|||
|
models.AddSetting("大模型名称", "openaiModel", openaiModel)
|
|||
|
models.AddSetting("关键词话术", "keywords", keywords)
|
|||
|
models.AddSetting("兜底回复", "finalReply", finalReply)
|
|||
|
models.AddSetting("回复内容模板", "replyTemplate", replyTemplate)
|
|||
|
models.AddSetting("循环话术列表", "loopSpeaks", loopSpeaks)
|
|||
|
models.AddSetting("延迟时间", "delayTime", delayTime)
|
|||
|
reply, _ := models.FindSettingList()
|
|||
|
c.JSON(200, reply)
|
|||
|
}
|
|||
|
func PostSettingByKey(c *gin.Context) {
|
|||
|
key := c.PostForm("key")
|
|||
|
val := c.PostForm("val")
|
|||
|
name := c.PostForm("name")
|
|||
|
models.AddSetting(name, key, val)
|
|||
|
reply, _ := models.FindSettingList()
|
|||
|
c.JSON(200, reply)
|
|||
|
}
|