允许用户标记上传文件状态

This commit is contained in:
刘祥超
2022-08-04 16:01:07 +08:00
parent fc839f96d2
commit 95349dc457

View File

@@ -18,8 +18,6 @@ func (this *FileService) FindEnabledFile(ctx context.Context, req *pb.FindEnable
return nil, err
}
// TODO 检查用户权限
var tx = this.NullTx()
file, err := models.SharedFileDAO.FindEnabledFile(tx, req.FileId)
if err != nil {
@@ -67,13 +65,20 @@ func (this *FileService) CreateFile(ctx context.Context, req *pb.CreateFileReque
// UpdateFileFinished 将文件置为已完成
func (this *FileService) UpdateFileFinished(ctx context.Context, req *pb.UpdateFileFinishedRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx)
_, userId, err := this.ValidateAdminAndUser(ctx)
if err != nil {
return nil, err
}
var tx = this.NullTx()
if userId > 0 {
err = models.SharedFileDAO.CheckUserFile(tx, userId, req.FileId)
if err != nil {
return nil, err
}
}
err = models.SharedFileDAO.UpdateFileIsFinished(tx, req.FileId)
if err != nil {
return nil, err