|
|
@@ -26,7 +26,7 @@ func DeviceList(c *gin.Context) { |
|
|
|
req.Page = 10 |
|
|
|
} |
|
|
|
|
|
|
|
sess := db.Db.Desc("id") |
|
|
|
sess := db.Db.Desc("device.id") |
|
|
|
if 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) |
|
|
|
} |
|
|
|
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 { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|