| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using molilian.core;
- using dodohold.core;
- using Microsoft.AspNetCore.Mvc;
- using Org.BouncyCastle.Ocsp;
- using System.Text.Json;
- using System.Runtime.InteropServices;
- using TencentCloud.Scf.V20180416.Models;
- using Quartz.Impl.AdoJobStore.Common;
- using TencentCloud.Gaap.V20180529.Models;
- using System.Net;
- using TencentCloud.Ie.V20200304.Models;
- using TencentCloud.Soe.V20180724.Models;
- namespace molilian.api.Controllers
- {
- [ApiController]
- [MyAuthorize("admin")]
- [Route("api/[controller]/[action]")]
- public class ReportController : ControllerBase
- {
- readonly IAuthorizationProvider provider = new AdminProvider();
- protected IHttpContextAccessor _accessor;
- public ReportController(IHttpContextAccessor accessor)
- {
- _accessor = accessor;
- }
- [HttpPost]
- public ActionResult daily_list([FromBody] JsonElement form)
- {
- var token = provider.Get(_accessor.HttpContext);
- int page = form.Read("current", 1);
- int size = form.Read("pageSize", 10);
- bool getTotal = form.Read("getTotal", true);
- string sort = form.Read<string>("sort");
- string order = form.Read<string>("order");
- string filter = string.Empty;
- var log_date = form.PathReadArray<string>("query_date[]");
- var accountName = form.Read("accountName", string.Empty);
- int channel = form.Read("channel", -1);
- if (!string.IsNullOrEmpty(accountName))
- {
- filter += $" AND accountName=@accountName";
- }
- else
- {
- filter += $" AND accountName!='all'";
- }
- DateTime stime = DateTime.MinValue, etime = DateTime.MinValue;
- if (log_date.Count == 2)
- {
- if (DateTime.TryParse(log_date[0], out stime) && DateTime.TryParse(log_date[1], out etime))
- {
- etime = etime.AddDays(1).AddSeconds(-1);
- if (etime > DateTime.Now) etime = DateTime.Now;
- filter += $" AND log_date BETWEEN @stime AND @etime";
- }
- }
- if (channel != -1)
- {
- filter += $" AND channel=@channel";
- }
- filter = filter.StringTrimStart(" AND ");
- //排序
- string orderBy = "id DESC";
- if (!string.IsNullOrEmpty(order))
- {
- order = "descending".Equals(order) ? "DESC" : "ASC";
- orderBy = sort switch
- {
- _ => $"{sort} {order}",
- };
- }
- using var conn = DBContext.GetOpenConnection();
- var result = new DBContext.Table(conn, "daily_logs")
- .Where(filter, new { channel, accountName, stime, etime })
- .Page(size, page)
- .Order(orderBy)
- .PageList<DailyLogsDTO>(getTotal);
- return new APIResult(new { data = result });
- }
- }
- }
|