Browse Source

分页添加总数

longan 1 year ago
parent
commit
c64c94d103
3 changed files with 4 additions and 62 deletions
  1. 2 2
      api/v1/app/gateway.go
  2. 0 59
      config.yaml
  3. 2 1
      service/app/gateway.go

+ 2 - 2
api/v1/app/gateway.go

@@ -35,14 +35,14 @@ func (api *GatewayApi) List(c *gin.Context) {
 	v3 := c.Query("page")
 	req.Page, _ = strconv.Atoi(v3)
 
-	list, err := gs.List(req)
+	list, total, err := gs.List(req)
 	if err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	response.OkWithDetailed(response.PageResult{
 		List:     list,
-		Total:    int64(len(list)),
+		Total:    total,
 		Page:     req.Page,
 		PageSize: req.PageSize,
 	}, "获取成功", c)

+ 0 - 59
config.yaml

@@ -1,59 +0,0 @@
-#系统/后台相关
-system:
-  env: public
-  addr: 8889
-  db-type: mysql
-  oss-type: local
-  use-multipoint: false
-  use-redis: true
-  iplimit-count: 15000
-  iplimit-time: 3600
-  router-prefix: ""
-jwt:
-  signing-key: 86e7a688-8d7d-42a5-af86-ec61120601d5
-  expires-time: 100d
-  buffer-time: 1d
-  issuer: qmPlus
-captcha:
-  key-long: 6     #验证码长度
-  img-width: 240  #宽
-  img-height: 80  #高
-  open-captcha: 0 #开启验证码 1关闭,0开启
-  open-captcha-timeout: 3600  #有效期
-logrus:
-mysql:
-  path: 192.168.110.69
-  port: "3306"
-  config: charset=utf8mb4&parseTime=True&loc=Local
-  db-name: lcfns
-  username: root
-  password: root
-  prefix: ""
-  singular: false
-  engine: ""
-  max-idle-conns: 10
-  max-open-conns: 100
-  log-mode: info
-  log-zap: false
-#海康摄像头事件监听服务器,最多配三个,只需修改id,url,ipAddress和portNo
-HttpHostNotificationList:
-  HttpHostNotification:
-    -
-      id: 1
-      url: /event
-      protocolType: HTTP
-      parameterFormatType: XML
-      addressingFormatType: ipaddress
-      ipAddress: 192.168.110.69
-      portNo: 8850
-      httpBroken: true
-      httpAuthenticationMethod: none
-#调用外部接口
-foreign:
-  securityRewindUrl: "http://106.52.134.22:9099"
-  gatewayServer: "192.168.110.253:9001"
-#海康摄像头统一配置
-hikvision:
-  user: admin
-  password: kk176@lc
-  streamBaseUrl: "webrtc://106.52.134.22/live/"

+ 2 - 1
service/app/gateway.go

@@ -34,7 +34,7 @@ func (gs *GatewayService) CreateIfNotExist(isn string) (*app.Gateway, error) {
 }
 
 // List 该用户下所有设备数据
-func (gs *GatewayService) List(req request.GatewayRequest) (list []response.Gateways, err error) {
+func (gs *GatewayService) List(req request.GatewayRequest) (list []response.Gateways, total int64, err error) {
 	//SELECT g.id,g.name AS gateway_name,g.osn,
 	//	c.`name` AS camera_name, RIGHT(c.sn,9) AS sn,stream_id,stream_url,
 	//	l.device_id AS ls_id,l.`status` AS ls_status
@@ -65,6 +65,7 @@ func (gs *GatewayService) List(req request.GatewayRequest) (list []response.Gate
 		db.Offset(req.PageSize * (req.Page - 1)).Limit(req.PageSize)
 	}
 	err = db.Debug().Find(&list).Error
+	db.Where("is_deleted = 0").Count(&total)
 	return
 }