mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-09-04 13:34:35 +08:00
fix channelType
This commit is contained in:
parent
e237f1422d
commit
d4bc51d730
3 changed files with 12 additions and 8 deletions
|
@ -31,7 +31,7 @@ func MapFileInToFile(file schemas.FileIn) models.File {
|
|||
UserID: file.UserID,
|
||||
ParentID: file.ParentID,
|
||||
Parts: file.Parts,
|
||||
ChannelID: file.ChannelID,
|
||||
ChannelID: &file.ChannelID,
|
||||
Status: file.Status,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ type FileIn struct {
|
|||
Type string `json:"type" mapstructure:"type,omitempty"`
|
||||
Parts *models.Parts `json:"parts,omitempty" mapstructure:"parts,omitempty"`
|
||||
MimeType string `json:"mimeType" mapstructure:"mime_type,omitempty"`
|
||||
ChannelID *int64 `json:"channelId,omitempty" mapstructure:"channel_id,omitempty"`
|
||||
ChannelID int64 `json:"channelId" mapstructure:"channel_id,omitempty"`
|
||||
Path string `json:"path" mapstructure:"path,omitempty"`
|
||||
Size int64 `json:"size" mapstructure:"size,omitempty"`
|
||||
Starred *bool `json:"starred" mapstructure:"starred,omitempty"`
|
||||
|
|
|
@ -65,14 +65,18 @@ func (fs *FileService) CreateFile(c *gin.Context) (*schemas.FileOut, *types.AppE
|
|||
fileIn.Depth = utils.IntPointer(len(strings.Split(fileIn.Path, "/")) - 1)
|
||||
} else if fileIn.Type == "file" {
|
||||
fileIn.Path = ""
|
||||
|
||||
channelId, err := GetDefaultChannel(c, userId)
|
||||
|
||||
if err != nil {
|
||||
return nil, &types.AppError{Error: err, Code: http.StatusInternalServerError}
|
||||
var channelId int64
|
||||
var err error
|
||||
if fileIn.ChannelID == 0 {
|
||||
channelId, err = GetDefaultChannel(c, userId)
|
||||
if err != nil {
|
||||
return nil, &types.AppError{Error: err, Code: http.StatusInternalServerError}
|
||||
}
|
||||
} else {
|
||||
channelId = fileIn.ChannelID
|
||||
}
|
||||
|
||||
fileIn.ChannelID = &channelId
|
||||
fileIn.ChannelID = channelId
|
||||
}
|
||||
|
||||
fileIn.UserID = userId
|
||||
|
|
Loading…
Add table
Reference in a new issue