xyxie hace 4 semanas
padre
commit
95663071ce
Se han modificado 1 ficheros con 11 adiciones y 3 borrados
  1. 11 3
      services/wework/wework_audit_linux.go

+ 11 - 3
services/wework/wework_audit_linux.go

@@ -11,6 +11,7 @@ import (
 	"io/ioutil"
 	"os"
 	"path"
+	"time"
 
 	"github.com/silenceper/wechat/v2/work/msgaudit"
 )
@@ -27,6 +28,14 @@ func (w *WeWorkMsgAuditClient) GetMsgAuditContent(seq, limit uint64, timeout int
 	if len(chatDataList) == 0 {
 		return
 	}
+
+	filePath, _ := os.Getwd()
+	// 创建日期文件夹
+	date := time.Now().Format("2006-01-02")
+	filePath = path.Join(filePath, date)
+	if _, err := os.Stat(filePath); os.IsNotExist(err) {
+		os.MkdirAll(filePath, 0755)
+	}
 	for _, chatData := range chatDataList {
 		seqRes = chatData.Seq
 		//消息解密
@@ -58,7 +67,7 @@ func (w *WeWorkMsgAuditClient) GetMsgAuditContent(seq, limit uint64, timeout int
 				}
 				indexBuf = mediaData.OutIndexBuf
 			}
-			filePath, _ := os.Getwd()
+			
 			filePath = path.Join(filePath, image.Image.Md5Sum+".jpg")
 			err := ioutil.WriteFile(filePath, buffer.Bytes(), 0666)
 			if err != nil {
@@ -113,8 +122,7 @@ func (w *WeWorkMsgAuditClient) GetMsgAuditContent(seq, limit uint64, timeout int
 				indexBuf = mediaData.OutIndexBuf
 			}
 			// 保存文件到本地
-			filePath, _ := os.Getwd()
-			filePath = path.Join(filePath, file.File.FileName+"."+file.File.FileExt)
+			filePath = path.Join(filePath, file.File.FileName)
 			err = ioutil.WriteFile(filePath, buffer.Bytes(), 0666)
 			if err != nil {
 				utils.FileLog.Info(fmt.Sprintf("文件存储失败:%v \n", err))