Browse Source

mod attachment

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
fdd544ae98
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      models/attachment.go

+ 15
- 0
models/attachment.go View File

@@ -384,6 +384,7 @@ func getPrivateAttachments(e Engine, userID int64) ([]*AttachmentUsername, error
return attachments, nil
}

/*
func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) {
attachsPub, err := getAllPublicAttachments(x)
if err != nil {
@@ -400,3 +401,17 @@ func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) {
return append(attachsPub, attachsPri...), nil
}

*/

func getAllUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) {
attachments := make([]*AttachmentUsername, 0, 10)
if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id " +
"= `user`.id").Where("decompress_state= ? and (uploader_id= ? or is_private = ?)", DecompressStateDone, userID, false).Find(&attachments); err != nil {
return nil, err
}
return attachments, nil
}

func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) {
return getAllUserAttachments(x, userID)
}

Loading…
Cancel
Save