Files
Yi.Framework/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/LogController.cs
2022-09-09 15:53:11 +08:00

56 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.AttributeExtend;
using Yi.Framework.WebCore.AuthorizationPolicy;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
public class LogController : ControllerBase
{
private ILogService _iLogService;
//大量日志将采用自动分表形式默认1年分一次表
public LogController(ILogger<LogEntity> logger, ILogService iLogService)
{
_iLogService = iLogService;
}
/// <summary>
/// 自动分表,日志添加
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<Result> Add()
{
Random random = new Random();
var logList = new List<LogEntity>() {
new LogEntity() { CreateTime = Convert.ToDateTime("2019-12-1"), Message = "jack"+random.Next() } ,
new LogEntity() { CreateTime = Convert.ToDateTime("2022-02-1"), Message = "jack"+random.Next() },
new LogEntity() { CreateTime = Convert.ToDateTime("2020-02-1"), Message = "jack"+random.Next() },
new LogEntity() { CreateTime = Convert.ToDateTime("2021-12-1"), Message = "jack"+random.Next() } };
return Result.Success().SetData(await _iLogService.AddListTest(logList));
}
/// <summary>
/// 查询近20年与21年的日志表
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<Result> GetList()
{
return Result.Success().SetData(await _iLogService.GetListTest());
}
}
}