zoukankan      html  css  js  c++  java
  • RTSP协议网络摄像头接入视频平台EasyNVR实现网页无插件直播后台导出用户信息是如何实现的?

    了解TSINGSEE青犀视频产品的用户都知道,作为专注于音视频流媒体行业的研发团队,我们一直都在追求更前沿的技术,比如H265接入与播放、比如在能力平台上叠加上业务功能,如:用户管理、设备管理等。最近我们就对RTSP协议网络摄像头接入视频平台EasyNVR进行了一次功能的迭代更新,升级后界面直播,视频编码兼容性更强,同时也增加了用户管理功能。有此功能需求的用户可以官网下载更新啦。

    新版EasyNVR用户管理不仅能够添加角色,分配设备,当用户或者角色过多时,还能将用户/角色下载表格,表格里对应了用户的通道、密码,对用户及设备进行表格管理,让运营者获取数据更加便捷。

    这个功能刚上线时,我们内部对此做了一系列的测试,并且随后又添加了用户的邮箱和手机号,便于查找。但在测试的时候,发现EasyNVR导出的用户excel表格里,新增的邮箱和手机号并没有被导出,导出的内容还是旧数据。

    我考虑可能是接口调用的代码错误,于是从EasyNVR导出excel接口开始排查错误:

    users := make([]*models.User, 0)
    models.DB.Table("user").Order("id").Find(&users)
    for i := 0; i < len(users); i++ {
       user := users[i]
       row := userSheet.AddRow()
       row.SetHeightCM(1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%v", user.ID)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%v", user.Name)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%v", user.Username)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", user.Password)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%v", user.Role)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%v", user.Phone)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%v", user.Email)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", user.Reserve1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", user.Reserve2)
    }
    

      

    上面实际上在理论上是没有问题的,但是新版的EasyNVR多出了角色、角色设备、分组、分组设备,于是我们需要把这些详细内容都添加进导出代码。

     
    //用户角色表
    userRoles := make([]*models.UserRole, 0)
    models.DB.Table("user_roles").Order("id").Find(&userRoles)
    for i := 0; i < len(userRoles); i++ {
       userRole := userRoles[i]
       row := userRoleSheet.AddRow()
       row.SetHeightCM(1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", userRole.Id)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", userRole.Uid)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", userRole.Rid)
    }
    //角色表
    roles := make([]*models.Role, 0)
    models.DB.Table("roles").Order("id").Find(&roles)
    for i := 0; i < len(roles); i++ {
       role := roles[i]
       row := roleSheet.AddRow()
       row.SetHeightCM(1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", role.ID)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", role.Name)
    }
    //角色设备表
    roleCameras := make([]*models.RoleCamera, 0)
    models.DB.Table("role_camera").Order("role_id").Find(&roleCameras)
    for i := 0; i < len(roleCameras); i++ {
       roleCamera := roleCameras[i]
       row := roleCameraSheet.AddRow()
       row.SetHeightCM(1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", roleCamera.RoleId)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", roleCamera.CameraId)
    }
    //分组表
    labels := make([]*models.Label, 0)
    models.DB.Table("label").Order("id").Find(&labels)
    for i := 0; i < len(labels); i++ {
       label := labels[i]
       row := labelSheet.AddRow()
       row.SetHeightCM(1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", label.ID)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", label.Name)
    }
    //分组设备表
    labelCameras := make([]*models.LabelCamera, 0)
    models.DB.Table("label_camera").Order("label_id").Find(&labelCameras)
    for i := 0; i < len(labelCameras); i++ {
       labelCamera := labelCameras[i]
       row := labelCameraSheet.AddRow()
       row.SetHeightCM(1)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%d", labelCamera.LabelId)
       cell = row.AddCell()
       cell.Value = fmt.Sprintf("%s", labelCamera.CameraId)
    }
     
    

      

    在代码中将内容信息补全后,再次导出,就可以发现新增内容都添加完善了。

    EasyNVR视频平台播放界面:

     
  • 相关阅读:
    第一阶段-坑爹猴
    终于做出来了
    一天就制作成了这些
    累成狗做出来的
    一周的学习,组合起来的成就
    刚刚出炉的搜狗浏览器最新版本
    自己动手设计了一下下百度首页
    数论:卢卡斯定理(求组合数)
    数据结构:ST表模板(可维护区间RMQ)
    快读和快写(可以使用__int128)
  • 原文地址:https://www.cnblogs.com/EasyNVR/p/13533403.html
Copyright © 2011-2022 走看看