Skip to content

Commit abaf366

Browse files
author
QM303176530
committed
修改数量查询方法
1 parent a3dc504 commit abaf366

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

server/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/onsi/gomega v1.4.3 // indirect
3131
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
3232
github.com/pelletier/go-toml v1.6.0 // indirect
33-
github.com/piexlmax/gvaplug v0.0.8 // indirect
33+
github.com/piexlmax/gvaplug v0.0.8
3434
github.com/pkg/errors v0.9.1 // indirect
3535
github.com/qiniu/api.v7 v7.2.5+incompatible
3636
github.com/qiniu/x v7.0.8+incompatible // indirect

server/resource/template/te/service.go.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
6161
limit := info.PageSize
6262
offset := info.PageSize * (info.Page - 1)
6363
// 创建db
64-
db := global.GVA_DB
64+
db := global.GVA_DB.Model(&model.{{.StructName}}{})
6565
var {{.Abbreviation}}s []model.{{.StructName}}
6666
// 如果有条件搜索 下方会自动创建搜索语句
6767
{{- range .Fields}}
@@ -89,7 +89,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
8989
{{- end }}
9090
{{- end }}
9191
{{- end }}
92-
err = db.Find(&{{.Abbreviation}}s).Count(&total).Error
92+
err = db.Count(&total).Error
9393
err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
9494
return err, {{.Abbreviation}}s, total
9595
}

server/service/exa_customer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func GetExaCustomer(id uint) (err error, customer model.ExaCustomer) {
6161
func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err error, list interface{}, total int) {
6262
limit := info.PageSize
6363
offset := info.PageSize * (info.Page - 1)
64-
db := global.GVA_DB
64+
db := global.GVA_DB.Model(&model.SysAuthority{})
6565
var a model.SysAuthority
6666
a.AuthorityId = sysUserAuthorityID
6767
err, auth := GetAuthorityInfo(a)
@@ -70,7 +70,7 @@ func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err
7070
dataId = append(dataId, v.AuthorityId)
7171
}
7272
var CustomerList []model.ExaCustomer
73-
err = db.Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Count(&total).Error
73+
err = db.Where("sys_user_authority_id in (?)", dataId).Count(&total).Error
7474
if err != nil {
7575
return err, CustomerList, total
7676
} else {

server/service/sys_api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func DeleteApi(api model.SysApi) (err error) {
4949
func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc bool) (err error, list interface{}, total int) {
5050
limit := info.PageSize
5151
offset := info.PageSize * (info.Page - 1)
52-
db := global.GVA_DB
52+
db := global.GVA_DB.Model(&model.SysApi{})
5353
var apiList []model.SysApi
5454

5555
if api.Path != "" {
@@ -68,7 +68,7 @@ func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc
6868
db = db.Where("api_group = ?", api.ApiGroup)
6969
}
7070

71-
err = db.Find(&apiList).Count(&total).Error
71+
err = db.Count(&total).Error
7272

7373
if err != nil {
7474
return err, apiList, total

server/service/sys_user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter
7373
func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int) {
7474
limit := info.PageSize
7575
offset := info.PageSize * (info.Page - 1)
76-
db := global.GVA_DB
76+
db := global.GVA_DB.Model(&model.SysUser{})
7777
var userList []model.SysUser
78-
err = db.Find(&userList).Count(&total).Error
78+
err = db.Count(&total).Error
7979
err = db.Limit(limit).Offset(offset).Preload("Authority").Find(&userList).Error
8080
return err, userList, total
8181
}

0 commit comments

Comments
 (0)