修改用户文件查询数据
This commit is contained in:
parent
58a0c9e8c3
commit
4843548fd0
|
|
@ -34,8 +34,8 @@ func GetUserFileList(c *gin.Context) {
|
|||
var req GetUserFileListReq
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
if req.Type == "all" {
|
||||
fileList, files := dao.FileUserFileList(user_id, proto.UserFileTypeFile)
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "msg": "success", "data": fileList, "files": files})
|
||||
userFiles := service.FindUserFileList(user_id, proto.UserFileTypeFile)
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "msg": "success", "data": userFiles})
|
||||
} else if req.Type == "search" {
|
||||
fileList := dao.FindFileByUserFileName(req.FileName, user_id)
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "msg": "success", "data": fileList})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package proto
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"StuAcaWorksAI/dao"
|
||||
"time"
|
||||
)
|
||||
|
||||
type FileUploadReq struct {
|
||||
UploadType string `json:"upload_type" form:"upload_type" binding:"required"`
|
||||
|
|
@ -30,3 +33,8 @@ 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"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,3 +247,18 @@ func CreateUserFile(userID int, fileAuthName string, fileID int, UploadType stri
|
|||
fileAuth := dao.CreateFileAuth(userID, fileID, fileAuthName, UploadType, 1, "")
|
||||
return fileAuth
|
||||
}
|
||||
|
||||
func FindUserFileList(userID int, uploadType string) []proto.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
|
||||
for _, file := range fileList {
|
||||
fileStoreName := filesM[uint(file.FileID)].FileStoreName
|
||||
r := proto.UserFileListResp{FileAuth: file, FileStoreName: fileStoreName}
|
||||
res = append(res, r)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue