feat(channel): implement multi-key mode handling and improve channel update logic

This commit is contained in:
CaIon
2025-07-11 21:12:17 +08:00
parent cd8c23c0ab
commit 85efea3fb8
5 changed files with 192 additions and 86 deletions

View File

@@ -718,8 +718,13 @@ func DeleteChannelBatch(c *gin.Context) {
return
}
type PatchChannel struct {
model.Channel
MultiKeyMode *string `json:"multi_key_mode"`
}
func UpdateChannel(c *gin.Context) {
channel := model.Channel{}
channel := PatchChannel{}
err := c.ShouldBindJSON(&channel)
if err != nil {
c.JSON(http.StatusOK, gin.H{
@@ -761,6 +766,19 @@ func UpdateChannel(c *gin.Context) {
}
}
}
if channel.MultiKeyMode != nil && *channel.MultiKeyMode != "" {
originChannel, err := model.GetChannelById(channel.Id, false)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": err.Error(),
})
}
if originChannel.ChannelInfo.IsMultiKey {
channel.ChannelInfo = originChannel.ChannelInfo
channel.ChannelInfo.MultiKeyMode = constant.MultiKeyMode(*channel.MultiKeyMode)
}
}
err = channel.Update()
if err != nil {
c.JSON(http.StatusOK, gin.H{