支持在线时间跨天并优化发布与筛选体验
允许在线时段 end 早于 start 表示跨天,统一展示「次日」文案;修复移动端价格区间清空后被 sessionStorage 回写;优化 PC/移动端在线时间控件密度与通栏展示。
This commit is contained in:
@@ -93,7 +93,7 @@ func TestValidateRequiredOnlineTimeRejectsMissing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRequiredOnlineTimeRejectsInvalidRange(t *testing.T) {
|
||||
func TestValidateRequiredOnlineTimeAllowsCrossDay(t *testing.T) {
|
||||
req := CreateRequest{
|
||||
AssetSummary: map[string]any{
|
||||
"online_time": map[string]any{
|
||||
@@ -103,6 +103,21 @@ func TestValidateRequiredOnlineTimeRejectsInvalidRange(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if err := validateRequiredOnlineTime(req); err != nil {
|
||||
t.Fatalf("expected cross-day range to be valid, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRequiredOnlineTimeRejectsSameStartEnd(t *testing.T) {
|
||||
req := CreateRequest{
|
||||
AssetSummary: map[string]any{
|
||||
"online_time": map[string]any{
|
||||
"start": "10:00",
|
||||
"end": "10:00",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := validateRequiredOnlineTime(req); err != ErrInvalidOnlineTime {
|
||||
t.Fatalf("expected ErrInvalidOnlineTime, got %v", err)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ func validateRequiredOnlineTime(req CreateRequest) error {
|
||||
if !ok {
|
||||
return ErrInvalidOnlineTime
|
||||
}
|
||||
if startMinute >= endMinute {
|
||||
// 允许跨天:start > end 表示每日 start 至次日 end(如 23:00-05:00)
|
||||
// 仅禁止起止时刻相同(全天请用 00:00-23:59)
|
||||
if startMinute == endMinute {
|
||||
return ErrInvalidOnlineTime
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user