瀏覽代碼

媒体资源submit 日志修改

terry 2 年之前
父節點
當前提交
2188a0c881
共有 39 個文件被更改,包括 484 次插入121 次删除
  1. 5 4
      app/device/service/LightStrategyService.go
  2. 5 4
      app/device/service/alarmService.go
  3. 5 5
      app/device/service/alarmTerminalService.go
  4. 4 4
      app/device/service/bridgeSensorService.go
  5. 4 4
      app/device/service/bridgeService.go
  6. 6 6
      app/device/service/cameraService.go
  7. 9 9
      app/device/service/captureUintService.go
  8. 4 3
      app/device/service/garbageService.go
  9. 4 3
      app/device/service/garbageWayGroupService.go
  10. 7 6
      app/device/service/gatewayService.go
  11. 4 4
      app/device/service/infoBoardService.go
  12. 4 4
      app/device/service/ipBroadcastService.go
  13. 5 4
      app/device/service/lampPoleGroupService.go
  14. 5 5
      app/device/service/lampPoleService.go
  15. 6 6
      app/device/service/lightControlService.go
  16. 4 4
      app/device/service/manholeCoverService.go
  17. 5 4
      app/device/service/onDemandGroupService.go
  18. 4 4
      app/device/service/onDemandSensorService.go
  19. 4 4
      app/device/service/optoSensoService.go
  20. 4 3
      app/device/service/switchBoxService.go
  21. 2 2
      app/device/service/timeConditionService.go
  22. 4 3
      app/device/service/transformerService.go
  23. 4 4
      app/device/service/zigbeeService.go
  24. 84 0
      app/multimedia/controller/libraryController.go
  25. 30 1
      app/multimedia/dao/libraryDao.go
  26. 42 2
      app/multimedia/model/library.go
  27. 140 0
      app/multimedia/service/libraryService.go
  28. 5 3
      app/system/service/dictService.go
  29. 2 2
      app/system/service/operationHisService.go
  30. 2 1
      app/system/service/roleService.go
  31. 2 1
      app/system/service/tenantService.go
  32. 2 1
      app/system/service/userService.go
  33. 7 0
      config/config.go
  34. 5 0
      config/config.yaml
  35. 13 5
      go.mod
  36. 31 5
      go.sum
  37. 2 1
      main.go
  38. 4 0
      router/router.go
  39. 5 0
      util/logger/logger.go

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

@@ -6,6 +6,7 @@ import (
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"sort"
 	"time"
 )
@@ -41,7 +42,7 @@ func (s *lightStrategyService) Get(id int) (*model.LightStrategyDetail, *common.
 func (s *lightStrategyService) CreateOrUpdate(userId int64, tenantId int, req *model.LightStrategyDetail) *common.Errors {
 	// 创建查询实例
 	strategy := req
-	fmt.Printf("CreateOrUpdate strategy = %+v \n", strategy)
+	logger.Logger.Errorf("CreateOrUpdate strategy = %+v \n", strategy)
 	strategy.TenantId = tenantId
 	strategy.UpdateUser = userId
 	strategy.UpdateTime = time.Now()
@@ -80,7 +81,7 @@ func (s *lightStrategyService) CreateOrUpdate(userId int64, tenantId int, req *m
 		strategy.CreateTime = time.Now()
 		strategy.CreateUser = userId
 		if strategy.IsExistedBySN() {
-			fmt.Printf("Create GetstrategyID err \n")
+			logger.Logger.Errorf("Create GetstrategyID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 	}
@@ -157,12 +158,12 @@ func (s *lightStrategyService) CreateOrUpdate(userId int64, tenantId int, req *m
 	//存数据库
 	if strategy.ID == 0 {
 		if err := strategy.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 	} else {
 		if err := strategy.Update(); err != nil {
-			fmt.Printf("Update err = %s \n", err.Error())
+			logger.Logger.Errorf("Update err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 	}

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

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -38,11 +39,11 @@ func (s *alarmService) CreateOrUpdate(userId int64, tenantId int, req dao.Alarm)
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedName, nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -51,12 +52,12 @@ func (s *alarmService) CreateOrUpdate(userId int64, tenantId int, req dao.Alarm)
 	}
 
 	if device.IsExistedByNameAndCode() {
-		fmt.Printf("Update IsExistedByNameAndCode \n")
+		logger.Logger.Errorf("Update IsExistedByNameAndCode \n")
 		return common.ParamsInvalidResponse(model.RepeatedName, nil)
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -44,11 +44,11 @@ func (s *alarmTerminalService) CreateOrUpdate(userId int64, tenantId int, req da
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedName, nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -57,12 +57,12 @@ func (s *alarmTerminalService) CreateOrUpdate(userId int64, tenantId int, req da
 	}
 
 	if device.IsExistedByNameAndCode() {
-		fmt.Printf("Update IsExistedByNameAndCode \n")
+		logger.Logger.Errorf("Update IsExistedByNameAndCode \n")
 		return common.ParamsInvalidResponse(model.RepeatedName, nil)
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,11 +1,11 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -36,11 +36,11 @@ func (s *bridgeSensorService) CreateOrUpdate(userId int64, tenantId int, req dao
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -52,7 +52,7 @@ func (s *bridgeSensorService) CreateOrUpdate(userId int64, tenantId int, req dao
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,10 +1,10 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -34,11 +34,11 @@ func (s *bridgeService) CreateOrUpdate(userId int64, tenantId int, req dao.Bridg
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -51,7 +51,7 @@ func (s *bridgeService) CreateOrUpdate(userId int64, tenantId int, req dao.Bridg
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"strconv"
 	"time"
 )
@@ -31,7 +31,7 @@ func (s *cameraService) CreateOrUpdate(userId int64, tenantId int, req *model.Ca
 			device.LampPoleLocation = lampPole.InstallLocation
 			device.GroupId = lampPole.GroupId
 		} else {
-			fmt.Printf("LampPoleService.GetOne err = %v \n", err)
+			logger.Logger.Errorf("LampPoleService.GetOne err = %v \n", err)
 		}
 	}
 
@@ -40,12 +40,12 @@ func (s *cameraService) CreateOrUpdate(userId int64, tenantId int, req *model.Ca
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -54,7 +54,7 @@ func (s *cameraService) CreateOrUpdate(userId int64, tenantId int, req *model.Ca
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -30,12 +30,12 @@ func (s *captureUintService) CaptureSubmit(userId int64, tenantId int, req *mode
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -44,7 +44,7 @@ func (s *captureUintService) CaptureSubmit(userId int64, tenantId int, req *mode
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 
@@ -137,12 +137,12 @@ func (s *captureUintService) PointSubmit(userId int64, tenantId int, req *dao.Ch
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -151,7 +151,7 @@ func (s *captureUintService) PointSubmit(userId int64, tenantId int, req *dao.Ch
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -37,11 +38,11 @@ func (s *garbageService) CreateOrUpdate(userId int64, tenantId int, req dao.Garb
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -53,7 +54,7 @@ func (s *garbageService) CreateOrUpdate(userId int64, tenantId int, req dao.Garb
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 	service.OperationHisService.Save(userId, tenantId, common.OperationUpdate, common.ModuleTypeDevice,

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

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -37,11 +38,11 @@ func (s *garbageWayGroupService) CreateOrUpdate(userId int64, tenantId int, req
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedByName() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("存在重名,请更改名称!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -53,7 +54,7 @@ func (s *garbageWayGroupService) CreateOrUpdate(userId int64, tenantId int, req
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

+ 7 - 6
app/device/service/gatewayService.go

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -31,7 +32,7 @@ func (s *gatewayService) Get(id int) (*model.GatewayDetail, *common.Errors) {
 	if e == nil {
 		detail.CountLampPole = relation.Total
 	} else {
-		fmt.Printf("GatewayRelationService.Get err = %v", err)
+		logger.Logger.Errorf("GatewayRelationService.Get err = %v", err)
 	}
 
 	endTime, state := cache.GetDeviceState(device.GatewaySn)
@@ -55,7 +56,7 @@ func (s *gatewayService) CreateOrUpdate(userId int64, tenantId int, req *model.G
 			device.LampPoleSn = lampPole.PoleSN
 			device.LampPoleLocation = lampPole.InstallLocation
 		} else {
-			fmt.Printf("LampPoleService.GetOne err = %v \n", err)
+			logger.Logger.Errorf("LampPoleService.GetOne err = %v \n", err)
 		}
 	}
 
@@ -64,12 +65,12 @@ func (s *gatewayService) CreateOrUpdate(userId int64, tenantId int, req *model.G
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -78,7 +79,7 @@ func (s *gatewayService) CreateOrUpdate(userId int64, tenantId int, req *model.G
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -41,11 +41,11 @@ func (s *infoBoardService) CreateOrUpdate(userId int64, tenantId int, req dao.In
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -57,7 +57,7 @@ func (s *infoBoardService) CreateOrUpdate(userId int64, tenantId int, req dao.In
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -42,11 +42,11 @@ func (s *ipBroadcastService) CreateOrUpdate(userId int64, tenantId int, req dao.
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -58,7 +58,7 @@ func (s *ipBroadcastService) CreateOrUpdate(userId int64, tenantId int, req dao.
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -37,11 +38,11 @@ func (s *lampPoleGroupService) CreateOrUpdate(userId int64, tenantId int, req *d
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedByName() {
-			fmt.Printf("Create IsExistedByName \n")
+			logger.Logger.Errorf("Create IsExistedByName \n")
 			return common.ParamsInvalidResponse(model.RepeatedName, nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -50,12 +51,12 @@ func (s *lampPoleGroupService) CreateOrUpdate(userId int64, tenantId int, req *d
 	}
 
 	if device.IsExistedByNameAndCode() {
-		fmt.Printf("Update IsExistedByNameAndCode \n")
+		logger.Logger.Errorf("Update IsExistedByNameAndCode \n")
 		return common.ParamsInvalidResponse(model.RepeatedName, nil)
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 	service.OperationHisService.Save(userId, tenantId, common.OperationUpdate, common.ModuleTypeDevice,

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

@@ -1,11 +1,11 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -62,12 +62,12 @@ func (s *lampPoleService) CreateOrUpdate(userId int64, tenantId int, req *dao.La
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -76,7 +76,7 @@ func (s *lampPoleService) CreateOrUpdate(userId int64, tenantId int, req *dao.La
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"strconv"
 	"strings"
 	"time"
@@ -52,7 +52,7 @@ func (s *lightControlService) CreateOrUpdate(userId int64, tenantId int, req *da
 			device.LampPoleLocation = lampPole.InstallLocation
 			device.GroupId = lampPole.GroupId
 		} else {
-			fmt.Printf("LampPoleService.GetOne err = %v \n", err)
+			logger.Logger.Errorf("LampPoleService.GetOne err = %v \n", err)
 		}
 	}
 
@@ -83,12 +83,12 @@ func (s *lightControlService) CreateOrUpdate(userId int64, tenantId int, req *da
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -97,7 +97,7 @@ func (s *lightControlService) CreateOrUpdate(userId int64, tenantId int, req *da
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,10 +1,10 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -35,11 +35,11 @@ func (s *manholeCoverService) CreateOrUpdate(userId int64, tenantId int, req dao
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -51,7 +51,7 @@ func (s *manholeCoverService) CreateOrUpdate(userId int64, tenantId int, req dao
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

+ 5 - 4
app/device/service/onDemandGroupService.go

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"strconv"
 	"time"
 )
@@ -40,12 +41,12 @@ func (s *onDemandGroupService) CreateOrUpdate(userId int64, tenantId int, req *d
 		device.CreateUser = userId
 
 		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
+			logger.Logger.Errorf("Create IsExistedBySN \n")
 			return common.ParamsInvalidResponse(model.RepeatedPrompts, nil)
 		}
-		fmt.Printf("device = %+v \n", device)
+		logger.Logger.Errorf("device = %+v \n", device)
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -54,7 +55,7 @@ func (s *onDemandGroupService) CreateOrUpdate(userId int64, tenantId int, req *d
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,10 +1,10 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -33,11 +33,11 @@ func (s *onDemandSensorService) CreateOrUpdate(userId int64, tenantId int, req d
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -51,7 +51,7 @@ func (s *onDemandSensorService) CreateOrUpdate(userId int64, tenantId int, req d
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -42,11 +42,11 @@ func (s *optoSensorService) CreateOrUpdate(userId int64, tenantId int, req dao.O
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -58,7 +58,7 @@ func (s *optoSensorService) CreateOrUpdate(userId int64, tenantId int, req dao.O
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -37,11 +38,11 @@ func (s *switchBoxService) CreateOrUpdate(userId int64, tenantId int, req dao.Sw
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		cache.Redis.Del(getSwitchBoxListRedisKey(tenantId))
@@ -55,7 +56,7 @@ func (s *switchBoxService) CreateOrUpdate(userId int64, tenantId int, req dao.Sw
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 	cache.Redis.Del(getSwitchBoxListRedisKey(tenantId))

+ 2 - 2
app/device/service/timeConditionService.go

@@ -1,9 +1,9 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 )
 
 // 灯控策略-时间策略服务
@@ -41,7 +41,7 @@ func (s *timeConditionService) GetByLightId(id int) []dao.TimeCondition {
 	}
 	conditions, err := condition.GetByLightId()
 	if err != nil {
-		fmt.Printf("GetByLightIds err = %v  \n", err)
+		logger.Logger.Errorf("GetByLightIds err = %v  \n", err)
 		return nil
 	}
 	return conditions

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

@@ -7,6 +7,7 @@ import (
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -37,11 +38,11 @@ func (s *transformerService) CreateOrUpdate(userId int64, tenantId int, req dao.
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -53,7 +54,7 @@ func (s *transformerService) CreateOrUpdate(userId int64, tenantId int, req dao.
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 

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

@@ -1,12 +1,12 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/device/dao"
 	"iot_manager_service/app/device/model"
 	"iot_manager_service/app/system/service"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -43,11 +43,11 @@ func (s *zigbeeService) CreateOrUpdate(userId int64, tenantId int, req dao.Zigbe
 		device.CreateTime = time.Now()
 		device.CreateUser = userId
 		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
+			logger.Logger.Errorf("Create GetDeviceID err \n")
 			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
 		}
 		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
 			return common.FailResponse(err.Error(), nil)
 		}
 		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
@@ -59,7 +59,7 @@ func (s *zigbeeService) CreateOrUpdate(userId int64, tenantId int, req dao.Zigbe
 	}
 
 	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
 		return common.FailResponse(err.Error(), nil)
 	}
 	service.OperationHisService.Save(userId, tenantId, common.OperationUpdate, common.ModuleTypeDevice,

+ 84 - 0
app/multimedia/controller/libraryController.go

@@ -15,6 +15,20 @@ var Library = new(libraryCtl)
 
 type libraryCtl struct{}
 
+func (c *libraryCtl) Detail(ctx *gin.Context) {
+	id, e := strconv.Atoi(ctx.Query("id"))
+	if e != nil {
+		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
+		return
+	}
+	library, err := service.LibraryService.Get(id)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, library))
+}
+
 func (c *libraryCtl) List(ctx *gin.Context) {
 	searchValue := ctx.Query("searchValue")
 	current, _ := strconv.Atoi(ctx.Query("current"))
@@ -44,3 +58,73 @@ func (c *libraryCtl) List(ctx *gin.Context) {
 	}
 	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
 }
+
+func (c *libraryCtl) Remove(ctx *gin.Context) {
+	var req *model.ReqLibraryRemove
+	if err := ctx.ShouldBindJSON(&req); err != nil {
+		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
+		return
+	}
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	err := service.LibraryService.Remove(claims.UserId, claims.TenantId, req.IDs)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
+}
+
+func (c *libraryCtl) GetList(ctx *gin.Context) {
+	libName := ctx.Query("libName")
+	t := ctx.Query("libType")
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	libType := -1
+	if t != "" {
+		libType, _ = strconv.Atoi(t)
+	}
+
+	library, err := service.LibraryService.GetList(claims.TenantId, libName, libType)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, library))
+}
+
+func (c *libraryCtl) UploadFile(ctx *gin.Context) {
+	file, err := ctx.FormFile("file")
+	if err != nil {
+		ctx.JSON(http.StatusOK, common.FailResponse(err.Error(), nil))
+		return
+	}
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	rsp, e := service.LibraryService.UploadFile(claims.TenantId, file)
+	if e != nil {
+		ctx.JSON(http.StatusOK, e)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
+}
+
+func (c *libraryCtl) Submit(ctx *gin.Context) {
+	var req *model.ReqLibrarySubmit
+	if err := ctx.ShouldBindJSON(&req); err != nil {
+		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
+		return
+	}
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	e := service.LibraryService.Submit(claims.TenantId, claims.UserId, req)
+	if e != nil {
+		ctx.JSON(http.StatusOK, e)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
+}

+ 30 - 1
app/multimedia/dao/libraryDao.go

@@ -28,7 +28,11 @@ func (Library) TableName() string {
 	return "media_library"
 }
 
-func (c Library) GetLibraries(offset, limit int) ([]Library, error) {
+func (c *Library) Create() error {
+	return Db.Debug().Model(&c).Save(c).Error
+}
+
+func (c *Library) GetLibraries(offset, limit int) ([]Library, error) {
 	var libraries []Library
 	db := Db.Debug().Model(&c)
 	if c.LibName != "" {
@@ -38,3 +42,28 @@ func (c Library) GetLibraries(offset, limit int) ([]Library, error) {
 	err := db.Where("is_deleted = 0 and tenant_id = ?", c.TenantId).Offset(offset).Limit(limit).Find(&libraries).Error
 	return libraries, err
 }
+
+func (c *Library) Get() error {
+	return Db.Debug().Model(&c).Where("is_deleted = 0 and id = ?", c.ID).Find(&c).Error
+}
+
+func (c *Library) Delete() error {
+	return Db.Debug().Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime, "update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
+}
+
+func (c *Library) GetAll() ([]Library, error) {
+	var libraries []Library
+	db := Db.Debug().Model(&c).Where("tenant_id = ?", c.TenantId)
+	if c.LibName != "" {
+		db = db.Where("lib_name like ?", "%"+c.LibName+"%")
+	}
+	if c.LibType > 0 {
+		db = db.Where("lib_type = ?", c.LibType)
+	}
+	err := db.Find(&libraries).Order("create_time").Error
+	return libraries, err
+}
+
+func (c *Library) Update() error {
+	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
+}

+ 42 - 2
app/multimedia/model/library.go

@@ -5,15 +5,27 @@ import "iot_manager_service/app/multimedia/dao"
 const (
 	LibraryTypeVideo    = 1
 	LibraryTypeImage    = 2
+	LibraryTypeTxt      = 3
+	LibraryTypeAudio    = 4
 	LibraryTypeVideoStr = "视频"
 	LibraryTypeImageStr = "图片"
+	LibraryTypeTxtStr   = "文本"
+	LibraryTypeAudioStr = "音频"
 )
 
 func DaoToModel(library dao.Library) LibraryDetail {
-	typeName := LibraryTypeVideoStr
-	if library.LibType == LibraryTypeImage {
+	typeName := ""
+	switch library.LibType {
+	case LibraryTypeVideo:
+		typeName = LibraryTypeVideoStr
+	case LibraryTypeImage:
 		typeName = LibraryTypeImageStr
+	case LibraryTypeTxt:
+		typeName = LibraryTypeTxtStr
+	case LibraryTypeAudio:
+		typeName = LibraryTypeAudioStr
 	}
+
 	return LibraryDetail{
 		Library:  library,
 		TypeName: typeName,
@@ -32,3 +44,31 @@ type RsqLibraryList struct {
 	Pages   int             `json:"pages"`   //总页数
 	Total   int             `json:"total"`   //总数
 }
+
+type ReqLibraryRemove struct {
+	IDs int `json:"ids"`
+}
+
+type RspUploadFile struct {
+	Link         string `json:"link"`
+	Domain       string `json:"domain"`
+	Name         string `json:"name"`
+	OriginalName string `json:"originalName"`
+	AttachId     int    `json:"attachId"`
+	Duration     int    `json:"duration"`
+	Resolution   string `json:"resolution"`
+	FileSize     int64  `json:"fileSize"`
+	FileType     int    `json:"fileType"`
+}
+
+type ReqLibrarySubmit struct {
+	Id              int    `json:"id"`
+	FileSize        int64  `json:"fileSize"`
+	LibName         string `json:"libName"`
+	Resolution      string `json:"resolution"`
+	MaterialAddress string `json:"materialAddress"`
+	LibType         int    `json:"libType"`
+	LibDuration     int    `json:"libDuration"`
+	LibExplain      string `json:"libExplain"`
+	TalkSpeed       int    `json:"talkSpeed"`
+}

+ 140 - 0
app/multimedia/service/libraryService.go

@@ -3,13 +3,32 @@ package service
 import (
 	"iot_manager_service/app/multimedia/dao"
 	"iot_manager_service/app/multimedia/model"
+	"iot_manager_service/app/system/service"
+	"iot_manager_service/config"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
+	"iot_manager_service/util/minio"
+	"mime/multipart"
+	"strings"
+	"time"
 )
 
 var LibraryService = new(libraryService)
 
 type libraryService struct{}
 
+func (s *libraryService) Get(id int) (*dao.Library,
+	*common.Errors) {
+	library := &dao.Library{
+		ID: id,
+	}
+	err := library.Get()
+	if err != nil {
+		return nil, common.FailResponse(err.Error(), nil)
+	}
+	return library, nil
+}
+
 func (s *libraryService) List(tenantId int, searchValue string, current, size int) ([]model.LibraryDetail,
 	*common.Errors) {
 	library := &dao.Library{
@@ -33,3 +52,124 @@ func (s *libraryService) List(tenantId int, searchValue string, current, size in
 	}
 	return rsp, nil
 }
+
+func (s *libraryService) Remove(userId int64, tenantId int, id int) *common.Errors {
+	library := &dao.Library{
+		ID:         id,
+		IsDeleted:  1,
+		UpdateUser: userId,
+		UpdateTime: time.Now(),
+	}
+	err := library.Delete()
+	if err != nil {
+		return common.FailResponse(err.Error(), nil)
+	}
+	service.OperationHisService.Save(userId, tenantId, common.OperationRemove, common.ModuleTypeInfoBar,
+		common.DeviceTypeDefault, "", common.OperationSuccess)
+	return nil
+}
+
+func (s *libraryService) GetList(tenantId int, libName string, libType int) ([]dao.Library, *common.Errors) {
+	library := &dao.Library{
+		TenantId: tenantId,
+		LibName:  libName,
+		LibType:  libType,
+	}
+	libraries, err := library.GetAll()
+	if err != nil {
+		return nil, common.FailResponse(err.Error(), nil)
+	}
+
+	return libraries, nil
+}
+
+func (s *libraryService) UploadFile(tenantId int, fileHeader *multipart.FileHeader) (*model.RspUploadFile,
+	*common.Errors) {
+	fileContent, err := fileHeader.Open()
+	if err != nil {
+		logger.Logger.Errorf("UploadFile fileHeader.Open fail, err = %s", err.Error())
+		return nil, common.ParamsInvalidResponse(err.Error(), nil)
+	}
+
+	fileNameArray := strings.Split(fileHeader.Filename, ".")
+	if len(fileNameArray) < 2 {
+		return nil, common.ParamsInvalidResponse("invalid file name", nil)
+	}
+	// happy8as8f0980f_92389h.jpg
+	objectName := "library/" + common.RandomString2(16) + "_" + common.RandomString2(6) + "." + fileNameArray[len(
+		fileNameArray)-1]
+
+	err = minio.PutFile(minio.FileObject{
+		TenantId:   tenantId,
+		ObjectName: objectName,
+		ObjectSize: fileHeader.Size,
+		Reader:     fileContent,
+	})
+	if err != nil {
+		logger.Logger.Errorf("UploadFile PutFile fail, err = %s", err.Error())
+		return nil, common.FailResponse("", nil)
+	}
+
+	contentTypeArr := fileHeader.Header["Content-Type"]
+	contentType := ""
+	if len(contentTypeArr) > 0 {
+		contentType = contentTypeArr[0]
+	}
+	fileType := 0
+	if contentType == "image/jpeg" {
+		fileType = 2
+	} else if contentType == "video/mp4" {
+		fileType = 1
+	} else if contentType == "audio/mpeg" {
+		fileType = 3
+	}
+	return &model.RspUploadFile{
+		Link:         config.Instance().Minio.Endpoint,
+		Domain:       "",
+		Name:         objectName,
+		OriginalName: fileHeader.Filename,
+		AttachId:     0,
+		Duration:     0,
+		Resolution:   "",
+		FileSize:     fileHeader.Size,
+		FileType:     fileType,
+	}, nil
+}
+
+func (s *libraryService) Submit(tenantId int, userId int64, req *model.ReqLibrarySubmit) *common.Errors {
+	library := &dao.Library{
+		ID:              req.Id,
+		MaterialAddress: req.MaterialAddress,
+		LibName:         req.LibName,
+		LibExplain:      req.LibExplain,
+		LibType:         req.LibType,
+		Resolution:      req.Resolution,
+		FileSize:        req.FileSize,
+		LibDuration:     req.LibDuration,
+		TalkSpeed:       req.TalkSpeed,
+		TenantId:        tenantId,
+		UpdateTime:      time.Now(),
+		UpdateUser:      userId,
+		IsDeleted:       0,
+	}
+
+	if library.ID == 0 {
+		library.CreateTime = time.Now()
+		library.CreateUser = userId
+		if err := library.Create(); err != nil {
+			logger.Logger.Errorf("Create err = %s \n", err.Error())
+			return common.FailResponse(err.Error(), nil)
+		}
+		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeInfoBar,
+			common.DeviceTypeDefault, library.LibName, common.OperationSuccess)
+		return common.SuccessResponse(common.Succeeded, nil)
+	}
+	if err := library.Update(); err != nil {
+		logger.Logger.Errorf("Update err = %s \n", err.Error())
+		return common.FailResponse(err.Error(), nil)
+	}
+
+	service.OperationHisService.Save(userId, tenantId, common.OperationUpdate, common.ModuleTypeInfoBar,
+		common.DeviceTypeDefault, library.LibName, common.OperationSuccess)
+	return common.SuccessResponse(common.Succeeded, nil)
+}

+ 5 - 3
app/system/service/dictService.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"iot_manager_service/app/system/dao"
 	"iot_manager_service/util/cache"
+	"iot_manager_service/util/logger"
+
 	"strconv"
 )
 
@@ -33,7 +35,7 @@ func (s *dictService) GetControlType(tenantId int, id int) string {
 	if err != nil {
 		dict := &dao.Dict{Code: ControlType, DictKey: strconv.Itoa(id)}
 		if err := dict.GetByCodeAndKey(); err != nil {
-			fmt.Printf("GetByCodeAndKey err = %d \n", err)
+			logger.Logger.Errorf("GetByCodeAndKey err = %d \n", err)
 		} else {
 			name = dict.DictValue
 			cache.Redis.Set(key, name, -1)
@@ -49,7 +51,7 @@ func (s *dictService) GetModuleName(tenantId int, id int) string {
 	if err != nil {
 		dict := &dao.Dict{Code: ModuleType, DictKey: strconv.Itoa(id)}
 		if err := dict.GetByCodeAndKey(); err != nil {
-			fmt.Printf("GetByCodeAndKey err = %d \n", err)
+			logger.Logger.Errorf("GetByCodeAndKey err = %d \n", err)
 		} else {
 			name = dict.DictValue
 			cache.Redis.Set(key, name, -1)
@@ -65,7 +67,7 @@ func (s *dictService) GetSexName(tenantId int, id int) string {
 	if err != nil {
 		dict := &dao.Dict{Code: Sex, DictKey: strconv.Itoa(id)}
 		if err := dict.GetByCodeAndKey(); err != nil {
-			fmt.Printf("GetByCodeAndKey err = %d \n", err)
+			logger.Logger.Errorf("GetByCodeAndKey err = %d \n", err)
 		} else {
 			name = dict.DictValue
 			cache.Redis.Set(key, name, -1)

+ 2 - 2
app/system/service/operationHisService.go

@@ -1,10 +1,10 @@
 package service
 
 import (
-	"fmt"
 	"iot_manager_service/app/system/dao"
 	"iot_manager_service/app/system/model"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"strconv"
 	"time"
 )
@@ -28,7 +28,7 @@ func (s *operationHisService) Save(userId int64, tenantId int, handleType, handl
 	}
 	err := operation.Create()
 	if err != nil {
-		fmt.Printf("Operation save err =%v \n", err)
+		logger.Logger.Errorf("Operation save err =%v \n", err)
 	}
 }
 

+ 2 - 1
app/system/service/roleService.go

@@ -6,6 +6,7 @@ import (
 	"iot_manager_service/app/system/model"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"strconv"
 )
 
@@ -165,7 +166,7 @@ func (s *roleService) GetRoleName(tenantId int, roleId int64) string {
 	if err != nil {
 		role := &dao.Role{ID: roleId}
 		if err := role.GetRole(); err != nil {
-			fmt.Printf("GetRole err = %s \n", err)
+			logger.Logger.Errorf("GetRole err = %s \n", err)
 		} else {
 			name = role.RoleName
 			cache.Redis.Set(key, name, -1)

+ 2 - 1
app/system/service/tenantService.go

@@ -5,6 +5,7 @@ import (
 	"iot_manager_service/app/system/dao"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -130,7 +131,7 @@ func (s *tenantService) GetTenantName(tenantId int, id int) string {
 	if err != nil {
 		tenant := &dao.Tenant{TenantId: id}
 		if err := tenant.GetTenant(); err != nil {
-			fmt.Printf("GetTenant err = %s \n", err)
+			logger.Logger.Errorf("GetTenant err = %s \n", err)
 		} else {
 			name = tenant.TenantName
 			cache.Redis.Set(key, name, -1)

+ 2 - 1
app/system/service/userService.go

@@ -8,6 +8,7 @@ import (
 	"iot_manager_service/app/system/model"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/common"
+	"iot_manager_service/util/logger"
 	"time"
 )
 
@@ -152,7 +153,7 @@ func (s *userService) GetUserName(tenantId int, id int64) string {
 	if err != nil {
 		user := &dao.User{ID: id}
 		if err := user.GetUser(); err != nil {
-			fmt.Printf("GetUser err = %s \n", err)
+			logger.Logger.Errorf("GetUser err = %s \n", err)
 		} else {
 			name = user.Name
 			cache.Redis.Set(key, name, time.Second*10)

+ 7 - 0
config/config.go

@@ -38,6 +38,7 @@ type config struct {
 	Database database `yaml:"database"`
 	Redis    redis    `yaml:"redis"`
 	Logger   logger   `yaml:"logger"`
+	Minio    minio    `yaml:"minio"`
 }
 
 type server struct {
@@ -65,3 +66,9 @@ type logger struct {
 	Name  string `yaml:"name"`
 	Level string `yaml:"level"`
 }
+
+type minio struct {
+	Endpoint  string `yaml:"endpoint"`
+	AccessKey string `yaml:"access_key"`
+	SecretKey string `yaml:"secret_key"`
+}

+ 5 - 0
config/config.yaml

@@ -27,3 +27,8 @@ database:
 redis:
   host: "127.0.0.1:6379"
   #password: "lczm*2019"
+
+minio:
+  endpoint: "110.40.223.170:9000"
+  access_key: "lczm*minio"
+  secret_key: "lczm*minio"

+ 13 - 5
go.mod

@@ -9,6 +9,7 @@ require (
 	github.com/go-sql-driver/mysql v1.6.0
 	github.com/golang-jwt/jwt v3.2.2+incompatible
 	github.com/jinzhu/gorm v1.9.16
+	github.com/minio/minio-go/v7 v7.0.43
 	github.com/mojocn/base64Captcha v1.3.5
 	github.com/satori/go.uuid v1.2.0
 	github.com/sirupsen/logrus v1.9.0
@@ -16,6 +17,7 @@ require (
 )
 
 require (
+	github.com/dustin/go-humanize v1.0.0 // indirect
 	github.com/fogleman/gg v1.3.0 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-playground/locales v0.14.0 // indirect
@@ -24,21 +26,27 @@ require (
 	github.com/goccy/go-json v0.9.7 // indirect
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
 	github.com/google/go-cmp v0.5.8 // indirect
-	github.com/google/uuid v1.2.0 // indirect
+	github.com/google/uuid v1.3.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/compress v1.15.9 // indirect
+	github.com/klauspost/cpuid/v2 v2.1.0 // indirect
 	github.com/leodido/go-urn v1.2.1 // indirect
 	github.com/mattn/go-isatty v0.0.14 // indirect
-	github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
+	github.com/minio/md5-simd v1.1.2 // indirect
+	github.com/minio/sha256-simd v1.0.0 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/onsi/ginkgo v1.16.5 // indirect
 	github.com/onsi/gomega v1.20.0 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.1 // indirect
+	github.com/rs/xid v1.4.0 // indirect
 	github.com/ugorji/go/codec v1.2.7 // indirect
-	golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
+	golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
 	golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
-	golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
-	golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
+	golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
+	golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
 	golang.org/x/text v0.3.7 // indirect
 	google.golang.org/protobuf v1.28.0 // indirect
+	gopkg.in/ini.v1 v1.66.6 // indirect
 )

+ 31 - 5
go.sum

@@ -11,6 +11,8 @@ github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6RO
 github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
 github.com/druidcaesa/gotool v0.0.0-20220613023420-645c641d1304 h1:YSmbj/dqe9cV3vQRLIVfXIW22qMA18oyG/C54B19TFM=
 github.com/druidcaesa/gotool v0.0.0-20220613023420-645c641d1304/go.mod h1:dYDc/fkM/uhP6dEdKhhLvpw3fgzZB7lexG1w+ZlVfyk=
+github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
+github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
 github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
 github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
 github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
@@ -61,8 +63,9 @@ github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
 github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
-github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
 github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
+github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
@@ -73,6 +76,12 @@ github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
 github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
+github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
+github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8rF0=
+github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
 github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
@@ -89,8 +98,15 @@ github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9
 github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
 github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
 github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
-github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
+github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
+github.com/minio/minio-go/v7 v7.0.43 h1:14Q4lwblqTdlAmba05oq5xL0VBLHi06zS4yLnIkz6hI=
+github.com/minio/minio-go/v7 v7.0.43/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw=
+github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
+github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
 github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 github.com/mojocn/base64Captcha v1.3.5 h1:Qeilr7Ta6eDtG4S+tQuZ5+hO+QHbiGAJdi4PfoagaA0=
@@ -119,6 +135,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
 github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
 github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
 github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
+github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY=
+github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
 github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
 github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
 github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
@@ -143,8 +161,9 @@ golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPh
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
+golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
 golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
 golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
 golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
@@ -161,9 +180,11 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
 golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
-golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -187,8 +208,11 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -220,6 +244,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI=
+gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

+ 2 - 1
main.go

@@ -12,6 +12,7 @@ import (
 	"iot_manager_service/router"
 	"iot_manager_service/util/cache"
 	"iot_manager_service/util/logger"
+	"iot_manager_service/util/minio"
 	"net/url"
 )
 
@@ -26,7 +27,7 @@ func main() {
 	if err != nil {
 		panic(err)
 	}
-
+	minio.InitMinio()
 	engine := gin.Default()
 	router.InitRouter(engine)
 	_ = engine.Run(config.Instance().Server.Address)

+ 4 - 0
router/router.go

@@ -461,5 +461,9 @@ func InitRouter(engine *gin.Engine) {
 	multimediaGroup := engine.Group("/api/longchi/multimedia/library")
 	{
 		multimediaGroup.GET("/list", multimedia.Library.List)
+		multimediaGroup.GET("/detail", multimedia.Library.Detail)
+		multimediaGroup.GET("/remove", multimedia.Library.Remove)
+		multimediaGroup.GET("/getList", multimedia.Library.GetList)
+		multimediaGroup.POST("/putFile", multimedia.Library.UploadFile)
 	}
 }

+ 5 - 0
util/logger/logger.go

@@ -6,6 +6,7 @@ import (
 	"github.com/sirupsen/logrus"
 	"io/ioutil"
 	"net/http"
+	"strings"
 	"time"
 )
 
@@ -56,6 +57,10 @@ func LogToFile() gin.HandlerFunc {
 }
 
 func getRequestBody(ctx *gin.Context) interface{} {
+	if strings.Contains(ctx.ContentType(), "multipart/form-data") {
+		return "multipart"
+	}
+
 	switch ctx.Request.Method {
 	case http.MethodGet:
 		fallthrough