XMLWAN 4 years ago
parent
commit
8327a80133

+ 4 - 1
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -92,14 +92,17 @@ func (this *CommonApiController) SaveConfiguration() {
92 92
 }
93 93
 
94 94
 func (this *CommonApiController) GetConfigurationlist() {
95
+	limit, _ := this.GetInt64("limit")
96
+	page, _ := this.GetInt64("page")
95 97
 	adminUser := this.GetAdminUserInfo()
96 98
 	orgid := adminUser.CurrentOrgId
97
-	configurationlist, err := service.GetConfigurationlist(orgid)
99
+	configurationlist, total, err := service.GetConfigurationlist(orgid, limit, page)
98 100
 	if err != nil {
99 101
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
100 102
 		return
101 103
 	}
102 104
 	this.ServeSuccessJSON(map[string]interface{}{
103 105
 		"configurationlist": configurationlist,
106
+		"total":             total,
104 107
 	})
105 108
 }

+ 5 - 4
service/common_service.go View File

@@ -29,7 +29,7 @@ func SaveInspection(standard *models.XtQualityControlStandard) error {
29 29
 	return err
30 30
 }
31 31
 
32
-func GetConfigurationlist(orgid int64) (standard []*models.QualityControlStandard, err error) {
32
+func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*models.QualityControlStandard, total int64, err error) {
33 33
 
34 34
 	//err = XTReadDB().Model(&standard).Where("user_org_id = ? and status =1", orgid).Order("sort asc,created_time desc").Find(&standard).Error
35 35
 	//return standard,err
@@ -40,7 +40,8 @@ func GetConfigurationlist(orgid int64) (standard []*models.QualityControlStandar
40 40
 	}
41 41
 	table := XTReadDB().Table("xt_inspection_reference as s")
42 42
 	fmt.Println(table)
43
-	err = db.Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").
44
-		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Order("x.sort asc,x.created_time desc").Scan(&standard).Error
45
-	return standard, err
43
+	offset := (page - 1) * limit
44
+	err = db.Order("x.sort asc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").Count(&total).
45
+		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
46
+	return standard, total, err
46 47
 }