|
@@ -193,7 +193,7 @@ func GetListByCondition[T any](column string, values []T) (reports []Report, err
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func GetMaxIdByPermissionIds(orgIds map[string][]int) (maxId int64) {
|
|
|
+func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64, err error) {
|
|
|
db := models.Main()
|
|
|
if len(orgIds["ETA"]) == 0 && len(orgIds["HT"]) == 0 {
|
|
|
//err := db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Scan(&maxId).Error
|
|
@@ -202,28 +202,44 @@ func GetMaxIdByPermissionIds(orgIds map[string][]int) (maxId int64) {
|
|
|
// return 0
|
|
|
//}
|
|
|
maxId = 0
|
|
|
+ total = 0
|
|
|
return
|
|
|
}
|
|
|
if len(orgIds["ETA"]) == 0 {
|
|
|
- err := db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
+ err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&total).Error
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取记录条数失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
- return 0
|
|
|
+ return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
if len(orgIds["HT"]) == 0 {
|
|
|
- err := db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&maxId).Error
|
|
|
+ err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&maxId).Error
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取报告最大ID失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&maxId).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
- return 0
|
|
|
+ return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- err := db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
+ err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
- return 0
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取报告最大ID失败:%v", err)
|
|
|
+ return
|
|
|
}
|
|
|
return
|
|
|
}
|