package com.ruoyi.system.controller; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.system.service.TelegramAuditService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** Telegram Webhook管理员运维接口。 */ @RestController @RequestMapping("/system/telegram/webhook") public class TelegramWebhookController { private final TelegramAuditService telegramAuditService; public TelegramWebhookController(TelegramAuditService telegramAuditService) { this.telegramAuditService = telegramAuditService; } /** 查询Telegram侧当前Webhook状态,不返回Bot Token或Secret。 */ @PreAuthorize("@ss.hasRole('admin')") @GetMapping public AjaxResult getInfo() { return AjaxResult.success(telegramAuditService.getWebhookInfo()); } /** 按服务端环境变量重新注册Webhook。 */ @PreAuthorize("@ss.hasRole('admin')") @Log(title = "Telegram Webhook设置", businessType = BusinessType.UPDATE) @PostMapping("/set") public AjaxResult setWebhook() { return AjaxResult.success("Telegram Webhook设置成功", telegramAuditService.setWebhook()); } }