新增采集日志服务接口 ICollectLogService、实现 CollectLogService、控制器 CollectLogController,并更新 API 文档 3.14 采集日志模块
parent
5a7c1b3436
commit
23eda3751f
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using CncModels.Dto;
|
||||||
|
using CncModels.Dto.CollectLog;
|
||||||
|
using CncModels.Constants;
|
||||||
|
using CncService.Interface;
|
||||||
|
using CncRepository.Interface;
|
||||||
|
|
||||||
|
namespace CncService.Impl
|
||||||
|
{
|
||||||
|
// 采集日志相关的业务实现
|
||||||
|
public class CollectLogService : ICollectLogService
|
||||||
|
{
|
||||||
|
private readonly ICollectAnalysisRepository _analysisRepository;
|
||||||
|
private readonly ICollectCycleRepository _cycleRepository;
|
||||||
|
|
||||||
|
public CollectLogService(ICollectAnalysisRepository analysisRepository, ICollectCycleRepository cycleRepository)
|
||||||
|
{
|
||||||
|
_analysisRepository = analysisRepository ?? throw new ArgumentNullException(nameof(analysisRepository));
|
||||||
|
_cycleRepository = cycleRepository ?? throw new ArgumentNullException(nameof(cycleRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedResult<CollectAnalysisListItem> GetAnalysisList(CollectAnalysisQuery query)
|
||||||
|
{
|
||||||
|
if (query == null) throw new BusinessException(ErrorCode.BadRequest, "查询参数不能为空");
|
||||||
|
return _analysisRepository.GetAnalysisList(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectAnalysisDetail GetAnalysisDetail(long id)
|
||||||
|
{
|
||||||
|
var detail = _analysisRepository.GetAnalysisDetail(id);
|
||||||
|
if (detail == null) throw new BusinessException(ErrorCode.NotFound, "采集分析记录不存在");
|
||||||
|
return detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CollectAnalysisListItem> GetAnalysisByRawLogId(long rawLogId)
|
||||||
|
{
|
||||||
|
return _analysisRepository.GetAnalysisByRawLogId(rawLogId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedResult<CollectCycleListItem> GetCycleList(CollectCycleQuery query)
|
||||||
|
{
|
||||||
|
if (query == null) throw new BusinessException(ErrorCode.BadRequest, "查询参数不能为空");
|
||||||
|
return _cycleRepository.GetCycleList(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using CncModels.Dto;
|
||||||
|
using CncModels.Dto.CollectLog;
|
||||||
|
|
||||||
|
namespace CncService.Interface
|
||||||
|
{
|
||||||
|
public interface ICollectLogService
|
||||||
|
{
|
||||||
|
// 分页查询采集分析日志
|
||||||
|
PagedResult<CollectAnalysisListItem> GetAnalysisList(CollectAnalysisQuery query);
|
||||||
|
|
||||||
|
// 获取单条采集分析日志的详情
|
||||||
|
CollectAnalysisDetail GetAnalysisDetail(long id);
|
||||||
|
|
||||||
|
// 根据原始日志ID查找相关联的分析记录
|
||||||
|
List<CollectAnalysisListItem> GetAnalysisByRawLogId(long rawLogId);
|
||||||
|
|
||||||
|
// 分页查询采集周期信息
|
||||||
|
PagedResult<CollectCycleListItem> GetCycleList(CollectCycleQuery query);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Web.Http;
|
||||||
|
using CncModels.Dto;
|
||||||
|
using CncModels.Dto.CollectLog;
|
||||||
|
using CncService.Interface;
|
||||||
|
using CncRepository.Interface;
|
||||||
|
using System.Web.Http.Description;
|
||||||
|
|
||||||
|
namespace CncWebApi.Controllers
|
||||||
|
{
|
||||||
|
[RoutePrefix("api/admin/collect-log")]
|
||||||
|
[JwtAuthFilter]
|
||||||
|
public class CollectLogController : ApiController
|
||||||
|
{
|
||||||
|
private readonly ICollectLogService _collectLogService;
|
||||||
|
private readonly ICollectRawRepository _rawRepository;
|
||||||
|
|
||||||
|
public CollectLogController(ICollectLogService collectLogService, ICollectRawRepository rawRepository)
|
||||||
|
{
|
||||||
|
_collectLogService = collectLogService ?? throw new ArgumentNullException(nameof(collectLogService));
|
||||||
|
_rawRepository = rawRepository ?? throw new ArgumentNullException(nameof(rawRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/admin/collect-log/analysis
|
||||||
|
[HttpGet]
|
||||||
|
[Route("analysis")]
|
||||||
|
[ResponseType(typeof(ApiResponse<PagedResult<CollectAnalysisListItem>>))]
|
||||||
|
public IHttpActionResult GetAnalysisList([FromUri] CollectAnalysisQuery query)
|
||||||
|
{
|
||||||
|
var result = _collectLogService.GetAnalysisList(query);
|
||||||
|
return Ok(ApiResponse<PagedResult<CollectAnalysisListItem>>.Success(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/admin/collect-log/analysis/{id}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("analysis/{id}")]
|
||||||
|
[ResponseType(typeof(ApiResponse<CollectAnalysisDetail>))]
|
||||||
|
public IHttpActionResult GetAnalysisDetail(long id)
|
||||||
|
{
|
||||||
|
var detail = _collectLogService.GetAnalysisDetail(id);
|
||||||
|
return Ok(ApiResponse<CollectAnalysisDetail>.Success(detail));
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/admin/collect-log/analysis/by-raw/{rawLogId}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("analysis/by-raw/{rawLogId}")]
|
||||||
|
[ResponseType(typeof(ApiResponse<List<CollectAnalysisListItem>>))]
|
||||||
|
public IHttpActionResult GetAnalysisByRawLogId(long rawLogId)
|
||||||
|
{
|
||||||
|
var list = _collectLogService.GetAnalysisByRawLogId(rawLogId);
|
||||||
|
return Ok(ApiResponse<List<CollectAnalysisListItem>>.Success(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/admin/collect-log/cycle
|
||||||
|
[HttpGet]
|
||||||
|
[Route("cycle")]
|
||||||
|
[ResponseType(typeof(ApiResponse<PagedResult<CollectCycleListItem>>))]
|
||||||
|
public IHttpActionResult GetCycleList([FromUri] CollectCycleQuery query)
|
||||||
|
{
|
||||||
|
var result = _collectLogService.GetCycleList(query);
|
||||||
|
return Ok(ApiResponse<PagedResult<CollectCycleListItem>>.Success(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/admin/collect-log/raw
|
||||||
|
[HttpGet]
|
||||||
|
[Route("raw")]
|
||||||
|
[ResponseType(typeof(ApiResponse<PagedResult<CollectRaw>>))]
|
||||||
|
public IHttpActionResult GetRaw([FromUri] int? collectAddressId, [FromUri] int page = 1, [FromUri] int pageSize = 20, [FromUri] string startDate = null, [FromUri] string endDate = null, [FromUri] bool? isSuccess = null)
|
||||||
|
{
|
||||||
|
// 通过 ICollectRawRepository 进行分页查询,具体筛选条件以仓储实现为准
|
||||||
|
var result = _rawRepository.GetByAddressId(collectAddressId ?? 0, page, pageSize);
|
||||||
|
return Ok(ApiResponse<PagedResult<CollectRaw>>.Success(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue