|
@@ -8,7 +8,13 @@ import (
|
8
|
8
|
)
|
9
|
9
|
|
10
|
10
|
func GetInspectionReference(orgId int64) (reference []*models.InspectionReference, err error) {
|
11
|
|
- err = readDb.Model(&models.InspectionReference{}).Where("(org_id=0 OR org_id=?) and status=1", orgId).Order("project_id").Find(&reference).Error
|
|
11
|
+ var count int
|
|
12
|
+ err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1", orgId).Count(&count).Error
|
|
13
|
+ if count > 0 {
|
|
14
|
+ err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1", orgId).Order("project_id").Find(&reference).Error
|
|
15
|
+ } else {
|
|
16
|
+ err = readDb.Model(&models.InspectionReference{}).Where("org_id=0 and status=1").Order("project_id").Find(&reference).Error
|
|
17
|
+ }
|
12
|
18
|
return
|
13
|
19
|
}
|
14
|
20
|
|