feat(channel): 支持安全删除渠道并保留历史数据
CI / Frontend (typecheck + lint + build) (push) Successful in 5m31s
CI / Backend (go vet + test) (push) Failing after 11m10s

This commit is contained in:
yml2213
2026-11-06 18:36:07 +08:00
parent 6297ea6634
commit de1ffbf4f6
10 changed files with 135 additions and 23 deletions
+16
View File
@@ -152,6 +152,22 @@ func (h *ChannelHandler) Update(c *gin.Context) {
middleware.JSON(c, toChannelView(channel))
}
func (h *ChannelHandler) Delete(c *gin.Context) {
if !requireTenantAdmin(c) {
return
}
var channel model.Channel
if err := model.DB.Where("id = ? AND tenant_id = ?", c.Param("id"), middleware.GetTenantID(c)).First(&channel).Error; err != nil {
c.JSON(http.StatusNotFound, gin.H{"code": 404, "message": "渠道不存在"})
return
}
if err := model.DB.Delete(&channel).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"code": 500, "message": "删除失败"})
return
}
middleware.JSON(c, gin.H{"id": channel.ID, "deleted": true})
}
type createChannelReq struct {
Type string `json:"type" binding:"required"`
Name string `json:"name"`