Merge branch 'refs/heads/feat-file' into master-pg
This commit is contained in:
commit
1c830a6bd3
16
dao/file.go
16
dao/file.go
|
|
@ -53,6 +53,22 @@ func UpdateFileByID(id, auth_id int, fileStoreName, fileName, fileType, filePath
|
||||||
if pd.ID == 0 {
|
if pd.ID == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if fileStoreName == "" {
|
||||||
|
fileStoreName = pd.FileStoreName
|
||||||
|
}
|
||||||
|
if fileName == "" {
|
||||||
|
fileName = pd.FileName
|
||||||
|
}
|
||||||
|
if fileType == "" {
|
||||||
|
fileType = pd.FileType
|
||||||
|
}
|
||||||
|
if filePath == "" {
|
||||||
|
filePath = pd.FilePath
|
||||||
|
}
|
||||||
|
if fileSize == 0 {
|
||||||
|
fileSize = pd.FileSize
|
||||||
|
}
|
||||||
|
|
||||||
result := DB.Debug().Model(&File{}).Where("id = ? and auth_id = ?", id, auth_id).Updates(File{FileStoreName: fileStoreName, FileName: fileName, FileType: fileType, FilePath: filePath, FileSize: fileSize})
|
result := DB.Debug().Model(&File{}).Where("id = ? and auth_id = ?", id, auth_id).Updates(File{FileStoreName: fileStoreName, FileName: fileName, FileType: fileType, FilePath: filePath, FileSize: fileSize})
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,14 @@ type SetRedisReq struct {
|
||||||
Expire int `json:"expire" form:"expire"`
|
Expire int `json:"expire" form:"expire"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SetFileReq struct {
|
||||||
|
ID int `json:"id" form:"id"`
|
||||||
|
FileStoreName string `json:"file_store_name" form:"file_store_name"`
|
||||||
|
FileName string `json:"file_name" form:"file_name"`
|
||||||
|
FileSize int `json:"file_size" form:"file_size"`
|
||||||
|
FileType string `json:"file_type" form:"file_type"`
|
||||||
|
}
|
||||||
|
|
||||||
func SetUpToolGroup(router *gin.Engine) {
|
func SetUpToolGroup(router *gin.Engine) {
|
||||||
toolGroup := router.Group("/tool")
|
toolGroup := router.Group("/tool")
|
||||||
toolGroup.POST("/set_redis", SetRedis)
|
toolGroup.POST("/set_redis", SetRedis)
|
||||||
|
|
@ -31,6 +39,22 @@ func SetUpToolGroup(router *gin.Engine) {
|
||||||
//文件管理
|
//文件管理
|
||||||
toolGroup.POST("/file_del", DelFile)
|
toolGroup.POST("/file_del", DelFile)
|
||||||
toolGroup.POST("/file_status", FileStatus)
|
toolGroup.POST("/file_status", FileStatus)
|
||||||
|
toolGroup.POST("/file_set", SetFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetFile(c *gin.Context) {
|
||||||
|
id, _ := c.Get("id")
|
||||||
|
id1 := int(id.(float64))
|
||||||
|
|
||||||
|
var req SetFileReq
|
||||||
|
if err := c.ShouldBind(&req); err == nil {
|
||||||
|
//先查看是否有权限
|
||||||
|
dao.UpdateFileByID(req.ID, id1, req.FileStoreName, req.FileName, req.FileType, "", req.FileSize)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func FileStatus(c *gin.Context) {
|
func FileStatus(c *gin.Context) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue