Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
b6c259bc55
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      app/admin/hdl/hdl_device.go

+ 3
- 2
app/admin/hdl/hdl_device.go View File

@@ -26,7 +26,7 @@ func DeviceList(c *gin.Context) {
req.Page = 10 req.Page = 10
} }


sess := db.Db.Desc("id")
sess := db.Db.Desc("device.id")
if req.Name != "" { if req.Name != "" {
sess.And("device.name like ?", "%"+req.Name+"%") sess.And("device.name like ?", "%"+req.Name+"%")
} }
@@ -40,7 +40,8 @@ func DeviceList(c *gin.Context) {
sess.And("device.create_at <=?", req.EndDate) sess.And("device.create_at <=?", req.EndDate)
} }
var m []*db.DeviceWithEnterprise var m []*db.DeviceWithEnterprise
total, err := sess.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
total, err := sess.
Join("LEFT", "enterprise", "enterprise.id = device.enterprise_id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil { if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error()) e.OutErr(c, e.ERR_DB_ORM, err.Error())
return return


Loading…
Cancel
Save