| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using molilian.core;
- using dodohold.core;
- using Microsoft.AspNetCore.Mvc;
- using System.Text.Json;
- using static molilian.core.ChartDataCore;
- using TencentCloud.Soe.V20180724.Models;
- namespace molilian.api.Controllers
- {
- [ApiController]
- [MyAuthorize("admin")]
- [Route("api/[controller]/[action]")]
- public class AliyunController : ControllerBase
- {
- readonly IAuthorizationProvider provider = new AdminProvider();
- protected IHttpContextAccessor _accessor;
- public AliyunController(IHttpContextAccessor accessor)
- {
- _accessor = accessor;
- }
- [HttpPost]
- public ActionResult account_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 keyword = form.Read("keyword", string.Empty);
- if (!string.IsNullOrEmpty(keyword))
- {
- filter += $" AND (name like @keyword OR username like @keyword OR company like @keyword OR mobile like @keyword)";
- keyword = $"%{keyword}%";
- }
- filter = filter.StringTrimStart(" AND ");
- //排序
- string orderBy = "id DESC";
- if (!string.IsNullOrEmpty(order))
- {
- order = "descending".Equals(order) ? "DESC" : "ASC";
- orderBy = sort switch
- {
- _ => $"{sort} {order}",
- };
- }
- var result = new DBContext.Table("aliyun_pool")
- .Where(filter, new { keyword })
- .Page(size, page)
- .Order(orderBy)
- .PageList<dynamic>(getTotal);
-
- return new APIResult(new { data = result });
- }
- [HttpPost]
- public ActionResult ecs_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 = CenterHub.GetOpenConnection();
- var result = new DBContext.Table(conn, "center_daily_logs")
- .Where(filter, new { channel, accountName, stime, etime })
- .Page(size, page)
- .Order(orderBy)
- .PageList<DailyLogsDTO>(getTotal);
- var accounts = JdPoolCore.List();
- var hide_ids = accounts.Where(e => e.is_hide).Select(e => e.id).ToList();
- result.List = result.List.Where(e => e.channel != 1 || !hide_ids.Contains(e.accountId));
- return new APIResult(new { data = result });
- }
- }
- }
|