当我输入接口/服务时,我的 API 没有被获取,但是当我评论我的接口/服务时,它可以工作。生病尝试使用具有相同代码的不同 API 并且它可以工作。
控制器:
private readonly IUnitOfWorkAsync _unitOfWork;
private readonly IDivMapItemListService _divMapItem;
public DivMapItemListController(IUnitOfWorkAsync unitOfWork, IDivMapItemListService divMapItem)
{
_unitOfWork = unitOfWork;
_divMapItem = divMapItem;
}
[HttpGet]
[AllowAnonymous]
[Route("api/item/list")]
public IHttpActionResult DailyItemList()
{
_unitOfWork.BeginTransaction();
try
{
var data = _divMapItem.DailyInsert();
return Ok();
}
catch (Exception ex)
{
_unitOfWork.Rollback();
return InternalServerError();
}
}
服务:
public class DivMapItemListService : Service<DivMapItemList>, IDivMapItemListService
{
private readonly IRepositoryAsync<DivMapItemList> _repository;
public DivMapItemListService(IRepositoryAsync<DivMapItemLis> repository) : base(repository)
{
_repository = repository;
}
public IEnumerable<DivMapItemList> DailyInsert()
{
try
{
var _currentDate = DateTime.Now.Date;
int _lastTwoYears = _currentDate.Year - 2;
var rawData = _repository.GetRepositoryAsync<DivMapItem>().DivMapItemListOpt(_lastTwoYears, _lastTwoYears).ToList();
return rawData;
}
catch (Exception ex)
{
throw ex;
}
}
}
界面
public interface IDivMapItemListService : IService<DivMapItemList>
{
IEnumerable<DivMapItemList> DailyInsert();
}