...
|
...
|
@@ -67,52 +67,56 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt |
|
|
startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
|
|
|
endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
ok := listIntervalDao.RankPeriodCheckTime(startTime.UnixNano() / 1e6, endTime.UnixNano() / 1e6, 0)
|
|
|
if !ok {
|
|
|
startTimeCheck := time.Date(createListIntervalCommand.ListIntervalStartTime.Year(), createListIntervalCommand.ListIntervalStartTime.Month(), createListIntervalCommand.ListIntervalStartTime.Day(), 0, 0, 0, 0, time.UTC)
|
|
|
endTimeCheck := time.Date(createListIntervalCommand.ListIntervalEndTime.Year(), createListIntervalCommand.ListIntervalEndTime.Month(), createListIntervalCommand.ListIntervalEndTime.Day(), 23, 59, 59, 0, time.UTC)
|
|
|
|
|
|
ok := listIntervalDao.RankPeriodCheckTime(startTimeCheck, endTimeCheck, 0, listIntervals[0].CompanyId)
|
|
|
fmt.Print(ok, "\n")
|
|
|
if ok {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
|
|
}
|
|
|
|
|
|
// 创建排行榜时间
|
|
|
newListInterval := &domain.ListInterval {
|
|
|
CompanyId: createListIntervalCommand.CompanyId,
|
|
|
IntervalStartTime: startTime,
|
|
|
IntervalEndTime: endTime,
|
|
|
}
|
|
|
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
|
|
|
|
|
|
// 判断年榜时间是否和上个年榜重叠
|
|
|
if len(listIntervals) > 0 {
|
|
|
if startTime.Before(listIntervals[0].IntervalEndTime.Local()) || startTime.Equal(listIntervals[0].IntervalEndTime.Local()){
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
} else {
|
|
|
// 创建排行榜时间命令
|
|
|
newListInterval := &domain.ListInterval {
|
|
|
CompanyId: createListIntervalCommand.CompanyId,
|
|
|
IntervalStartTime: startTime,
|
|
|
IntervalEndTime: endTime,
|
|
|
}
|
|
|
|
|
|
// 保存排行榜时间
|
|
|
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,
|
|
|
IntervalStartTime: startTime,
|
|
|
IntervalEndTime: endTime,
|
|
|
}
|
|
|
//if len(listIntervals) > 0 {
|
|
|
//if startTime.Before(listIntervals[0].IntervalEndTime.Local()) || startTime.Equal(listIntervals[0].IntervalEndTime.Local()){
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
//} else {
|
|
|
// // 创建排行榜时间命令
|
|
|
// newListInterval := &domain.ListInterval {
|
|
|
// CompanyId: createListIntervalCommand.CompanyId,
|
|
|
// IntervalStartTime: startTime,
|
|
|
// IntervalEndTime: endTime,
|
|
|
// }
|
|
|
//
|
|
|
// // 保存排行榜时间
|
|
|
// 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 {
|
|
|
|
|
|
// 保存排行榜时间
|
|
|
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
|
|
|
}
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
// 返回排行榜时间列表
|
...
|
...
|
@@ -252,11 +256,15 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
|
// 当前更新的开始结束时间
|
|
|
startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
|
|
|
endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
updateListIntervalCommand.ListIntervalStartTime = startTime
|
|
|
updateListIntervalCommand.ListIntervalEndTime = endTime
|
|
|
|
|
|
ok := listIntervalDao.RankPeriodCheckTime(startTime.UnixNano() / 1e6, endTime.UnixNano() / 1e6, listIntervalFound.ListIntervalId)
|
|
|
if !ok {
|
|
|
startTimeCheck := time.Date(updateListIntervalCommand.ListIntervalStartTime.Year(), updateListIntervalCommand.ListIntervalStartTime.Month(), updateListIntervalCommand.ListIntervalStartTime.Day(), 0, 0, 0, 0, time.UTC)
|
|
|
endTimeCheck := time.Date(updateListIntervalCommand.ListIntervalEndTime.Year(), updateListIntervalCommand.ListIntervalEndTime.Month(), updateListIntervalCommand.ListIntervalEndTime.Day(), 23, 59, 59, 0, time.UTC)
|
|
|
|
|
|
ok := listIntervalDao.RankPeriodCheckTime(startTimeCheck, endTimeCheck, listIntervalFound.ListIntervalId, listIntervalFound.CompanyId)
|
|
|
if ok {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
|
|
}
|
|
|
|
...
|
...
|
|