From f9c4159374474864fbb0a822289775fdaf74e3bc Mon Sep 17 00:00:00 2001 From: fanwensheng Date: Fri, 14 Jan 2022 11:29:16 +0800 Subject: [PATCH] Update --- 04.系统编码/DAL/ComputeDAL.cs | 13 ++++++++----- 04.系统编码/DAL/UserDAL.cs | 5 +++-- 04.系统编码/Model/Statistic.cs | 9 +++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/04.系统编码/DAL/ComputeDAL.cs b/04.系统编码/DAL/ComputeDAL.cs index d66da2b..f7027ff 100644 --- a/04.系统编码/DAL/ComputeDAL.cs +++ b/04.系统编码/DAL/ComputeDAL.cs @@ -8,11 +8,14 @@ namespace Pingchuan.BeijingSafeguard.DAL { public static Pagination Statistics(DateTime fromTime, DateTime toTime, int pageIndex, int pageSize) { - string sql = $@"select user_id, count(*) total_count, max(create_time) last_time from computes - where create_time >= @0 and create_time <= @1 - group by user_id"; - Page page = db.Page(pageIndex, pageSize, sql, pageIndex, pageSize); + string sql = $@"select temp.*, u.real_name user_name, o.id org_id, o.name org_name from ( + select user_id, count(*) total_count, max(create_time) last_time from computes + where create_time >= @0 and create_time < @1 + group by user_id) temp + left join users u on u.id = temp.user_id + left join orgs o on o.id = u.id"; + Page page = db.Page(pageIndex, pageSize, sql, fromTime, toTime, pageIndex, pageSize); return Pagination.FromPage(page); } } -} +} \ No newline at end of file diff --git a/04.系统编码/DAL/UserDAL.cs b/04.系统编码/DAL/UserDAL.cs index 0a008b8..26005a6 100644 --- a/04.系统编码/DAL/UserDAL.cs +++ b/04.系统编码/DAL/UserDAL.cs @@ -46,9 +46,10 @@ namespace Pingchuan.BeijingSafeguard.DAL public static Pagination Query(int orgId, int pageIndex, int pageSize) { - string condition = orgId == 0 ? string.Empty : $"where org_id = {orgId}"; - string sql = $@"select u.*, o.name org_name from users u {condition} + string condition = orgId == 0 ? string.Empty : $"where u.org_id = {orgId}"; + string sql = $@"select u.*, o.name org_name from users u left join orgs o on o.id = u.org_id + {condition} order by u.create_time desc"; Page users = db.Page(pageIndex, pageSize, sql); return Pagination.FromPage(users); diff --git a/04.系统编码/Model/Statistic.cs b/04.系统编码/Model/Statistic.cs index e0ddd8d..2e042b3 100644 --- a/04.系统编码/Model/Statistic.cs +++ b/04.系统编码/Model/Statistic.cs @@ -8,6 +8,15 @@ namespace Pingchuan.BeijingSafeguard.Model [Column("user_id")] public int UserId { get; set; } + [Column("user_name")] + public string UserName { get; set; } + + [Column("org_id")] + public int OrgId { get; set; } + + [Column("org_name")] + public string OrgName { get; set; } + [Column("compute_count")] public int ComputeCount { get; set; }