This commit is contained in:
liangzai 2025-06-02 17:10:35 +08:00
parent 3f754d66e4
commit 21a88b42f8
3 changed files with 21 additions and 6 deletions

View File

@ -217,6 +217,7 @@ type (
Id string `path:"id"` Id string `path:"id"`
} }
QueryShareDetailResp { QueryShareDetailResp {
Status string `json:"status"`
Query Query
} }
) )

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"strconv" "time"
"tydata-server/app/user/cmd/api/internal/svc" "tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types" "tydata-server/app/user/cmd/api/internal/types"
@ -12,6 +12,7 @@ import (
"tydata-server/common/xerr" "tydata-server/common/xerr"
"tydata-server/pkg/lzkit/crypto" "tydata-server/pkg/lzkit/crypto"
"github.com/bytedance/sonic"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
@ -41,12 +42,23 @@ func (l *QueryShareDetailLogic) QueryShareDetail(req *types.QueryShareDetailReq)
if decryptErr != nil { if decryptErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 解密数据失败: %v", decryptErr) return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 解密数据失败: %v", decryptErr)
} }
// 获取订单信息
orderID, err := strconv.ParseInt(string(decryptedID), 10, 64) var payload types.QueryShareLinkPayload
err = sonic.Unmarshal(decryptedID, &payload)
if err != nil { if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 解密ID转换失败: %v", err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 解密数据失败: %v", err)
} }
order, err := l.svcCtx.OrderModel.FindOne(l.ctx, orderID)
// 检查分享链接是否过期
now := time.Now().Unix()
if now > payload.ExpireAt {
return &types.QueryShareDetailResp{
Status: "expired",
}, nil
}
// 获取订单信息
order, err := l.svcCtx.OrderModel.FindOne(l.ctx, payload.OrderId)
if err != nil { if err != nil {
if errors.Is(err, model.ErrNotFound) { if errors.Is(err, model.ErrNotFound) {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.LOGIC_QUERY_NOT_FOUND), "报告查询, 订单不存在: %v", err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.LOGIC_QUERY_NOT_FOUND), "报告查询, 订单不存在: %v", err)
@ -92,7 +104,8 @@ func (l *QueryShareDetailLogic) QueryShareDetail(req *types.QueryShareDetailReq)
} }
query.ProductName = product.ProductName query.ProductName = product.ProductName
return &types.QueryShareDetailResp{ return &types.QueryShareDetailResp{
Query: query, Status: "success",
Query: query,
}, nil }, nil
} }

View File

@ -441,6 +441,7 @@ type QueryShareDetailReq struct {
} }
type QueryShareDetailResp struct { type QueryShareDetailResp struct {
Status string `json:"status"`
Query Query
} }