|
@@ -33,11 +33,10 @@ func (f *File) Create() error {
|
|
|
return Db.Model(&f).Save(&f).Error
|
|
|
}
|
|
|
|
|
|
-func (f *File) GetSysUserFiles(uid int, search model.SearchSysUserFiles) ([]File, error) {
|
|
|
- var files []File
|
|
|
+func (f *File) GetSysUserFiles(uid int, search model.SearchSysUserFiles) (files []File, total int64, err error) {
|
|
|
//var db *gorm.DB
|
|
|
db := Db.Table("file").
|
|
|
- Select("file.*").
|
|
|
+ Select("file.id,file.*").
|
|
|
Joins("left join user_file uf on uf.file_id = file.id").
|
|
|
Where("uf.receiver = ? AND file.is_showed = 0 AND file.is_deleted = 0 AND uf.is_deleted = 0 AND uf.operation_status = '下发' OR uf.operation_status = '转发'", uid). // 根据upload_time字段降序排列
|
|
|
Group("file.id")
|
|
@@ -55,12 +54,13 @@ func (f *File) GetSysUserFiles(uid int, search model.SearchSysUserFiles) ([]File
|
|
|
}
|
|
|
limit := search.PageSize
|
|
|
offset := search.PageSize * (search.PageNO - 1)
|
|
|
+ db.Count(&total)
|
|
|
// 执行查询并检查错误
|
|
|
- err := db.Limit(limit).Offset(offset).Scan(&files).Error
|
|
|
+ err = db.Limit(limit).Offset(offset).Scan(&files).Error
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ return nil, 0, err
|
|
|
}
|
|
|
- return files, err
|
|
|
+ return files, total, err
|
|
|
}
|
|
|
|
|
|
func (f *File) GetFileInfo(fileid, uid int) (model.RespFileInfo, error) {
|