fix: 修复调整resource manager接口导致无法过编译的问题

This commit is contained in:
SikongJueluo 2025-08-14 14:22:06 +08:00
parent 66bc5882af
commit 9af4546a11
No known key found for this signature in database
2 changed files with 6 additions and 23 deletions

View File

@ -166,20 +166,14 @@ public class JtagController : ControllerBase
var user = userResult.Value.Value;
var resourceRet = _resourceManager.GetResourceById(bitstreamId);
if (!resourceRet.IsSuccessful)
{
logger.Error($"User {username} failed to get bitstream from database: {resourceRet.Error}");
return TypedResults.InternalServerError($"数据库查询失败: {resourceRet.Error?.Message}");
}
if (!resourceRet.Value.HasValue)
if (!resourceRet.HasValue)
{
logger.Warn($"User {username} attempted to download non-existent bitstream ID: {bitstreamId}");
return TypedResults.BadRequest("比特流不存在");
}
// 处理比特流数据
var resource = resourceRet.Value.Value;
var resource = resourceRet.Value;
var bitstreamRet = _resourceManager.ReadBytesFromPath(resource.Path);
if (!bitstreamRet.IsSuccessful)
{

View File

@ -227,19 +227,13 @@ public class ResourceController : ControllerBase
{
var result = _resourceManager.GetResourceById(resourceId);
if (!result.IsSuccessful)
{
logger.Error($"获取资源时出错: {result.Error.Message}");
return StatusCode(StatusCodes.Status500InternalServerError, $"获取资源失败: {result.Error.Message}");
}
if (!result.Value.HasValue)
if (!result.HasValue)
{
logger.Warn($"资源不存在: {resourceId}");
return NotFound($"资源 {resourceId} 不存在");
}
var resource = result.Value.Value;
var resource = result.Value;
logger.Info($"成功获取资源: {resourceId} ({resource.ResourceName})");
var dataRet = _resourceManager.ReadBytesFromPath(resource.Path);
@ -288,19 +282,14 @@ public class ResourceController : ControllerBase
// 先获取资源信息以验证权限
var resourceResult = _resourceManager.GetResourceById(resourceId);
if (!resourceResult.IsSuccessful)
{
logger.Error($"获取资源时出错: {resourceResult.Error.Message}");
return StatusCode(StatusCodes.Status500InternalServerError, $"获取资源失败: {resourceResult.Error.Message}");
}
if (!resourceResult.Value.HasValue)
if (!resourceResult.HasValue)
{
logger.Warn($"资源不存在: {resourceId}");
return NotFound($"资源 {resourceId} 不存在");
}
var resource = resourceResult.Value.Value;
var resource = resourceResult.Value;
// 权限检查:管理员可以删除所有资源,普通用户只能删除自己的用户资源
if (!User.IsInRole("Admin"))