Sfoglia il codice sorgente

1.定时发送时,获取详情接口的时间时区问题修复
2.登录时,fastgpt系统未查到用户时,删除已经种上的fastgpt的cookie

lichangdong 1 settimana fa
parent
commit
1c4b4ca40b

+ 3 - 2
internal/logic/batch_msg/get_batch_msg_by_id_logic.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"encoding/json"
 	"github.com/zeromicro/go-zero/core/errorx"
+	"time"
 	"wechat-api/ent"
 	"wechat-api/ent/batchmsg"
 
@@ -53,7 +54,7 @@ func (l *GetBatchMsgByIdLogic) GetBatchMsgById(req *types.IDReq) (*types.BatchMs
 	}
 	labels = tagMap["contact_tag"]
 	groupLables = tagMap["group_tag"]
-
+	loc, _ := time.LoadLocation("Asia/Shanghai")
 	return &types.BatchMsgInfoResp{
 		BaseDataInfo: types.BaseDataInfo{
 			Code: 0,
@@ -79,7 +80,7 @@ func (l *GetBatchMsgByIdLogic) GetBatchMsgById(req *types.IDReq) (*types.BatchMs
 			StartTime:    pointy.GetUnixMilliPointer(data.StartTime.UnixMilli()),
 			StopTime:     pointy.GetUnixMilliPointer(data.StopTime.UnixMilli()),
 			SendTime:     pointy.GetUnixMilliPointer(data.SendTime.UnixMilli()),
-			StartTimeStr: pointy.GetPointer(data.StartTime.Format("2006-01-02 15:04:05")),
+			StartTimeStr: pointy.GetPointer(data.StartTime.In(loc).Format("2006-01-02 15:04:05")),
 			Labels:       labels,
 			GroupLabels:  groupLables,
 		},

+ 16 - 0
internal/logic/fastgpt/set_token_logic.go

@@ -40,6 +40,7 @@ func (l *SetTokenLogic) SetToken(username string) (resp *types.BaseMsgResp, err
 	data, err := l.svcCtx.CoreRpc.GetUserById(context.TODO(), &core.UUIDReq{Id: claims.UserId})
 	token, err := GetToken(strconv.FormatUint(*data.DepartmentId, 10))
 	if err != nil {
+		l.clearFastGPTCookie()
 		return nil, fmt.Errorf("invalid token3")
 	}
 	//if err != nil {
@@ -68,6 +69,21 @@ func (l *SetTokenLogic) SetToken(username string) (resp *types.BaseMsgResp, err
 	return
 }
 
+func (l *SetTokenLogic) clearFastGPTCookie() {
+	cookie := &http.Cookie{
+		Name:     "fastgpt_token",
+		Value:    "",
+		Domain:   ".gkscrm.com",
+		SameSite: http.SameSiteNoneMode,
+		Secure:   true,
+		HttpOnly: false,
+		Path:     "/",
+		MaxAge:   -1, // 删除 Cookie
+	}
+	http.SetCookie(l.rw, cookie)
+	l.Logger.Info("Cleared fastgpt_token cookie due to an error")
+}
+
 // SetTokenByUserId 根据用户ID设置token。
 // 参数:
 //