Browse Source

所有控制器修复分布总数量

sixian 2 years ago
parent
commit
fdc014add9
75 changed files with 332 additions and 257 deletions
  1. 3 3
      app/device/controller/GatewayController.go
  2. 3 3
      app/device/controller/IntelligentLightingStrategy.go
  3. 3 3
      app/device/controller/LightStrategy.go
  4. 3 3
      app/device/controller/alarmController.go
  5. 3 3
      app/device/controller/alarmTerminalController.go
  6. 3 3
      app/device/controller/bridgeController.go
  7. 3 3
      app/device/controller/bridgeSensorController.go
  8. 3 3
      app/device/controller/cameraController.go
  9. 5 5
      app/device/controller/captureUintController.go
  10. 3 3
      app/device/controller/garbageController.go
  11. 3 3
      app/device/controller/garbageWayGroupController.go
  12. 3 3
      app/device/controller/infoBoardController.go
  13. 3 3
      app/device/controller/ipBroadcastController.go
  14. 3 3
      app/device/controller/lampPoleController.go
  15. 3 3
      app/device/controller/lampPoleGroupController.go
  16. 3 3
      app/device/controller/lightController.go
  17. 3 3
      app/device/controller/manholeCoverController.go
  18. 3 3
      app/device/controller/onDemandSensorController.go
  19. 3 3
      app/device/controller/optoSensorController.go
  20. 3 3
      app/device/controller/switchBoxController.go
  21. 3 3
      app/device/controller/transformerController.go
  22. 3 3
      app/device/controller/zigbeeController.go
  23. 4 2
      app/device/dao/LightStrategyDao.go
  24. 6 3
      app/device/dao/alarmDao.go
  25. 6 3
      app/device/dao/alarmTerminalDao.go
  26. 6 3
      app/device/dao/bridgeDao.go
  27. 6 3
      app/device/dao/bridgeSensorDao.go
  28. 6 3
      app/device/dao/cameraDao.go
  29. 6 3
      app/device/dao/captureUnitDao.go
  30. 6 4
      app/device/dao/checkPointDao.go
  31. 6 3
      app/device/dao/garbageDao.go
  32. 6 3
      app/device/dao/garbageWayGroupDao.go
  33. 6 3
      app/device/dao/gatewayDao.go
  34. 6 3
      app/device/dao/infoBoardDao.go
  35. 6 3
      app/device/dao/ipBroadcastDao.go
  36. 6 4
      app/device/dao/lampPoleDao.go
  37. 6 3
      app/device/dao/lampPoleGroupDao.go
  38. 6 3
      app/device/dao/lightControlDao.go
  39. 6 3
      app/device/dao/manholeCoverDao.go
  40. 6 3
      app/device/dao/onDemandSensorDao.go
  41. 6 3
      app/device/dao/optoSensoDao.go
  42. 7 4
      app/device/dao/switchBoxDao.go
  43. 6 3
      app/device/dao/transformerDao.go
  44. 6 3
      app/device/dao/zigbeeDao.go
  45. 4 4
      app/device/service/LightStrategyService.go
  46. 4 4
      app/device/service/alarmService.go
  47. 4 4
      app/device/service/alarmTerminalService.go
  48. 4 4
      app/device/service/bridgeSensorService.go
  49. 4 4
      app/device/service/bridgeService.go
  50. 4 4
      app/device/service/cameraService.go
  51. 8 8
      app/device/service/captureUintService.go
  52. 4 4
      app/device/service/garbageService.go
  53. 4 4
      app/device/service/garbageWayGroupService.go
  54. 4 4
      app/device/service/gatewayService.go
  55. 4 4
      app/device/service/infoBoardService.go
  56. 6 3
      app/device/service/intelligentLightingService.go
  57. 4 4
      app/device/service/ipBroadcastService.go
  58. 4 4
      app/device/service/lampPoleGroupService.go
  59. 4 4
      app/device/service/lampPoleService.go
  60. 4 4
      app/device/service/lightControlService.go
  61. 4 4
      app/device/service/manholeCoverService.go
  62. 4 4
      app/device/service/onDemandSensorService.go
  63. 4 4
      app/device/service/optoSensoService.go
  64. 4 4
      app/device/service/switchBoxService.go
  65. 4 4
      app/device/service/transformerService.go
  66. 4 4
      app/device/service/zigbeeService.go
  67. 3 3
      app/multimedia/controller/libraryController.go
  68. 3 3
      app/multimedia/controller/programController.go
  69. 3 3
      app/multimedia/controller/publishLibrariesController.go
  70. 6 3
      app/multimedia/dao/libraryDao.go
  71. 6 3
      app/multimedia/dao/programDao.go
  72. 6 3
      app/multimedia/dao/publishLibrariesDao.go
  73. 4 4
      app/multimedia/service/libraryService.go
  74. 4 4
      app/multimedia/service/programService.go
  75. 4 4
      app/multimedia/service/publishLibrariesService.go

+ 3 - 3
app/device/controller/GatewayController.go

@@ -42,16 +42,16 @@ func (c *gatewayCtl) List(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.GatewayService.List(searchValue, current, size)
+	devices, total, err := service.GatewayService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspGatewayList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 3 - 3
app/device/controller/IntelligentLightingStrategy.go

@@ -59,7 +59,7 @@ func (c *intelligentLightingCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	strategies, err := service.IntelligentLightingService.List(claims.TenantId, searchValue, current, size, gId)
+	strategies, total, err := service.IntelligentLightingService.List(claims.TenantId, searchValue, current, size, gId)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
@@ -68,7 +68,7 @@ func (c *intelligentLightingCtl) List(ctx *gin.Context) {
 	rsp := model.RspIntelligentLightList{
 		Current: current,
 		Size:    size,
-		Total:   len(strategies),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: strategies,
 	}
@@ -88,7 +88,7 @@ func (c *intelligentLightingCtl) RelationList(ctx *gin.Context) {
 		size = 10
 	}
 	searchValue := ""
-	strategies, err := service.LightStrategyService.List(searchValue, current, size)
+	strategies, _, err := service.LightStrategyService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return

+ 3 - 3
app/device/controller/LightStrategy.go

@@ -42,16 +42,16 @@ func (c *lightStrategyCtl) List(ctx *gin.Context) {
 		size = 10
 	}
 
-	lightStrategies, err := service.LightStrategyService.List(searchValue, current, size)
+	lightStrategies, total, err := service.LightStrategyService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(lightStrategies)) / float64(size))
+	pages := math.Ceil(float64(int(total)) / float64(size))
 	rsp := model.RspLightStrategyList{
 		Current: current,
 		Size:    size,
-		Total:   len(lightStrategies),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: lightStrategies,
 	}

+ 3 - 3
app/device/controller/alarmController.go

@@ -42,16 +42,16 @@ func (c *alarmCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.AlarmService.List(searchValue, current, size)
+	devices, total, err := service.AlarmService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqAlarmList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/alarmTerminalController.go

@@ -42,16 +42,16 @@ func (c *alarmTerminalCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.AlarmTerminalService.List(searchValue, current, size)
+	devices, total, err := service.AlarmTerminalService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqAlarmTerminalList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 3 - 3
app/device/controller/bridgeController.go

@@ -42,16 +42,16 @@ func (c *bridgeCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.BridgeService.List(searchValue, current, size)
+	devices, total, err := service.BridgeService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqBridgeList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/bridgeSensorController.go

@@ -42,16 +42,16 @@ func (c *bridgeSensorCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.BridgeSensorService.List(searchValue, current, size)
+	devices, total, err := service.BridgeSensorService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspBridgeSensorList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/cameraController.go

@@ -43,16 +43,16 @@ func (c *cameraCtl) List(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.CameraService.List(searchValue, cameraType, current, size)
+	devices, total, err := service.CameraService.List(searchValue, cameraType, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspCameraList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 5 - 5
app/device/controller/captureUintController.go

@@ -54,16 +54,16 @@ func (c *captureUintCtl) CaptureList(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.CaptureUintService.CaptureList(searchValue, current, size)
+	devices, total, err := service.CaptureUintService.CaptureList(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspCaptureList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}
@@ -100,7 +100,7 @@ func (c *captureUintCtl) PointList(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.CaptureUintService.PointList(searchValue, current, size)
+	devices, total, err := service.CaptureUintService.PointList(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
@@ -109,7 +109,7 @@ func (c *captureUintCtl) PointList(ctx *gin.Context) {
 	rsp := model.RspPointList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 3 - 3
app/device/controller/garbageController.go

@@ -42,16 +42,16 @@ func (c *garbageCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.GarbageService.List(searchValue, current, size)
+	devices, total, err := service.GarbageService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqGarbageList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/garbageWayGroupController.go

@@ -42,16 +42,16 @@ func (c *garbageWayCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.GarbageWayGroupService.List(searchValue, current, size)
+	devices, total, err := service.GarbageWayGroupService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqGarbageWayGroupList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/infoBoardController.go

@@ -42,16 +42,16 @@ func (c *infoBoardCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.InfoBoardService.List(searchValue, current, size)
+	devices, total, err := service.InfoBoardService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqInfoBoardList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 3 - 3
app/device/controller/ipBroadcastController.go

@@ -42,16 +42,16 @@ func (c *ipBroadcastCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.IpBroadcastService.List(searchValue, current, size)
+	devices, total, err := service.IpBroadcastService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqIpBroadcastList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/lampPoleController.go

@@ -58,16 +58,16 @@ func (c *lampPoleCtl) List(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.LampPoleService.List(searchValue, groupId, boxId, current, size)
+	devices, total, err := service.LampPoleService.List(searchValue, groupId, boxId, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspLampPoleList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/lampPoleGroupController.go

@@ -61,16 +61,16 @@ func (c *lampPoleGroupCtl) List(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.LampPoleGroupService.List(poleGroupName, current, size)
+	devices, total, err := service.LampPoleGroupService.List(poleGroupName, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspLampPoleGroupList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/lightController.go

@@ -45,16 +45,16 @@ func (c *lightCtl) List(ctx *gin.Context) {
 		size = 10
 	}
 
-	devices, err := service.LightControlService.List(searchValue, controlType, zigbeeId, current, size)
+	devices, total, err := service.LightControlService.List(searchValue, controlType, zigbeeId, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RspLightControlList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 3 - 3
app/device/controller/manholeCoverController.go

@@ -42,16 +42,16 @@ func (c *manholeCoverCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.ManholeCoverService.List(searchValue, current, size)
+	devices, total, err := service.ManholeCoverService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqManholeCoverList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/onDemandSensorController.go

@@ -42,16 +42,16 @@ func (c *onDemandSensorCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.OnDemandSensorService.List(searchValue, current, size)
+	devices, total, err := service.OnDemandSensorService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqOnDemandSensorList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/optoSensorController.go

@@ -42,16 +42,16 @@ func (c *optoSensorCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.OptoSensorService.List(searchValue, current, size)
+	devices, total, err := service.OptoSensorService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqOptoSensorList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/switchBoxController.go

@@ -42,16 +42,16 @@ func (c *switchBoxCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.SwitchBoxService.List(searchValue, current, size)
+	devices, total, err := service.SwitchBoxService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqSwitchBoxList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/transformerController.go

@@ -42,16 +42,16 @@ func (c *transformerCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.TransformerService.List(searchValue, current, size)
+	devices, total, err := service.TransformerService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqTransformerList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 	}
 	for _, device := range devices {

+ 3 - 3
app/device/controller/zigbeeController.go

@@ -42,16 +42,16 @@ func (c *zigbeeCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	devices, err := service.ZigbeeService.List(searchValue, current, size)
+	devices, total, err := service.ZigbeeService.List(searchValue, current, size)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqZigbeeList{
 		Current: current,
 		Size:    size,
-		Total:   len(devices),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: devices,
 	}

+ 4 - 2
app/device/dao/LightStrategyDao.go

@@ -69,14 +69,16 @@ func (c *LightStrategy) GetStrategy() error {
 	return err
 }
 
-func (c LightStrategy) GetStrategies(offset, limit int) ([]LightStrategy, error) {
+func (c LightStrategy) GetStrategies(offset, limit int) ([]LightStrategy, int64, error) {
 	var Strategies []LightStrategy
+	var count int64
 	db := Db.Debug().Model(&c).Where("is_deleted = 0")
 	if c.LightSn != "" {
 		db = db.Where(" light_name like ? or light_sn like ?", "%"+c.LightSn+"%", "%"+c.LightSn+"%")
 	}
+	db.Count(&count)
 	err := db.Offset(offset).Limit(limit).Find(&Strategies).Error
-	return Strategies, err
+	return Strategies, count, err
 
 }
 

+ 6 - 3
app/device/dao/alarmDao.go

@@ -74,10 +74,13 @@ func (c *Alarm) GetDevice() error {
 	return err
 }
 
-func (c Alarm) GetDevices(offset, limit int) ([]Alarm, error) {
+func (c Alarm) GetDevices(offset, limit int) ([]Alarm, int64, error) {
 	var devices []Alarm
-	err := Db.Debug().Model(&c).Where(" serve_name like ? and is_deleted = 0", "%"+c.ServeName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" serve_name like ? and is_deleted = 0", "%"+c.ServeName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c Alarm) GetAllDevices() ([]*Alarm, error) {

+ 6 - 3
app/device/dao/alarmTerminalDao.go

@@ -78,10 +78,13 @@ func (c *AlarmTerminal) GetDevice() error {
 	return err
 }
 
-func (c AlarmTerminal) GetDevices(offset, limit int) ([]AlarmTerminal, error) {
+func (c AlarmTerminal) GetDevices(offset, limit int) ([]AlarmTerminal, int64, error) {
 	var devices []AlarmTerminal
-	err := Db.Debug().Model(&c).Where(" terminal_name like ? and is_deleted = 0", "%"+c.TerminalName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" terminal_name like ? and is_deleted = 0", "%"+c.TerminalName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c AlarmTerminal) GetAllDevices() ([]*AlarmTerminal, error) {

+ 6 - 3
app/device/dao/bridgeDao.go

@@ -83,10 +83,13 @@ func (c *Bridge) GetDevice() error {
 	return err
 }
 
-func (c Bridge) GetDevices(offset, limit int) ([]Bridge, error) {
+func (c Bridge) GetDevices(offset, limit int) ([]Bridge, int64, error) {
 	var devices []Bridge
-	err := Db.Debug().Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c Bridge) GetAllDevices() ([]*Bridge, error) {

+ 6 - 3
app/device/dao/bridgeSensorDao.go

@@ -75,10 +75,13 @@ func (c *BridgeSensor) GetDevice() error {
 	return err
 }
 
-func (c BridgeSensor) GetDevices(offset, limit int) ([]BridgeSensor, error) {
+func (c BridgeSensor) GetDevices(offset, limit int) ([]BridgeSensor, int64, error) {
 	var devices []BridgeSensor
-	err := Db.Debug().Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c BridgeSensor) GetAllDevices() ([]*BridgeSensor, error) {

+ 6 - 3
app/device/dao/cameraDao.go

@@ -61,8 +61,9 @@ func (c *CameraDevice) GetDevice() error {
 	return err
 }
 
-func (c CameraDevice) GetDevices(offset, limit int) ([]CameraDevice, error) {
+func (c CameraDevice) GetDevices(offset, limit int) ([]CameraDevice, int64, error) {
 	var devices []CameraDevice
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.DeviceSN != "" {
 		db = db.Where("device_name like ? or device_sn like ?", "%"+c.DeviceSN+"%", "%"+c.DeviceSN+"%")
@@ -71,8 +72,10 @@ func (c CameraDevice) GetDevices(offset, limit int) ([]CameraDevice, error) {
 		db = db.Where("camera_type = ?", c.CameraType)
 	}
 
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	db = db.Where("is_deleted = 0")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c *CameraDevice) Delete() error {

+ 6 - 3
app/device/dao/captureUnitDao.go

@@ -61,15 +61,18 @@ func (c *CaptureUnit) GetDevice() error {
 	return err
 }
 
-func (c CaptureUnit) GetDevices(offset, limit int) ([]CaptureUnit, error) {
+func (c CaptureUnit) GetDevices(offset, limit int) ([]CaptureUnit, int64, error) {
 	var Captures []CaptureUnit
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.CaptureSn != "" {
 		db = db.Where("capture_name like ? or capture_sn like ?", "%"+c.CaptureSn+"%", "%"+c.CaptureSn+"%")
 	}
 
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&Captures).Error
-	return Captures, err
+	db = db.Where("is_deleted = 0")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&Captures).Error
+	return Captures, count, err
 }
 
 func (c *CaptureUnit) Delete() error {

+ 6 - 4
app/device/dao/checkPointDao.go

@@ -42,15 +42,17 @@ func (c *CheckPoint) GetDevice() error {
 	return err
 }
 
-func (c CheckPoint) GetDevices(offset, limit int) ([]CheckPoint, error) {
+func (c CheckPoint) GetDevices(offset, limit int) ([]CheckPoint, int64, error) {
 	var Points []CheckPoint
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.PointSN != "" {
 		db = db.Where("point_name like ? or point_sn like ?", "%"+c.PointSN+"%", "%"+c.PointSN+"%")
 	}
-
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&Points).Error
-	return Points, err
+	db = db.Where("is_deleted = 0")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&Points).Error
+	return Points, count, err
 }
 
 func (c *CheckPoint) Delete() error {

+ 6 - 3
app/device/dao/garbageDao.go

@@ -85,10 +85,13 @@ func (c *Garbage) GetDevice() error {
 	return err
 }
 
-func (c Garbage) GetDevices(offset, limit int) ([]Garbage, error) {
+func (c Garbage) GetDevices(offset, limit int) ([]Garbage, int64, error) {
 	var devices []Garbage
-	err := Db.Debug().Model(&c).Where(" device_name like ? and is_deleted = 0", "%"+c.DeviceName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" device_name like ? and is_deleted = 0", "%"+c.DeviceName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c Garbage) GetAllDevices() ([]*Garbage, error) {

+ 6 - 3
app/device/dao/garbageWayGroupDao.go

@@ -63,10 +63,13 @@ func (c *GarbageWayGroup) GetDevice() error {
 	return err
 }
 
-func (c GarbageWayGroup) GetDevices(offset, limit int) ([]GarbageWayGroup, error) {
+func (c GarbageWayGroup) GetDevices(offset, limit int) ([]GarbageWayGroup, int64, error) {
 	var devices []GarbageWayGroup
-	err := Db.Debug().Model(&c).Where(" group_name like ? and is_deleted = 0", "%"+c.GroupName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" group_name like ? and is_deleted = 0", "%"+c.GroupName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c GarbageWayGroup) GetAllDevices() ([]*GarbageWayGroup, error) {

+ 6 - 3
app/device/dao/gatewayDao.go

@@ -80,15 +80,18 @@ func (c *Gateway) GetDevice() error {
 	return err
 }
 
-func (c Gateway) GetDevices(offset, limit int) ([]Gateway, error) {
+func (c Gateway) GetDevices(offset, limit int) ([]Gateway, int64, error) {
 	var devices []Gateway
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.GatewaySn != "" {
 		db = db.Where("gateway_name like ? or gateway_sn like ?", "%"+c.GatewaySn+"%", "%"+c.GatewaySn+"%")
 	}
 
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	tx := db.Where("is_deleted = 0")
+	tx.Count(&count)
+	err := tx.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c Gateway) GetAllDevices() ([]*Gateway, error) {

+ 6 - 3
app/device/dao/infoBoardDao.go

@@ -86,10 +86,13 @@ func (c *InfoBoard) GetDevice() error {
 	return err
 }
 
-func (c InfoBoard) GetDevices(offset, limit int) ([]InfoBoard, error) {
+func (c InfoBoard) GetDevices(offset, limit int) ([]InfoBoard, int64, error) {
 	var devices []InfoBoard
-	err := Db.Debug().Model(&c).Where(" info_name like ? ", "%"+c.InfoName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" info_name like ? ", "%"+c.InfoName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c InfoBoard) GetAllDevices() ([]*InfoBoard, error) {

+ 6 - 3
app/device/dao/ipBroadcastDao.go

@@ -76,10 +76,13 @@ func (c *IpBroadcast) GetDevice() error {
 	return err
 }
 
-func (c IpBroadcast) GetDevices(offset, limit int) ([]IpBroadcast, error) {
+func (c IpBroadcast) GetDevices(offset, limit int) ([]IpBroadcast, int64, error) {
 	var devices []IpBroadcast
-	err := Db.Debug().Model(&c).Where("is_deleted = 0 and cast_name like ? ", "%"+c.CastName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where("is_deleted = 0 and cast_name like ? ", "%"+c.CastName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c IpBroadcast) GetAllDevices() ([]IpBroadcast, error) {

+ 6 - 4
app/device/dao/lampPoleDao.go

@@ -82,9 +82,9 @@ func (c *LampPole) GetDevice() error {
 	return err
 }
 
-func (c LampPole) GetDevices(offset, limit int) ([]LampPole, error) {
+func (c LampPole) GetDevices(offset, limit int) ([]LampPole, int64, error) {
 	var devices []LampPole
-
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.PoleSN != "" {
 		db = db.Where("pole_name like ? or pole_sn like ?", "%"+c.PoleSN+"%", "%"+c.PoleSN+"%")
@@ -95,8 +95,10 @@ func (c LampPole) GetDevices(offset, limit int) ([]LampPole, error) {
 	if c.BoxId != -1 {
 		db = db.Where("box_id = ?", c.BoxId)
 	}
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	db = db.Where("is_deleted = 0")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c LampPole) GetAllDevices() ([]*LampPole, error) {

+ 6 - 3
app/device/dao/lampPoleGroupDao.go

@@ -66,10 +66,13 @@ func (c *LampPoleGroup) GetDevice() error {
 	return err
 }
 
-func (c LampPoleGroup) GetDevices(offset, limit int) ([]LampPoleGroup, error) {
+func (c LampPoleGroup) GetDevices(offset, limit int) ([]LampPoleGroup, int64, error) {
 	var devices []LampPoleGroup
-	err := Db.Debug().Model(&c).Where(" pole_group_name like ? and is_deleted = 0", "%"+c.PoleGroupName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" pole_group_name like ? and is_deleted = 0", "%"+c.PoleGroupName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c LampPoleGroup) GetAllDevices() ([]*LampPoleGroup, error) {

+ 6 - 3
app/device/dao/lightControlDao.go

@@ -96,8 +96,9 @@ func (c *LightControl) GetDevicesByGroup() ([]LightControl, error) {
 	return devices, err
 }
 
-func (c LightControl) GetDevices(offset, limit int) ([]LightControl, error) {
+func (c LightControl) GetDevices(offset, limit int) ([]LightControl, int64, error) {
 	var devices []LightControl
+	var count int64
 
 	db := Db.Debug().Model(&c)
 	if c.Sn != "" {
@@ -110,8 +111,10 @@ func (c LightControl) GetDevices(offset, limit int) ([]LightControl, error) {
 		db = db.Where("zigbee_id = ?", c.ZigbeeId)
 	}
 
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	db = db.Where("is_deleted = 0")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c LightControl) GetAllDevices() ([]LightControl, error) {

+ 6 - 3
app/device/dao/manholeCoverDao.go

@@ -85,10 +85,13 @@ func (c *ManholeCover) GetDevice() error {
 	return err
 }
 
-func (c ManholeCover) GetDevices(offset, limit int) ([]ManholeCover, error) {
+func (c ManholeCover) GetDevices(offset, limit int) ([]ManholeCover, int64, error) {
 	var devices []ManholeCover
-	err := Db.Debug().Model(&c).Where(" manhole_name like ? and is_deleted = 0", "%"+c.ManholeName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" manhole_name like ? and is_deleted = 0", "%"+c.ManholeName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c ManholeCover) GetAllDevices() ([]*ManholeCover, error) {

+ 6 - 3
app/device/dao/onDemandSensorDao.go

@@ -69,10 +69,13 @@ func (c *OnDemandSensor) GetDevice() error {
 	return err
 }
 
-func (c OnDemandSensor) GetDevices(offset, limit int) ([]OnDemandSensor, error) {
+func (c OnDemandSensor) GetDevices(offset, limit int) ([]OnDemandSensor, int64, error) {
 	var devices []OnDemandSensor
-	err := Db.Debug().Model(&c).Where(" name like ? ", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where(" name like ? ", "%"+c.Name+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c OnDemandSensor) GetAllDevices() ([]*OnDemandSensor, error) {

+ 6 - 3
app/device/dao/optoSensoDao.go

@@ -78,10 +78,13 @@ func (c *OptoSensor) GetDevice() error {
 	return err
 }
 
-func (c OptoSensor) GetDevices(offset, limit int) ([]OptoSensor, error) {
+func (c OptoSensor) GetDevices(offset, limit int) ([]OptoSensor, int64, error) {
 	var devices []OptoSensor
-	err := Db.Debug().Model(&c).Where("is_deleted=0 and name like ? ", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where("is_deleted=0 and name like ? ", "%"+c.Name+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c OptoSensor) GetAllDevices() ([]*OptoSensor, error) {

+ 7 - 4
app/device/dao/switchBoxDao.go

@@ -82,11 +82,14 @@ func (c *SwitchBox) GetDevice() error {
 	return err
 }
 
-func (c SwitchBox) GetDevices(offset, limit int) ([]SwitchBox, error) {
+func (c SwitchBox) GetDevices(offset, limit int) ([]SwitchBox, int64, error) {
 	var devices []SwitchBox
-	err := Db.Debug().Model(&c).Where("(box_name like ?) and is_deleted = 0",
-		"%"+c.BoxName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where("(box_name like ?) and is_deleted = 0",
+		"%"+c.BoxName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 //得到关联设备 2022-12-08 dsx

+ 6 - 3
app/device/dao/transformerDao.go

@@ -74,10 +74,13 @@ func (c *Transformer) GetDevice() error {
 	return err
 }
 
-func (c Transformer) GetDevices(offset, limit int) ([]Transformer, error) {
+func (c Transformer) GetDevices(offset, limit int) ([]Transformer, int64, error) {
+	var count int64
 	var devices []Transformer
-	err := Db.Debug().Model(&c).Where(" trans_name like ? and is_deleted = 0", "%"+c.TransName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	db := Db.Debug().Model(&c).Where(" trans_name like ? and is_deleted = 0", "%"+c.TransName+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c Transformer) GetAllDevices() ([]*Transformer, error) {

+ 6 - 3
app/device/dao/zigbeeDao.go

@@ -84,10 +84,13 @@ func (c *Zigbee) GetDevice() error {
 	return err
 }
 
-func (c Zigbee) GetDevices(offset, limit int) ([]Zigbee, error) {
+func (c Zigbee) GetDevices(offset, limit int) ([]Zigbee, int64, error) {
 	var devices []Zigbee
-	err := Db.Debug().Model(&c).Where("is_deleted=0 and name like ? ", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
+	var count int64
+	db := Db.Debug().Model(&c).Where("is_deleted=0 and name like ? ", "%"+c.Name+"%")
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&devices).Error
+	return devices, count, err
 }
 
 func (c Zigbee) GetAllDevices() ([]Zigbee, error) {

+ 4 - 4
app/device/service/LightStrategyService.go

@@ -183,7 +183,7 @@ func (s *lightStrategyService) CreateOrUpdate(userId int64, tenantId int, req *m
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *lightStrategyService) List(searchValue string, current, size int) ([]model.LightStrategyDetail, *common.Errors) {
+func (s *lightStrategyService) List(searchValue string, current, size int) ([]model.LightStrategyDetail, int64, *common.Errors) {
 	strategy := dao.LightStrategy{}
 	if searchValue != "" {
 		strategy.LightSn = searchValue
@@ -191,9 +191,9 @@ func (s *lightStrategyService) List(searchValue string, current, size int) ([]mo
 
 	offset := (current - 1) * size
 	limit := size
-	strategies, err := strategy.GetStrategies(offset, limit)
+	strategies, total, err := strategy.GetStrategies(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 
 	timeConditions, _ := TimeConditionService.GetAll()
@@ -232,7 +232,7 @@ func (s *lightStrategyService) List(searchValue string, current, size int) ([]mo
 
 		details = append(details, detail)
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *lightStrategyService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/alarmService.go

@@ -66,16 +66,16 @@ func (s *alarmService) CreateOrUpdate(userId int64, tenantId int, req dao.Alarm)
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *alarmService) List(poleGroupName string, current, size int) ([]dao.Alarm, *common.Errors) {
+func (s *alarmService) List(poleGroupName string, current, size int) ([]dao.Alarm, int64, *common.Errors) {
 	// 创建查询实例
 	device := &dao.Alarm{}
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *alarmService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/alarmTerminalService.go

@@ -71,14 +71,14 @@ func (s *alarmTerminalService) CreateOrUpdate(userId int64, tenantId int, req da
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *alarmTerminalService) List(poleGroupName string, current, size int) ([]model.AlarmTerminalDetail, *common.Errors) {
+func (s *alarmTerminalService) List(poleGroupName string, current, size int) ([]model.AlarmTerminalDetail, int64, *common.Errors) {
 	// 创建查询实例
 	device := &dao.AlarmTerminal{}
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var details []model.AlarmTerminalDetail
 	for _, d := range devices {
@@ -90,7 +90,7 @@ func (s *alarmTerminalService) List(poleGroupName string, current, size int) ([]
 			EndLineTime:   endTime,
 		})
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *alarmTerminalService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/bridgeSensorService.go

@@ -61,7 +61,7 @@ func (s *bridgeSensorService) CreateOrUpdate(userId int64, tenantId int, req dao
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *bridgeSensorService) List(searchValue string, current, size int) ([]dao.BridgeSensor, *common.Errors) {
+func (s *bridgeSensorService) List(searchValue string, current, size int) ([]dao.BridgeSensor, int64, *common.Errors) {
 	device := dao.BridgeSensor{}
 	if searchValue != "" {
 		device.SN = searchValue
@@ -70,11 +70,11 @@ func (s *bridgeSensorService) List(searchValue string, current, size int) ([]dao
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *bridgeSensorService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/bridgeService.go

@@ -60,7 +60,7 @@ func (s *bridgeService) CreateOrUpdate(userId int64, tenantId int, req dao.Bridg
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *bridgeService) List(searchValue string, current, size int) ([]dao.Bridge, *common.Errors) {
+func (s *bridgeService) List(searchValue string, current, size int) ([]dao.Bridge, int64, *common.Errors) {
 	device := dao.Bridge{}
 	if searchValue != "" {
 		device.SN = searchValue
@@ -69,11 +69,11 @@ func (s *bridgeService) List(searchValue string, current, size int) ([]dao.Bridg
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *bridgeService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/cameraService.go

@@ -87,7 +87,7 @@ func (s *cameraService) Get(id int) (*model.CameraDetail, *common.Errors) {
 	return detail, nil
 }
 
-func (s *cameraService) List(searchValue, cameraType string, current, size int) ([]model.CameraDetail, *common.Errors) {
+func (s *cameraService) List(searchValue, cameraType string, current, size int) ([]model.CameraDetail, int64, *common.Errors) {
 	var details []model.CameraDetail
 	device := dao.CameraDevice{}
 
@@ -103,10 +103,10 @@ func (s *cameraService) List(searchValue, cameraType string, current, size int)
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 
 	for _, d := range devices {
@@ -118,7 +118,7 @@ func (s *cameraService) List(searchValue, cameraType string, current, size int)
 		})
 	}
 
-	return details, nil
+	return details, total, nil
 }
 
 func (s *cameraService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 8 - 8
app/device/service/captureUintService.go

@@ -70,7 +70,7 @@ func (s *captureUintService) GetCapture(id int) (*model.CaptureDetail, *common.E
 	return detail, nil
 }
 
-func (s *captureUintService) CaptureList(searchValue string, current, size int) ([]model.CaptureDetail, *common.Errors) {
+func (s *captureUintService) CaptureList(searchValue string, current, size int) ([]model.CaptureDetail, int64, *common.Errors) {
 	var details []model.CaptureDetail
 	device := dao.CaptureUnit{}
 
@@ -80,10 +80,10 @@ func (s *captureUintService) CaptureList(searchValue string, current, size int)
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 
 	for _, d := range devices {
@@ -95,7 +95,7 @@ func (s *captureUintService) CaptureList(searchValue string, current, size int)
 		})
 	}
 
-	return details, nil
+	return details, total, nil
 }
 
 func (s *captureUintService) CaptureGetList(tenantId int) ([]*dao.CaptureUnit, *common.Errors) {
@@ -160,7 +160,7 @@ func (s *captureUintService) PointSubmit(userId int64, tenantId int, req *dao.Ch
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *captureUintService) PointList(searchValue string, current, size int) ([]dao.CheckPoint, *common.Errors) {
+func (s *captureUintService) PointList(searchValue string, current, size int) ([]dao.CheckPoint, int64, *common.Errors) {
 	device := dao.CheckPoint{}
 	if searchValue != "" {
 		device.PointSN = searchValue
@@ -168,11 +168,11 @@ func (s *captureUintService) PointList(searchValue string, current, size int) ([
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *captureUintService) PointGetList(tenantId int) ([]*dao.CheckPoint, *common.Errors) {

+ 4 - 4
app/device/service/garbageService.go

@@ -62,7 +62,7 @@ func (s *garbageService) CreateOrUpdate(userId int64, tenantId int, req dao.Garb
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *garbageService) List(searchValue string, current, size int) ([]dao.Garbage, *common.Errors) {
+func (s *garbageService) List(searchValue string, current, size int) ([]dao.Garbage, int64, *common.Errors) {
 	device := dao.Garbage{}
 	if searchValue != "" {
 		device.DeviceSN = searchValue
@@ -71,11 +71,11 @@ func (s *garbageService) List(searchValue string, current, size int) ([]dao.Garb
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *garbageService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/garbageWayGroupService.go

@@ -63,7 +63,7 @@ func (s *garbageWayGroupService) CreateOrUpdate(userId int64, tenantId int, req
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *garbageWayGroupService) List(searchValue string, current, size int) ([]dao.GarbageWayGroup, *common.Errors) {
+func (s *garbageWayGroupService) List(searchValue string, current, size int) ([]dao.GarbageWayGroup, int64, *common.Errors) {
 	device := dao.GarbageWayGroup{}
 	if searchValue != "" {
 		device.GroupName = searchValue
@@ -71,11 +71,11 @@ func (s *garbageWayGroupService) List(searchValue string, current, size int) ([]
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *garbageWayGroupService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/gatewayService.go

@@ -88,7 +88,7 @@ func (s *gatewayService) CreateOrUpdate(userId int64, tenantId int, req *model.G
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *gatewayService) List(searchValue string, current, size int) ([]model.GatewayDetail, *common.Errors) {
+func (s *gatewayService) List(searchValue string, current, size int) ([]model.GatewayDetail, int64, *common.Errors) {
 	var details []model.GatewayDetail
 	device := dao.Gateway{}
 
@@ -98,9 +98,9 @@ func (s *gatewayService) List(searchValue string, current, size int) ([]model.Ga
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	for _, d := range devices {
 		detail := model.GatewayDetail{Gateway: d}
@@ -123,7 +123,7 @@ func (s *gatewayService) List(searchValue string, current, size int) ([]model.Ga
 		detail.NetworkState = state
 		details = append(details, detail)
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *gatewayService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/infoBoardService.go

@@ -66,7 +66,7 @@ func (s *infoBoardService) CreateOrUpdate(userId int64, tenantId int, req dao.In
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *infoBoardService) List(searchValue string, current, size int) ([]model.InfoBoardDetail, *common.Errors) {
+func (s *infoBoardService) List(searchValue string, current, size int) ([]model.InfoBoardDetail, int64, *common.Errors) {
 	device := dao.InfoBoard{}
 	if searchValue != "" {
 		device.Sn = searchValue
@@ -75,9 +75,9 @@ func (s *infoBoardService) List(searchValue string, current, size int) ([]model.
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var details []model.InfoBoardDetail
 	for _, d := range devices {
@@ -89,7 +89,7 @@ func (s *infoBoardService) List(searchValue string, current, size int) ([]model.
 			EndLineTime:  endTime,
 		})
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *infoBoardService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 6 - 3
app/device/service/intelligentLightingService.go

@@ -109,7 +109,7 @@ func (s *intelligentLightingService) BatchGet(ids []int) []dao.IntelligentLight
 }
 
 func (s *intelligentLightingService) List(tenantId int, searchValue string, current, size,
-	groupId int) ([]dao.LightrelationVo, error) {
+	groupId int) ([]dao.LightrelationVo, int64, error) {
 	var result []dao.LightrelationVo
 	//获取策略关联信息
 	intelligent := &dao.IntelligentLight{
@@ -119,7 +119,7 @@ func (s *intelligentLightingService) List(tenantId int, searchValue string, curr
 	//println("fasdf")
 	list, err := intelligent.GetByGroup2(searchValue, current, size, groupId)
 	if err != nil {
-		return nil, nil
+		return nil, 0, err
 	}
 	for _, intelligentLight := range list {
 		_, state := cache.GetDeviceState(intelligentLight.LightSn)
@@ -129,6 +129,7 @@ func (s *intelligentLightingService) List(tenantId int, searchValue string, curr
 		intelligentLight.IsShowOpts = true
 		result = append(result, intelligentLight)
 	}
+	var total int64
 	for i, vo := range result {
 		groupId := vo.Rid
 		group2, _ := intelligent.GetByGroup(searchValue, current, size, groupId)
@@ -142,10 +143,12 @@ func (s *intelligentLightingService) List(tenantId int, searchValue string, curr
 			//TODO: 这里要调用边缘接口 灯状态未实时
 			group.LightControlState = "2"
 			group2[i2] = group
+
 		}
+		total += 1
 		result[i].Children = &group2
 	}
-	return result, nil
+	return result, total, nil
 }
 
 // Relation 保存策略

+ 4 - 4
app/device/service/ipBroadcastService.go

@@ -67,7 +67,7 @@ func (s *ipBroadcastService) CreateOrUpdate(userId int64, tenantId int, req dao.
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *ipBroadcastService) List(searchValue string, current, size int) ([]model.IpBroadcastDetail, *common.Errors) {
+func (s *ipBroadcastService) List(searchValue string, current, size int) ([]model.IpBroadcastDetail, int64, *common.Errors) {
 	device := dao.IpBroadcast{}
 	if searchValue != "" {
 		device.CastSn = searchValue
@@ -76,9 +76,9 @@ func (s *ipBroadcastService) List(searchValue string, current, size int) ([]mode
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var details []model.IpBroadcastDetail
 	for _, d := range devices {
@@ -90,7 +90,7 @@ func (s *ipBroadcastService) List(searchValue string, current, size int) ([]mode
 			EndLineTime:  endTime,
 		})
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *ipBroadcastService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/lampPoleGroupService.go

@@ -63,7 +63,7 @@ func (s *lampPoleGroupService) CreateOrUpdate(userId int64, tenantId int, req *d
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *lampPoleGroupService) List(poleGroupName string, current, size int) ([]dao.LampPoleGroup, *common.Errors) {
+func (s *lampPoleGroupService) List(poleGroupName string, current, size int) ([]dao.LampPoleGroup, int64, *common.Errors) {
 	// 创建查询实例
 	device := &dao.LampPoleGroup{
 		PoleGroupName: poleGroupName,
@@ -71,16 +71,16 @@ func (s *lampPoleGroupService) List(poleGroupName string, current, size int) ([]
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	for i, group := range devices {
 		poleGroup := dao.LampPole{}
 		poleGroup.GroupId = group.ID
 		devices[i].CountLampPole, _ = poleGroup.GetGroupIdCount()
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *lampPoleGroupService) Remove(userId int64, tenantId int, id int, name string) *common.Errors {

+ 4 - 4
app/device/service/lampPoleService.go

@@ -85,7 +85,7 @@ func (s *lampPoleService) CreateOrUpdate(userId int64, tenantId int, req *dao.La
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *lampPoleService) List(searchValue, groupId, boxId string, current, size int) ([]dao.LampPole, *common.Errors) {
+func (s *lampPoleService) List(searchValue, groupId, boxId string, current, size int) ([]dao.LampPole, int64, *common.Errors) {
 	device := dao.LampPole{}
 	if searchValue != "" {
 		device.PoleSN = searchValue
@@ -96,11 +96,11 @@ func (s *lampPoleService) List(searchValue, groupId, boxId string, current, size
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *lampPoleService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/lightControlService.go

@@ -106,7 +106,7 @@ func (s *lightControlService) CreateOrUpdate(userId int64, tenantId int, req *da
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *lightControlService) List(searchValue, controlType, zigbeeId string, current, size int) ([]model.LightControlDetail,
+func (s *lightControlService) List(searchValue, controlType, zigbeeId string, current, size int) ([]model.LightControlDetail, int64,
 	*common.Errors) {
 	device := dao.LightControl{}
 	if searchValue != "" {
@@ -127,9 +127,9 @@ func (s *lightControlService) List(searchValue, controlType, zigbeeId string, cu
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var details []model.LightControlDetail
 	for _, d := range devices {
@@ -140,7 +140,7 @@ func (s *lightControlService) List(searchValue, controlType, zigbeeId string, cu
 		detail.NetworkState = state
 		details = append(details, detail)
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *lightControlService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/manholeCoverService.go

@@ -60,7 +60,7 @@ func (s *manholeCoverService) CreateOrUpdate(userId int64, tenantId int, req dao
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *manholeCoverService) List(searchValue string, current, size int) ([]dao.ManholeCover, *common.Errors) {
+func (s *manholeCoverService) List(searchValue string, current, size int) ([]dao.ManholeCover, int64, *common.Errors) {
 	device := dao.ManholeCover{}
 	if searchValue != "" {
 		device.ManholeSn = searchValue
@@ -69,11 +69,11 @@ func (s *manholeCoverService) List(searchValue string, current, size int) ([]dao
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *manholeCoverService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/onDemandSensorService.go

@@ -60,7 +60,7 @@ func (s *onDemandSensorService) CreateOrUpdate(userId int64, tenantId int, req d
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *onDemandSensorService) List(searchValue string, current, size int) ([]dao.OnDemandSensor, *common.Errors) {
+func (s *onDemandSensorService) List(searchValue string, current, size int) ([]dao.OnDemandSensor, int64, *common.Errors) {
 	device := dao.OnDemandSensor{}
 	if searchValue != "" {
 		device.SN = searchValue
@@ -69,11 +69,11 @@ func (s *onDemandSensorService) List(searchValue string, current, size int) ([]d
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *onDemandSensorService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/optoSensoService.go

@@ -67,7 +67,7 @@ func (s *optoSensorService) CreateOrUpdate(userId int64, tenantId int, req dao.O
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *optoSensorService) List(searchValue string, current, size int) ([]model.OptoSensorDetail, *common.Errors) {
+func (s *optoSensorService) List(searchValue string, current, size int) ([]model.OptoSensorDetail, int64, *common.Errors) {
 	device := dao.OptoSensor{}
 	if searchValue != "" {
 		device.Sn = searchValue
@@ -76,9 +76,9 @@ func (s *optoSensorService) List(searchValue string, current, size int) ([]model
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var details []model.OptoSensorDetail
 	for _, d := range devices {
@@ -90,7 +90,7 @@ func (s *optoSensorService) List(searchValue string, current, size int) ([]model
 			EndLineTime:  endTime,
 		})
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *optoSensorService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/switchBoxService.go

@@ -65,7 +65,7 @@ func (s *switchBoxService) CreateOrUpdate(userId int64, tenantId int, req dao.Sw
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *switchBoxService) List(searchValue string, current, size int) ([]dao.SwitchBox, *common.Errors) {
+func (s *switchBoxService) List(searchValue string, current, size int) ([]dao.SwitchBox, int64, *common.Errors) {
 	device := dao.SwitchBox{}
 	if searchValue != "" {
 		device.BoxSN = searchValue
@@ -74,9 +74,9 @@ func (s *switchBoxService) List(searchValue string, current, size int) ([]dao.Sw
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	//关联灯杆
 	for i, box := range devices {
@@ -84,7 +84,7 @@ func (s *switchBoxService) List(searchValue string, current, size int) ([]dao.Sw
 		pole.BoxId = box.ID
 		devices[i].CountLampPole, _ = pole.GetSwitchBoxCount()
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *switchBoxService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/transformerService.go

@@ -63,7 +63,7 @@ func (s *transformerService) CreateOrUpdate(userId int64, tenantId int, req dao.
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *transformerService) List(searchValue string, current, size int) ([]dao.Transformer, *common.Errors) {
+func (s *transformerService) List(searchValue string, current, size int) ([]dao.Transformer, int64, *common.Errors) {
 	device := dao.Transformer{}
 	if searchValue != "" {
 		device.TransSN = searchValue
@@ -72,16 +72,16 @@ func (s *transformerService) List(searchValue string, current, size int) ([]dao.
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 
 	for i, transformer := range devices {
 		switchBox := dao.SwitchBox{TransformerId: transformer.ID}
 		devices[i].CountNum, _ = switchBox.GetDeviceCount()
 	}
-	return devices, nil
+	return devices, total, nil
 }
 
 func (s *transformerService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/device/service/zigbeeService.go

@@ -68,7 +68,7 @@ func (s *zigbeeService) CreateOrUpdate(userId int64, tenantId int, req dao.Zigbe
 	return common.SuccessResponse(common.Succeeded, nil)
 }
 
-func (s *zigbeeService) List(searchValue string, current, size int) ([]model.ZigbeeDetail, *common.Errors) {
+func (s *zigbeeService) List(searchValue string, current, size int) ([]model.ZigbeeDetail, int64, *common.Errors) {
 	device := dao.Zigbee{}
 	if searchValue != "" {
 		device.Sn = searchValue
@@ -77,9 +77,9 @@ func (s *zigbeeService) List(searchValue string, current, size int) ([]model.Zig
 
 	offset := (current - 1) * size
 	limit := size
-	devices, err := device.GetDevices(offset, limit)
+	devices, total, err := device.GetDevices(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var details []model.ZigbeeDetail
 	for _, d := range devices {
@@ -91,7 +91,7 @@ func (s *zigbeeService) List(searchValue string, current, size int) ([]model.Zig
 			EndLineTime:  endTime,
 		})
 	}
-	return details, nil
+	return details, total, nil
 }
 
 func (s *zigbeeService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 3 - 3
app/multimedia/controller/libraryController.go

@@ -55,16 +55,16 @@ func (c *libraryCtl) List(ctx *gin.Context) {
 
 	value, _ := ctx.Get(middleware.Authorization)
 	claims := value.(*middleware.Claims)
-	libraries, err := service.LibraryService.List(claims.TenantId, searchValue, current, size, sysType, libType)
+	libraries, total, err := service.LibraryService.List(claims.TenantId, searchValue, current, size, sysType, libType)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(libraries)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqLibraryList{
 		Current: current,
 		Size:    size,
-		Total:   len(libraries),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: libraries,
 	}

+ 3 - 3
app/multimedia/controller/programController.go

@@ -48,16 +48,16 @@ func (c *programCtl) List(ctx *gin.Context) {
 	value, _ := ctx.Get(middleware.Authorization)
 	claims := value.(*middleware.Claims)
 
-	libraries, err := service.ProgramService.List(claims.TenantId, searchValue, current, size, sysType)
+	libraries, total, err := service.ProgramService.List(claims.TenantId, searchValue, current, size, sysType)
 	if err != nil {
 		ctx.JSON(http.StatusOK, err)
 		return
 	}
-	pages := math.Ceil(float64(len(libraries)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqProgramList{
 		Current: current,
 		Size:    size,
-		Total:   len(libraries),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: libraries,
 	}

+ 3 - 3
app/multimedia/controller/publishLibrariesController.go

@@ -33,7 +33,7 @@ func (c *PublishLibrariesCtl) List(ctx *gin.Context) {
 	value, _ := ctx.Get(middleware.Authorization)
 	claims := value.(*middleware.Claims)
 
-	libraries, err := service.PublishLibrariesService.List(claims.TenantId, searchValue, current, size, sysType)
+	libraries, total, err := service.PublishLibrariesService.List(claims.TenantId, searchValue, current, size, sysType)
 	for i, library := range libraries {
 		stime := library.StartTime.DateString()
 		etime := library.EndTime.DateString()
@@ -46,11 +46,11 @@ func (c *PublishLibrariesCtl) List(ctx *gin.Context) {
 		return
 	}
 
-	pages := math.Ceil(float64(len(libraries)) / float64(size))
+	pages := math.Ceil(float64(total) / float64(size))
 	rsp := model.RsqPublishLibrariesList{
 		Current: current,
 		Size:    size,
-		Total:   len(libraries),
+		Total:   int(total),
 		Pages:   int(pages),
 		Records: libraries,
 	}

+ 6 - 3
app/multimedia/dao/libraryDao.go

@@ -32,8 +32,9 @@ func (c *Library) Create() error {
 	return Db.Debug().Model(&c).Save(c).Error
 }
 
-func (c *Library) GetLibraries(offset, limit int) ([]Library, error) {
+func (c *Library) GetLibraries(offset, limit int) ([]Library, int64, error) {
 	var libraries []Library
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.LibName != "" {
 		db = db.Where("lib_name like ?", "%"+c.LibName+"%")
@@ -45,8 +46,10 @@ func (c *Library) GetLibraries(offset, limit int) ([]Library, error) {
 		db = db.Where("lib_type = ?", c.LibType)
 	}
 
-	err := db.Where("is_deleted = 0 and tenant_id = ?", c.TenantId).Offset(offset).Limit(limit).Find(&libraries).Error
-	return libraries, err
+	db = db.Where("is_deleted = 0 and tenant_id = ?", c.TenantId)
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&libraries).Error
+	return libraries, count, err
 }
 
 func (c *Library) Get() error {

+ 6 - 3
app/multimedia/dao/programDao.go

@@ -33,8 +33,9 @@ func (c *Program) Remove() error {
 	return Db.Debug().Model(&c).Where("id = ?", c.ID).Delete(c).Error
 }
 
-func (c *Program) GetPrograms(offset, limit int) ([]Program, error) {
+func (c *Program) GetPrograms(offset, limit int) ([]Program, int64, error) {
 	var Programs []Program
+	var count int64
 	db := Db.Debug().Model(&c)
 	if c.Name != "" {
 		db = db.Where("name like ?", "%"+c.Name+"%")
@@ -43,8 +44,10 @@ func (c *Program) GetPrograms(offset, limit int) ([]Program, error) {
 		db = db.Where("sys_type = ?", c.SysType)
 	}
 
-	err := db.Where("is_deleted = 0 and tenant_id = ?", c.TenantId).Offset(offset).Limit(limit).Find(&Programs).Error
-	return Programs, err
+	db = db.Where("is_deleted = 0 and tenant_id = ?", c.TenantId)
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&Programs).Error
+	return Programs, count, err
 }
 
 func (c *Program) Get() error {

+ 6 - 3
app/multimedia/dao/publishLibrariesDao.go

@@ -43,10 +43,13 @@ func (PublishLibraries) TableName() string {
 	return "media_publish_libraries"
 }
 
-func (c *PublishLibraries) GetList(offset int, limit int) ([]PublishLibraries, error) {
+func (c *PublishLibraries) GetList(offset int, limit int) ([]PublishLibraries, int64, error) {
 	var list []PublishLibraries
-	err := Db.Debug().Model(&c).Where("tenant_id = ? and sys_type=? and is_deleted = 0", c.TenantId, c.SysType).Find(&list).Error
-	return list, err
+	var count int64
+	db := Db.Debug().Model(&c).Where("tenant_id = ? and sys_type=? and is_deleted = 0", c.TenantId, c.SysType)
+	db.Count(&count)
+	err := db.Offset(offset).Limit(limit).Find(&list).Error
+	return list, count, err
 }
 
 func (c *PublishLibraries) Create() error {

+ 4 - 4
app/multimedia/service/libraryService.go

@@ -29,7 +29,7 @@ func (s *libraryService) Get(id int) (*dao.Library, *common.Errors) {
 	return library, nil
 }
 
-func (s *libraryService) List(tenantId int, searchValue string, current, size, sysType, libType int) ([]model.LibraryDetail,
+func (s *libraryService) List(tenantId int, searchValue string, current, size, sysType, libType int) ([]model.LibraryDetail, int64,
 	*common.Errors) {
 	library := &dao.Library{
 		TenantId: tenantId,
@@ -47,16 +47,16 @@ func (s *libraryService) List(tenantId int, searchValue string, current, size, s
 		library.SysType = sysType
 	}
 	//fmt.Printf("sysType = %v", sysType)
-	libraries, err := library.GetLibraries(offset, limit)
+	libraries, total, err := library.GetLibraries(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 
 	var rsp []model.LibraryDetail
 	for _, lib := range libraries {
 		rsp = append(rsp, model.LibToModel(lib))
 	}
-	return rsp, nil
+	return rsp, total, nil
 }
 
 func (s *libraryService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/multimedia/service/programService.go

@@ -25,7 +25,7 @@ func (s *programService) Get(id int) (*dao.Program, *common.Errors) {
 	return Program, nil
 }
 
-func (s *programService) List(tenantId int, searchValue string, current, size, sysType int) ([]model.ProgramDetail,
+func (s *programService) List(tenantId int, searchValue string, current, size, sysType int) ([]model.ProgramDetail, int64,
 	*common.Errors) {
 	program := &dao.Program{
 		TenantId: tenantId,
@@ -39,9 +39,9 @@ func (s *programService) List(tenantId int, searchValue string, current, size, s
 		program.SysType = sysType
 	}
 
-	programs, err := program.GetPrograms(offset, limit)
+	programs, total, err := program.GetPrograms(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
 	var rsp []model.ProgramDetail
 	for _, pro := range programs {
@@ -50,7 +50,7 @@ func (s *programService) List(tenantId int, searchValue string, current, size, s
 			ResolutionName: service.DictService.GetResolutionName(tenantId, pro.Resolution),
 		})
 	}
-	return rsp, nil
+	return rsp, total, nil
 }
 
 func (s *programService) Remove(userId int64, tenantId int, id int) *common.Errors {

+ 4 - 4
app/multimedia/service/publishLibrariesService.go

@@ -18,7 +18,7 @@ type publishLibrariesService struct{}
 TODO: 此接口都未对接边缘端
 */
 
-func (s *publishLibrariesService) List(tenantId int, searchValue string, current, size int, sysType int) ([]dao.PublishLibraries,
+func (s *publishLibrariesService) List(tenantId int, searchValue string, current, size int, sysType int) ([]dao.PublishLibraries, int64,
 	*common.Errors) {
 	program := &dao.PublishLibraries{
 		TenantId: tenantId,
@@ -29,11 +29,11 @@ func (s *publishLibrariesService) List(tenantId int, searchValue string, current
 	if searchValue != "" {
 		program.Name = searchValue
 	}
-	list, err := program.GetList(offset, limit)
+	list, total, err := program.GetList(offset, limit)
 	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
+		return nil, 0, common.FailResponse(err.Error(), nil)
 	}
-	return list, nil
+	return list, total, nil
 }
 
 // Audit 素材发布