...
|
...
|
@@ -40,11 +40,42 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt |
|
|
}
|
|
|
|
|
|
// 获取当前最新排行榜时间
|
|
|
listListIntervalQuery := &query.ListListIntervalQuery {
|
|
|
CompanyId: createListIntervalCommand.CompanyId,
|
|
|
Offset: 0,
|
|
|
Limit: 1,
|
|
|
}
|
|
|
|
|
|
// 获取上个年榜时间
|
|
|
_, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 判断排行榜时间是否重叠
|
|
|
// 判断年榜时间是否和上个年榜重叠
|
|
|
if len(listIntervals) > 0 {
|
|
|
if createListIntervalCommand.ListIntervalStartTime.Before(listIntervals[0].IntervalEndTime) {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
} else {
|
|
|
// 创建排行榜时间命令
|
|
|
newListInterval := &domain.ListInterval {
|
|
|
CompanyId: createListIntervalCommand.CompanyId,
|
|
|
IntervalStartTime: createListIntervalCommand.ListIntervalStartTime,
|
|
|
IntervalEndTime: createListIntervalCommand.ListIntervalEndTime,
|
|
|
}
|
|
|
|
|
|
// 保存排行榜时间
|
|
|
listInterval, err := listIntervalRepository.Save(newListInterval)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
return listInterval, nil
|
|
|
}
|
|
|
} else {
|
|
|
// 创建排行榜时间命令
|
|
|
newListInterval := &domain.ListInterval {
|
|
|
CompanyId: createListIntervalCommand.CompanyId,
|
...
|
...
|
@@ -53,9 +84,10 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt |
|
|
}
|
|
|
|
|
|
// 保存排行榜时间
|
|
|
if listInterval, err := listIntervalRepository.Save(newListInterval); err != nil {
|
|
|
listInterval, err := listIntervalRepository.Save(newListInterval)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|