Files
LabelChange-server/.trae/specs/time_timestamp_conversion/spec.md
2026-06-01 16:30:29 +08:00

79 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 时间戳转换 - Product Requirement Document
## Overview
- **Summary**: 将到货及出库模块接口文档中提到的所有时间字段从DateTime类型统一转换为long类型的毫秒时间戳UTC确保API接口文档与实际代码实现一致。
- **Purpose**: 解决数据库中可null DateTime类型与API接口long类型时间戳之间的转换问题提供一致的API接口体验。
- **Target Users**: 后端开发人员、API调用方
## Goals
- 将出库交接单相关接口中的所有时间参数从DateTime?改为long?
- 将返回实体中的所有时间字段转换为long?类型的时间戳
- 保持文档与代码实现的一致性
- 确保时间戳使用UTC时区
## Non-Goals (Out of Scope)
- 不修改数据库表结构
- 不修改实体类的数据库映射属性
- 不影响其他模块的接口
## Background & Context
根据接口文档要求所有时间字段应使用long类型的毫秒时间戳UTC。目前代码中仍有部分接口使用DateTime类型需要统一转换。
## Functional Requirements
- **FR-1**: 修改出库交接单控制器中的所有时间参数为long?类型
- **FR-2**: 创建时间戳转换辅助方法处理DateTime与long之间的双向转换
- **FR-3**: 修改返回实体时的时间字段转换逻辑,确保所有返回的时间都是时间戳格式
- **FR-4**: 修改到货交接单控制器中的时间参数(如果有)
- **FR-5**: 修改袋牌相关接口中的时间字段(如果有)
## Non-Functional Requirements
- **NFR-1**: 转换逻辑必须处理null值情况
- **NFR-2**: 时间戳必须使用UTC时区
- **NFR-3**: 保持API向后兼容性尽可能
## Constraints
- **Technical**: .NET 6+, C#, ASP.NET Core
- **Business**: 需要尽快完成避免影响API调用方
- **Dependencies**: 依赖现有代码结构
## Assumptions
- 所有时间戳都使用毫秒级精度
- 所有时间戳都基于UTC时区
- SqlSugar ORM能正确处理DateTime?类型的数据库映射
## Acceptance Criteria
### AC-1: 出库交接单创建接口时间参数转换
- **Given**: 用户调用创建出库交接单接口
- **When**: 传入deliveryTime参数
- **Then**: 参数类型为long?系统正确转换为DateTime?存储到数据库
- **Verification**: `programmatic`
### AC-2: 出库交接单确认接口时间参数转换
- **Given**: 用户调用确认出库交接单接口
- **When**: 传入deliveryTime参数
- **Then**: 参数类型为long?系统正确转换为DateTime?存储到数据库
- **Verification**: `programmatic`
### AC-3: 出库交接单列表查询接口时间参数转换
- **Given**: 用户调用查询出库交接单列表接口
- **When**: 传入startDeliveryTime和endDeliveryTime参数
- **Then**: 参数类型为long?系统正确转换为DateTime?进行查询
- **Verification**: `programmatic`
### AC-4: 返回实体时间字段转换
- **Given**: 系统返回包含时间字段的实体数据
- **When**: 序列化响应数据
- **Then**: 所有DateTime类型字段都转换为long?类型的时间戳
- **Verification**: `programmatic`
### AC-5: 空值处理正确
- **Given**: 时间字段为null
- **When**: 进行转换
- **Then**: 转换结果也为null不抛出异常
- **Verification**: `programmatic`
## Open Questions
- [ ] 是否需要修改其他模块的接口?
- [ ] 是否需要添加单元测试?