Browse Source

修改数量查询方法

QM303176530 4 years ago
parent
commit
abaf366763

+ 1 - 1
server/go.mod

@@ -30,7 +30,7 @@ require (
 	github.com/onsi/gomega v1.4.3 // indirect
 	github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
 	github.com/pelletier/go-toml v1.6.0 // indirect
-	github.com/piexlmax/gvaplug v0.0.8 // indirect
+	github.com/piexlmax/gvaplug v0.0.8
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/qiniu/api.v7 v7.2.5+incompatible
 	github.com/qiniu/x v7.0.8+incompatible // indirect

+ 2 - 2
server/resource/template/te/service.go.tpl

@@ -61,7 +61,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
     // 创建db
-	db := global.GVA_DB
+	db := global.GVA_DB.Model(&model.{{.StructName}}{})
     var {{.Abbreviation}}s []model.{{.StructName}}
     // 如果有条件搜索 下方会自动创建搜索语句
         {{- range .Fields}}
@@ -89,7 +89,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
                 {{- end }}
         {{- end }}
     {{- end }}
-	err = db.Find(&{{.Abbreviation}}s).Count(&total).Error
+	err = db.Count(&total).Error
 	err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
 	return err, {{.Abbreviation}}s, total
 }

+ 2 - 2
server/service/exa_customer.go

@@ -61,7 +61,7 @@ func GetExaCustomer(id uint) (err error, customer model.ExaCustomer) {
 func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err error, list interface{}, total int) {
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
-	db := global.GVA_DB
+	db := global.GVA_DB.Model(&model.SysAuthority{})
 	var a model.SysAuthority
 	a.AuthorityId = sysUserAuthorityID
 	err, auth := GetAuthorityInfo(a)
@@ -70,7 +70,7 @@ func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err
 		dataId = append(dataId, v.AuthorityId)
 	}
 	var CustomerList []model.ExaCustomer
-	err = db.Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Count(&total).Error
+	err = db.Where("sys_user_authority_id in (?)", dataId).Count(&total).Error
 	if err != nil {
 		return err, CustomerList, total
 	} else {

+ 2 - 2
server/service/sys_api.go

@@ -49,7 +49,7 @@ func DeleteApi(api model.SysApi) (err error) {
 func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc bool) (err error, list interface{}, total int) {
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
-	db := global.GVA_DB
+	db := global.GVA_DB.Model(&model.SysApi{})
 	var apiList []model.SysApi
 
 	if api.Path != "" {
@@ -68,7 +68,7 @@ func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc
 		db = db.Where("api_group = ?", api.ApiGroup)
 	}
 
-	err = db.Find(&apiList).Count(&total).Error
+	err = db.Count(&total).Error
 
 	if err != nil {
 		return err, apiList, total

+ 2 - 2
server/service/sys_user.go

@@ -73,9 +73,9 @@ func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter
 func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int) {
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
-	db := global.GVA_DB
+	db := global.GVA_DB.Model(&model.SysUser{})
 	var userList []model.SysUser
-	err = db.Find(&userList).Count(&total).Error
+	err = db.Count(&total).Error
 	err = db.Limit(limit).Offset(offset).Preload("Authority").Find(&userList).Error
 	return err, userList, total
 }