|
@@ -5,10 +5,12 @@ import (
|
|
|
"iot_manager_service/app/middleware"
|
|
"iot_manager_service/app/middleware"
|
|
|
"iot_manager_service/app/multimedia/model"
|
|
"iot_manager_service/app/multimedia/model"
|
|
|
"iot_manager_service/app/multimedia/service"
|
|
"iot_manager_service/app/multimedia/service"
|
|
|
|
|
+ service2 "iot_manager_service/app/system/service"
|
|
|
"iot_manager_service/util/common"
|
|
"iot_manager_service/util/common"
|
|
|
"math"
|
|
"math"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
|
|
+ "strings"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var PublishLibraries = new(PublishLibrariesCtl)
|
|
var PublishLibraries = new(PublishLibrariesCtl)
|
|
@@ -19,21 +21,29 @@ func (c *PublishLibrariesCtl) List(ctx *gin.Context) {
|
|
|
searchValue := ctx.Query("searchValue")
|
|
searchValue := ctx.Query("searchValue")
|
|
|
current, _ := strconv.Atoi(ctx.Query("current"))
|
|
current, _ := strconv.Atoi(ctx.Query("current"))
|
|
|
size, _ := strconv.Atoi(ctx.Query("size"))
|
|
size, _ := strconv.Atoi(ctx.Query("size"))
|
|
|
-
|
|
|
|
|
|
|
+ sysType, _ := strconv.Atoi(ctx.Query("sysType"))
|
|
|
if current == 0 {
|
|
if current == 0 {
|
|
|
current = 1
|
|
current = 1
|
|
|
}
|
|
}
|
|
|
if size <= 0 || size > 100 {
|
|
if size <= 0 || size > 100 {
|
|
|
size = 10
|
|
size = 10
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
value, _ := ctx.Get(middleware.Authorization)
|
|
value, _ := ctx.Get(middleware.Authorization)
|
|
|
claims := value.(*middleware.Claims)
|
|
claims := value.(*middleware.Claims)
|
|
|
- libraries, err := service.PublishLibrariesService.List(claims.TenantId, searchValue, current, size)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ libraries, err := service.PublishLibrariesService.List(claims.TenantId, searchValue, current, size, sysType)
|
|
|
|
|
+ for i, library := range libraries {
|
|
|
|
|
+ stime := library.StartTime.DateString()
|
|
|
|
|
+ etime := library.EndTime.DateString()
|
|
|
|
|
+ libraries[i].PlayPeriod = stime + " - " + etime
|
|
|
|
|
+ libraries[i].ResolutionName = service2.DictService.GetResolutionName(library.TenantId, library.Resolution)
|
|
|
|
|
+ libraries[i].CountDeviceNum = len(strings.Split(library.InfoId, ","))
|
|
|
|
|
+ }
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
ctx.JSON(http.StatusOK, err)
|
|
ctx.JSON(http.StatusOK, err)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
pages := math.Ceil(float64(len(libraries)) / float64(size))
|
|
pages := math.Ceil(float64(len(libraries)) / float64(size))
|
|
|
rsp := model.RsqPublishLibrariesList{
|
|
rsp := model.RsqPublishLibrariesList{
|
|
|
Current: current,
|
|
Current: current,
|
|
@@ -44,3 +54,59 @@ func (c *PublishLibrariesCtl) List(ctx *gin.Context) {
|
|
|
}
|
|
}
|
|
|
ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
|
|
ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func (c *PublishLibrariesCtl) GetLibraryList(ctx *gin.Context) {
|
|
|
|
|
+ id := ctx.Query("id")
|
|
|
|
|
+ librariesId, e := strconv.Atoi(id)
|
|
|
|
|
+ if e != nil {
|
|
|
|
|
+ ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ value, _ := ctx.Get(middleware.Authorization)
|
|
|
|
|
+ claims := value.(*middleware.Claims)
|
|
|
|
|
+
|
|
|
|
|
+ programId, err := service.PublishLibrariesService.GetProgram(librariesId)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ list, errors := service.ProgramService.GetLibraryList(claims.TenantId, programId)
|
|
|
|
|
+ if errors != nil {
|
|
|
|
|
+ ctx.JSON(http.StatusOK, e)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, list))
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// AffiliateEquipment 关联设备
|
|
|
|
|
+func (c *PublishLibrariesCtl) AffiliateEquipment(ctx *gin.Context) {
|
|
|
|
|
+ sysType, _ := strconv.Atoi(ctx.Query("sysType"))
|
|
|
|
|
+ deviceIds := ctx.Query("infoId") //设备id
|
|
|
|
|
+ value, _ := ctx.Get(middleware.Authorization)
|
|
|
|
|
+ claims := value.(*middleware.Claims)
|
|
|
|
|
+
|
|
|
|
|
+ devices, err := service.ProgramService.RelationDeviceListByIds(claims.TenantId, sysType, deviceIds)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ ctx.JSON(http.StatusOK, err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, devices))
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 变更状态
|
|
|
|
|
+func (c *PublishLibrariesCtl) UpdateStatus(ctx *gin.Context) {
|
|
|
|
|
+ id, _ := strconv.Atoi(ctx.Query("id"))
|
|
|
|
|
+ status, _ := strconv.Atoi(ctx.Query("status"))
|
|
|
|
|
+ name := ctx.Query("name")
|
|
|
|
|
+ value, _ := ctx.Get(middleware.Authorization)
|
|
|
|
|
+ claims := value.(*middleware.Claims)
|
|
|
|
|
+
|
|
|
|
|
+ _, err := service.PublishLibrariesService.UpdateStatus(claims.TenantId, id, status, name)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ ctx.JSON(http.StatusOK, err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
|
|
|
|
|
+}
|