version 3
This commit is contained in:
@@ -73,5 +73,71 @@ public class DailyReportController : ControllerBase
|
||||
return StatusCode(500, new { error = "خطای سرور در پردازش درخواست" });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تحلیل هفتگی
|
||||
/// </summary>
|
||||
[HttpGet("weekly")]
|
||||
public async Task<ActionResult<DailyReportResponse>> GetWeeklyAnalysis(
|
||||
[FromQuery] int deviceId,
|
||||
[FromQuery] string startDate,
|
||||
[FromQuery] string endDate,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new WeeklyAnalysisRequest
|
||||
{
|
||||
DeviceId = deviceId,
|
||||
StartDate = startDate.Trim(),
|
||||
EndDate = endDate.Trim()
|
||||
};
|
||||
|
||||
var result = await _dailyReportService.GetWeeklyAnalysisAsync(request, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(new { error = ex.Message });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error getting weekly analysis");
|
||||
return StatusCode(500, new { error = "خطا در دریافت تحلیل هفتگی" });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تحلیل ماهانه
|
||||
/// </summary>
|
||||
[HttpGet("monthly")]
|
||||
public async Task<ActionResult<DailyReportResponse>> GetMonthlyAnalysis(
|
||||
[FromQuery] int deviceId,
|
||||
[FromQuery] int year,
|
||||
[FromQuery] int month,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new MonthlyAnalysisRequest
|
||||
{
|
||||
DeviceId = deviceId,
|
||||
Year = year,
|
||||
Month = month
|
||||
};
|
||||
|
||||
var result = await _dailyReportService.GetMonthlyAnalysisAsync(request, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(new { error = ex.Message });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error getting monthly analysis");
|
||||
return StatusCode(500, new { error = "خطا در دریافت تحلیل ماهانه" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user