...
|
...
|
@@ -211,14 +211,14 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId)))
|
|
|
}
|
|
|
|
|
|
// 获取上一个榜单
|
|
|
// 获取榜单命令
|
|
|
listListIntervalQuery := &query.ListListIntervalQuery {
|
|
|
CompanyId: listIntervalFound.CompanyId,
|
|
|
Offset: 1,
|
|
|
Limit: 1,
|
|
|
}
|
|
|
|
|
|
//获取上个年榜时间
|
|
|
//获取所有年榜
|
|
|
_, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -226,13 +226,17 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
|
|
|
|
// 判断年榜时间是否和上个年榜重叠
|
|
|
if len(listIntervals) > 0 {
|
|
|
if updateListIntervalCommand.ListIntervalStartTime.Before(listIntervals[0].IntervalEndTime) || updateListIntervalCommand.ListIntervalStartTime.Equal(listIntervals[0].IntervalEndTime){
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜开始时间必须大于上一个年榜结束时间")
|
|
|
} else { // 正常更新
|
|
|
for _, listInterval := range listIntervals {
|
|
|
// 排除当前年榜
|
|
|
if !listInterval.IntervalStartTime.Equal(listIntervalFound.IntervalStartTime) && listInterval.IntervalEndTime.Equal(listIntervalFound.IntervalEndTime) {
|
|
|
if updateListIntervalCommand.ListIntervalStartTime.Before(listInterval.IntervalEndTime) && updateListIntervalCommand.ListIntervalStartTime.After(listInterval.IntervalEndTime) { // 时间段重叠判断
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -241,12 +245,10 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt |
|
|
}
|
|
|
return listIntervalUpdated, nil
|
|
|
}
|
|
|
}
|
|
|
} else { // 正常更新
|
|
|
if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
|