|
@@ -67,52 +67,56 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt |
|
@@ -67,52 +67,56 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt |
67
|
startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
|
67
|
startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
|
68
|
endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
|
68
|
endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
|
69
|
|
69
|
|
70
|
- ok := listIntervalDao.RankPeriodCheckTime(startTime.UnixNano() / 1e6, endTime.UnixNano() / 1e6, 0)
|
|
|
71
|
- if !ok {
|
70
|
+ startTimeCheck := time.Date(createListIntervalCommand.ListIntervalStartTime.Year(), createListIntervalCommand.ListIntervalStartTime.Month(), createListIntervalCommand.ListIntervalStartTime.Day(), 0, 0, 0, 0, time.UTC)
|
|
|
71
|
+ endTimeCheck := time.Date(createListIntervalCommand.ListIntervalEndTime.Year(), createListIntervalCommand.ListIntervalEndTime.Month(), createListIntervalCommand.ListIntervalEndTime.Day(), 23, 59, 59, 0, time.UTC)
|
|
|
72
|
+
|
|
|
73
|
+ ok := listIntervalDao.RankPeriodCheckTime(startTimeCheck, endTimeCheck, 0, listIntervals[0].CompanyId)
|
|
|
74
|
+ fmt.Print(ok, "\n")
|
|
|
75
|
+ if ok {
|
72
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
76
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
73
|
}
|
77
|
}
|
74
|
|
78
|
|
|
|
79
|
+ // 创建排行榜时间
|
|
|
80
|
+ newListInterval := &domain.ListInterval {
|
|
|
81
|
+ CompanyId: createListIntervalCommand.CompanyId,
|
|
|
82
|
+ IntervalStartTime: startTime,
|
|
|
83
|
+ IntervalEndTime: endTime,
|
|
|
84
|
+ }
|
|
|
85
|
+ listInterval, err := listIntervalRepository.Save(newListInterval)
|
|
|
86
|
+ if err != nil {
|
|
|
87
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
88
|
+ }
|
|
|
89
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
90
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
91
|
+ }
|
|
|
92
|
+ return listInterval, nil
|
|
|
93
|
+
|
75
|
// 判断年榜时间是否和上个年榜重叠
|
94
|
// 判断年榜时间是否和上个年榜重叠
|
76
|
- if len(listIntervals) > 0 {
|
|
|
77
|
- if startTime.Before(listIntervals[0].IntervalEndTime.Local()) || startTime.Equal(listIntervals[0].IntervalEndTime.Local()){
|
|
|
78
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
79
|
- } else {
|
|
|
80
|
- // 创建排行榜时间命令
|
|
|
81
|
- newListInterval := &domain.ListInterval {
|
|
|
82
|
- CompanyId: createListIntervalCommand.CompanyId,
|
|
|
83
|
- IntervalStartTime: startTime,
|
|
|
84
|
- IntervalEndTime: endTime,
|
|
|
85
|
- }
|
|
|
86
|
-
|
|
|
87
|
- // 保存排行榜时间
|
|
|
88
|
- listInterval, err := listIntervalRepository.Save(newListInterval)
|
|
|
89
|
- if err != nil {
|
|
|
90
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
91
|
- }
|
|
|
92
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
93
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
94
|
- }
|
|
|
95
|
-
|
|
|
96
|
- return listInterval, nil
|
|
|
97
|
- }
|
|
|
98
|
- } else {
|
|
|
99
|
- // 创建排行榜时间命令
|
|
|
100
|
- newListInterval := &domain.ListInterval {
|
|
|
101
|
- CompanyId: createListIntervalCommand.CompanyId,
|
|
|
102
|
- IntervalStartTime: startTime,
|
|
|
103
|
- IntervalEndTime: endTime,
|
|
|
104
|
- }
|
95
|
+ //if len(listIntervals) > 0 {
|
|
|
96
|
+ //if startTime.Before(listIntervals[0].IntervalEndTime.Local()) || startTime.Equal(listIntervals[0].IntervalEndTime.Local()){
|
|
|
97
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
98
|
+ //} else {
|
|
|
99
|
+ // // 创建排行榜时间命令
|
|
|
100
|
+ // newListInterval := &domain.ListInterval {
|
|
|
101
|
+ // CompanyId: createListIntervalCommand.CompanyId,
|
|
|
102
|
+ // IntervalStartTime: startTime,
|
|
|
103
|
+ // IntervalEndTime: endTime,
|
|
|
104
|
+ // }
|
|
|
105
|
+ //
|
|
|
106
|
+ // // 保存排行榜时间
|
|
|
107
|
+ // listInterval, err := listIntervalRepository.Save(newListInterval)
|
|
|
108
|
+ // if err != nil {
|
|
|
109
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
110
|
+ // }
|
|
|
111
|
+ // if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
112
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
113
|
+ // }
|
|
|
114
|
+ //
|
|
|
115
|
+ // return listInterval, nil
|
|
|
116
|
+ //}
|
|
|
117
|
+ //} else {
|
105
|
|
118
|
|
106
|
- // 保存排行榜时间
|
|
|
107
|
- listInterval, err := listIntervalRepository.Save(newListInterval)
|
|
|
108
|
- if err != nil {
|
|
|
109
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
110
|
- }
|
|
|
111
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
112
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
113
|
- }
|
|
|
114
|
- return listInterval, nil
|
|
|
115
|
- }
|
119
|
+ //}
|
116
|
}
|
120
|
}
|
117
|
|
121
|
|
118
|
// 返回排行榜时间列表
|
122
|
// 返回排行榜时间列表
|
|
@@ -252,11 +256,15 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
@@ -252,11 +256,15 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
252
|
// 当前更新的开始结束时间
|
256
|
// 当前更新的开始结束时间
|
253
|
startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
|
257
|
startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
|
254
|
endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
|
258
|
endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
|
|
|
259
|
+
|
255
|
updateListIntervalCommand.ListIntervalStartTime = startTime
|
260
|
updateListIntervalCommand.ListIntervalStartTime = startTime
|
256
|
updateListIntervalCommand.ListIntervalEndTime = endTime
|
261
|
updateListIntervalCommand.ListIntervalEndTime = endTime
|
257
|
|
262
|
|
258
|
- ok := listIntervalDao.RankPeriodCheckTime(startTime.UnixNano() / 1e6, endTime.UnixNano() / 1e6, listIntervalFound.ListIntervalId)
|
|
|
259
|
- if !ok {
|
263
|
+ startTimeCheck := time.Date(updateListIntervalCommand.ListIntervalStartTime.Year(), updateListIntervalCommand.ListIntervalStartTime.Month(), updateListIntervalCommand.ListIntervalStartTime.Day(), 0, 0, 0, 0, time.UTC)
|
|
|
264
|
+ endTimeCheck := time.Date(updateListIntervalCommand.ListIntervalEndTime.Year(), updateListIntervalCommand.ListIntervalEndTime.Month(), updateListIntervalCommand.ListIntervalEndTime.Day(), 23, 59, 59, 0, time.UTC)
|
|
|
265
|
+
|
|
|
266
|
+ ok := listIntervalDao.RankPeriodCheckTime(startTimeCheck, endTimeCheck, listIntervalFound.ListIntervalId, listIntervalFound.CompanyId)
|
|
|
267
|
+ if ok {
|
260
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
268
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
261
|
}
|
269
|
}
|
262
|
|
270
|
|