diff --git a/04.系统编码/App/Controllers/OrgManagementController.cs b/04.系统编码/App/Controllers/OrgManagementController.cs index 2b07696..0a687cf 100644 --- a/04.系统编码/App/Controllers/OrgManagementController.cs +++ b/04.系统编码/App/Controllers/OrgManagementController.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; +using PetaPoco; using System.Web.Mvc; +using Pingchuan.BeijingSafeguard.BLL; +using Pingchuan.BeijingSafeguard.Model; + namespace Pingchuan.BeijingSafeguard.App.Controllers { public class OrgManagementController : Controller @@ -13,5 +13,33 @@ namespace Pingchuan.BeijingSafeguard.App.Controllers { return View(); } + + [HttpPost] + public JsonResult Add(Org org) + { + int id = OrgBLL.Add(org); + return Json(id); + } + + [HttpPost] + public JsonResult Update(Org org) + { + int count = OrgBLL.Update(org); + return Json(count); + } + + [HttpPost] + public JsonResult Delete(int id) + { + int count = OrgBLL.Delete(id); + return Json(count); + } + + [HttpPost] + public JsonResult Query(int pageIndex, int pageSize) + { + Page orgs = OrgBLL.Query(pageIndex, pageSize); + return Json(orgs); + } } } \ No newline at end of file diff --git a/04.系统编码/App/Controllers/UserManagementController.cs b/04.系统编码/App/Controllers/UserManagementController.cs index 67be681..6b2f880 100644 --- a/04.系统编码/App/Controllers/UserManagementController.cs +++ b/04.系统编码/App/Controllers/UserManagementController.cs @@ -24,7 +24,7 @@ namespace Pingchuan.BeijingSafeguard.App.Controllers [HttpPost] public JsonResult Update(User user) { - int count = UserBLL.Edit(user); + int count = UserBLL.Update(user); return Json(count); } diff --git a/04.系统编码/BLL/BLL.csproj b/04.系统编码/BLL/BLL.csproj index 500bdce..949f41e 100644 --- a/04.系统编码/BLL/BLL.csproj +++ b/04.系统编码/BLL/BLL.csproj @@ -47,6 +47,7 @@ + diff --git a/04.系统编码/BLL/UserBLL.cs b/04.系统编码/BLL/UserBLL.cs index c96c2b7..27f0beb 100644 --- a/04.系统编码/BLL/UserBLL.cs +++ b/04.系统编码/BLL/UserBLL.cs @@ -20,15 +20,17 @@ namespace Pingchuan.BeijingSafeguard.BLL public static int Add(User user) { + user.Enabled = 1; user.ComputeCount = 0; user.LastComputeTime = null; + user.LastLoginTime = null; user.CreateTime = DateTime.Now; return UserDAL.Add(user); } - public static int Edit(User user) + public static int Update(User user) { - return UserDAL.Edit(user); + return UserDAL.Update(user); } public static int Delete(int id) diff --git a/04.系统编码/DAL/DAL.csproj b/04.系统编码/DAL/DAL.csproj index be4919d..5c9d7bb 100644 --- a/04.系统编码/DAL/DAL.csproj +++ b/04.系统编码/DAL/DAL.csproj @@ -51,6 +51,7 @@ + diff --git a/04.系统编码/DAL/UserDAL.cs b/04.系统编码/DAL/UserDAL.cs index 968b5a9..ef71312 100644 --- a/04.系统编码/DAL/UserDAL.cs +++ b/04.系统编码/DAL/UserDAL.cs @@ -1,6 +1,5 @@ using PetaPoco; using Pingchuan.BeijingSafeguard.Model; -using System.Collections.Generic; namespace Pingchuan.BeijingSafeguard.DAL { @@ -27,7 +26,7 @@ namespace Pingchuan.BeijingSafeguard.DAL return (int)db.Insert(user); } - public static int Edit(User user) + public static int Update(User user) { return db.Update(user); } @@ -37,6 +36,12 @@ namespace Pingchuan.BeijingSafeguard.DAL return db.Delete(id); } + public static int Enable(int id, int enable) + { + string sql = $@"update users set enable = {enable} where id = {id}"; + return db.Execute(sql); + } + public static Page Query(int pageIndex, int pageSize) { string sql = $@"select * from users order by create_time desc"; diff --git a/04.系统编码/Model/Model.csproj b/04.系统编码/Model/Model.csproj index 7cb859a..d4ed8d4 100644 --- a/04.系统编码/Model/Model.csproj +++ b/04.系统编码/Model/Model.csproj @@ -47,6 +47,7 @@ + diff --git a/04.系统编码/Model/User.cs b/04.系统编码/Model/User.cs index a0c7dd9..96149ee 100644 --- a/04.系统编码/Model/User.cs +++ b/04.系统编码/Model/User.cs @@ -10,9 +10,15 @@ namespace Pingchuan.BeijingSafeguard.Model [Column("id")] public int Id { set; get; } + [Column("org_id")] + public int OrgId { set; get; } + [Column("gender")] public int Gender { set; get; } + [Column("enabled")] + public int Enabled { set; get; } + [Column("real_name")] public string RealName { set; get; } @@ -28,6 +34,9 @@ namespace Pingchuan.BeijingSafeguard.Model [Column("last_compute_time")] public DateTime? LastComputeTime { get; set; } + [Column("last_login_time")] + public DateTime? LastLoginTime { get; set; } + [Column("create_time")] public DateTime CreateTime { set; get; } }