|
@@ -1,6 +1,7 @@
|
|
package service
|
|
package service
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "fmt"
|
|
"iot_manager_service/app/multimedia/dao"
|
|
"iot_manager_service/app/multimedia/dao"
|
|
"iot_manager_service/app/multimedia/model"
|
|
"iot_manager_service/app/multimedia/model"
|
|
"iot_manager_service/app/system/service"
|
|
"iot_manager_service/app/system/service"
|
|
@@ -28,10 +29,11 @@ func (s *libraryService) Get(id int) (*dao.Library, *common.Errors) {
|
|
return library, nil
|
|
return library, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *libraryService) List(tenantId int, searchValue string, current, size int) ([]model.LibraryDetail,
|
|
|
|
|
|
+func (s *libraryService) List(tenantId int, searchValue string, current, size, sysType int) ([]model.LibraryDetail,
|
|
*common.Errors) {
|
|
*common.Errors) {
|
|
library := &dao.Library{
|
|
library := &dao.Library{
|
|
TenantId: tenantId,
|
|
TenantId: tenantId,
|
|
|
|
+ SysType: sysType,
|
|
}
|
|
}
|
|
|
|
|
|
offset := (current - 1) * size
|
|
offset := (current - 1) * size
|
|
@@ -40,6 +42,9 @@ func (s *libraryService) List(tenantId int, searchValue string, current, size in
|
|
if searchValue != "" {
|
|
if searchValue != "" {
|
|
library.LibName = searchValue
|
|
library.LibName = searchValue
|
|
}
|
|
}
|
|
|
|
+ if sysType != -1 {
|
|
|
|
+ library.SysType = sysType
|
|
|
|
+ }
|
|
libraries, err := library.GetLibraries(offset, limit)
|
|
libraries, err := library.GetLibraries(offset, limit)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, common.FailResponse(err.Error(), nil)
|
|
return nil, common.FailResponse(err.Error(), nil)
|
|
@@ -68,11 +73,12 @@ func (s *libraryService) Remove(userId int64, tenantId int, id int) *common.Erro
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *libraryService) GetList(tenantId int, libName string, libType int) ([]dao.Library, *common.Errors) {
|
|
|
|
|
|
+func (s *libraryService) GetList(tenantId int, libName string, libType, sysType int) ([]dao.Library, *common.Errors) {
|
|
library := &dao.Library{
|
|
library := &dao.Library{
|
|
TenantId: tenantId,
|
|
TenantId: tenantId,
|
|
LibName: libName,
|
|
LibName: libName,
|
|
LibType: libType,
|
|
LibType: libType,
|
|
|
|
+ SysType: sysType,
|
|
}
|
|
}
|
|
libraries, err := library.GetAll()
|
|
libraries, err := library.GetAll()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -97,9 +103,9 @@ func (s *libraryService) UploadFile(tenantId int, fileHeader *multipart.FileHead
|
|
// happy8as8f0980f_92389h.jpg
|
|
// happy8as8f0980f_92389h.jpg
|
|
objectName := "library/" + common.RandomString2(16) + "_" + common.RandomString2(6) + "." + fileNameArray[len(
|
|
objectName := "library/" + common.RandomString2(16) + "_" + common.RandomString2(6) + "." + fileNameArray[len(
|
|
fileNameArray)-1]
|
|
fileNameArray)-1]
|
|
-
|
|
|
|
|
|
+ bucket := fmt.Sprintf("longchi-%d", tenantId)
|
|
err = minio.PutFile(minio.FileObject{
|
|
err = minio.PutFile(minio.FileObject{
|
|
- TenantId: tenantId,
|
|
|
|
|
|
+ Bucket: bucket,
|
|
ObjectName: objectName,
|
|
ObjectName: objectName,
|
|
ObjectSize: fileHeader.Size,
|
|
ObjectSize: fileHeader.Size,
|
|
Reader: fileContent,
|
|
Reader: fileContent,
|
|
@@ -123,7 +129,7 @@ func (s *libraryService) UploadFile(tenantId int, fileHeader *multipart.FileHead
|
|
fileType = 3
|
|
fileType = 3
|
|
}
|
|
}
|
|
return &model.RspUploadFile{
|
|
return &model.RspUploadFile{
|
|
- Link: config.Instance().Minio.Endpoint,
|
|
|
|
|
|
+ Link: config.Instance().Minio.Link + "/" + bucket + "/" + objectName,
|
|
Domain: "",
|
|
Domain: "",
|
|
Name: objectName,
|
|
Name: objectName,
|
|
OriginalName: fileHeader.Filename,
|
|
OriginalName: fileHeader.Filename,
|
|
@@ -135,22 +141,11 @@ func (s *libraryService) UploadFile(tenantId int, fileHeader *multipart.FileHead
|
|
}, nil
|
|
}, 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,
|
|
|
|
- }
|
|
|
|
|
|
+func (s *libraryService) Submit(tenantId int, userId int64, req dao.Library) *common.Errors {
|
|
|
|
+ library := &req
|
|
|
|
+ library.TenantId = tenantId
|
|
|
|
+ library.UpdateUser = userId
|
|
|
|
+ library.UpdateTime = time.Now()
|
|
|
|
|
|
if library.ID == 0 {
|
|
if library.ID == 0 {
|
|
library.CreateTime = time.Now()
|
|
library.CreateTime = time.Now()
|