UpdateRecordingConfig godoc @Summary 更新录音配置 @Description 更新录音功能开关和解析平台选择 @Tags 录音管理 @Accept json @Produce json @Security BearerAuth @Param request body controller.UpdateRecordingConfigRequest true "配置更新请求" @Success 200 {object} model.CommonResponse @Router /api/admin/recordings/config [put]
(c *gin.Context)
| 80 | // @Success 200 {object} model.CommonResponse |
| 81 | // @Router /api/admin/recordings/config [put] |
| 82 | func UpdateRecordingConfig(c *gin.Context) { |
| 83 | eid := config.GetEID(c) |
| 84 | |
| 85 | var req UpdateRecordingConfigRequest |
| 86 | if err := c.ShouldBindJSON(&req); err != nil { |
| 87 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(err)) |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | if req.Enabled == nil && req.ParserPlatform == nil { |
| 92 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(fmt.Errorf("至少需要一个参数: enabled 或 parser_platform"))) |
| 93 | return |
| 94 | } |
| 95 | |
| 96 | if req.ParserPlatform != nil && *req.ParserPlatform != "" { |
| 97 | if _, ok := model.GetDefaultPlatformSettingDisplayMeta(*req.ParserPlatform); !ok { |
| 98 | c.JSON(http.StatusInternalServerError, model.SystemError.ToErrorResponse(fmt.Errorf("不支持的解析平台: %s", *req.ParserPlatform))) |
| 99 | return |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | svc := service.NewRecordingAdminService(eid) |
| 104 | if err := svc.UpdateRecordingConfig(c, req.Enabled, req.ParserPlatform); err != nil { |
| 105 | logger.SysErrorf("【录音配置】更新失败: eid=%d err=%v", eid, err) |
| 106 | c.JSON(http.StatusInternalServerError, model.SystemError.ToErrorResponse(err)) |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | logger.Infof(c, "【录音配置】更新成功: eid=%d", eid) |
| 111 | c.JSON(http.StatusOK, model.Success.ToResponse(gin.H{"ok": true})) |
| 112 | } |
| 113 | |
| 114 | // ListParserPlatforms godoc |
| 115 | // @Summary 获取可用解析平台列表 |
nothing calls this directly
no test coverage detected