From abaf366763f8f45f810a9839c603eea4e23da93c Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Tue, 16 Jun 2020 13:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E9=87=8F=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/go.mod | 2 +- server/resource/template/te/service.go.tpl | 4 ++-- server/service/exa_customer.go | 4 ++-- server/service/sys_api.go | 4 ++-- server/service/sys_user.go | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/go.mod b/server/go.mod index 6c48fb19..0088d3f8 100644 --- a/server/go.mod +++ b/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 diff --git a/server/resource/template/te/service.go.tpl b/server/resource/template/te/service.go.tpl index 5ba589c3..689c8917 100644 --- a/server/resource/template/te/service.go.tpl +++ b/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 } \ No newline at end of file diff --git a/server/service/exa_customer.go b/server/service/exa_customer.go index 24681aae..4c572abe 100644 --- a/server/service/exa_customer.go +++ b/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 { diff --git a/server/service/sys_api.go b/server/service/sys_api.go index 6c3a605c..fc3d9ec3 100644 --- a/server/service/sys_api.go +++ b/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 diff --git a/server/service/sys_user.go b/server/service/sys_user.go index 56e34116..e3cfefba 100644 --- a/server/service/sys_user.go +++ b/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 }