解决循环引用问题
This commit is contained in:
parent
f759046b15
commit
ae355b23ca
|
|
@ -41,6 +41,11 @@ type FileAuthListResp struct {
|
|||
FileStoreName string `gorm:"column:file_store_name;type:varchar(255);uniqueIndex:idx_file_name"`
|
||||
}
|
||||
|
||||
type UserFileListResp struct {
|
||||
FileAuth
|
||||
FileStoreName string `json:"file_store_name" form:"file_store_name"`
|
||||
}
|
||||
|
||||
func CreateFile(fileStoreName, fileName, fileType, filePath, md5Str string, fileSize, authID int, NeedAuth bool) File {
|
||||
file := File{FileStoreName: fileStoreName, FileName: fileName, FileType: fileType, FilePath: filePath, FileSize: fileSize, AuthID: authID, NeedAuth: NeedAuth, Md5: md5Str}
|
||||
result := DB.Create(&file)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
"StuAcaWorksAI/dao"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -33,8 +32,3 @@ type SearchOneConfigFileResp struct {
|
|||
FilePath string `json:"file_path" form:"file_path"`
|
||||
Content string `json:"content" form:"content"`
|
||||
}
|
||||
|
||||
type UserFileListResp struct {
|
||||
dao.FileAuth
|
||||
FileStoreName string `json:"file_store_name" form:"file_store_name"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,16 +249,16 @@ func CreateUserFile(userID int, fileAuthName string, fileID int, UploadType stri
|
|||
return fileAuth
|
||||
}
|
||||
|
||||
func FindUserFileList(userID int, uploadType string) []proto.UserFileListResp {
|
||||
func FindUserFileList(userID int, uploadType string) []dao.UserFileListResp {
|
||||
fileList, files := dao.FileUserFileList(userID, uploadType)
|
||||
filesM := make(map[uint]dao.File)
|
||||
for _, file := range files {
|
||||
filesM[file.ID] = file
|
||||
}
|
||||
var res []proto.UserFileListResp
|
||||
var res []dao.UserFileListResp
|
||||
for _, file := range fileList {
|
||||
fileStoreName := filesM[uint(file.FileID)].FileStoreName
|
||||
r := proto.UserFileListResp{FileAuth: file, FileStoreName: fileStoreName}
|
||||
r := dao.UserFileListResp{FileAuth: file, FileStoreName: fileStoreName}
|
||||
res = append(res, r)
|
||||
}
|
||||
log.Println("FindUserFileList res:", len(res))
|
||||
|
|
|
|||
Loading…
Reference in New Issue