|
@@ -211,14 +211,14 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
@@ -211,14 +211,14 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
211
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId)))
|
211
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId)))
|
212
|
}
|
212
|
}
|
213
|
|
213
|
|
214
|
- // 获取上一个榜单
|
214
|
+ // 获取榜单命令
|
215
|
listListIntervalQuery := &query.ListListIntervalQuery {
|
215
|
listListIntervalQuery := &query.ListListIntervalQuery {
|
216
|
CompanyId: listIntervalFound.CompanyId,
|
216
|
CompanyId: listIntervalFound.CompanyId,
|
217
|
Offset: 1,
|
217
|
Offset: 1,
|
218
|
Limit: 1,
|
218
|
Limit: 1,
|
219
|
}
|
219
|
}
|
220
|
|
220
|
|
221
|
- //获取上个年榜时间
|
221
|
+ //获取所有年榜
|
222
|
_, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery))
|
222
|
_, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery))
|
223
|
if err != nil {
|
223
|
if err != nil {
|
224
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
224
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -226,27 +226,29 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
@@ -226,27 +226,29 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
226
|
|
226
|
|
227
|
// 判断年榜时间是否和上个年榜重叠
|
227
|
// 判断年榜时间是否和上个年榜重叠
|
228
|
if len(listIntervals) > 0 {
|
228
|
if len(listIntervals) > 0 {
|
229
|
- if updateListIntervalCommand.ListIntervalStartTime.Before(listIntervals[0].IntervalEndTime) || updateListIntervalCommand.ListIntervalStartTime.Equal(listIntervals[0].IntervalEndTime){
|
|
|
230
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
231
|
- } else { // 正常更新
|
|
|
232
|
- if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
|
|
|
233
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
234
|
- }
|
|
|
235
|
-
|
|
|
236
|
- if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
|
|
|
237
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
238
|
- } else {
|
|
|
239
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
240
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
229
|
+ for _, listInterval := range listIntervals {
|
|
|
230
|
+ // 排除当前年榜
|
|
|
231
|
+ if !listInterval.IntervalStartTime.Equal(listIntervalFound.IntervalStartTime) && listInterval.IntervalEndTime.Equal(listIntervalFound.IntervalEndTime) {
|
|
|
232
|
+ if updateListIntervalCommand.ListIntervalStartTime.Before(listInterval.IntervalEndTime) && updateListIntervalCommand.ListIntervalStartTime.After(listInterval.IntervalEndTime) { // 时间段重叠判断
|
|
|
233
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
241
|
}
|
234
|
}
|
242
|
- return listIntervalUpdated, nil
|
|
|
243
|
}
|
235
|
}
|
244
|
}
|
236
|
}
|
|
|
237
|
+ if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
|
|
|
238
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
239
|
+ }
|
|
|
240
|
+ if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
|
|
|
241
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
242
|
+ } else {
|
|
|
243
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
244
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
245
|
+ }
|
|
|
246
|
+ return listIntervalUpdated, nil
|
|
|
247
|
+ }
|
245
|
} else { // 正常更新
|
248
|
} else { // 正常更新
|
246
|
if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
|
249
|
if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
|
247
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
250
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
248
|
}
|
251
|
}
|
249
|
-
|
|
|
250
|
if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
|
252
|
if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
|
251
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
253
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
252
|
} else {
|
254
|
} else {
|