diff --git a/04.系统编码/App/Controllers/PointController.cs b/04.系统编码/App/Controllers/PointController.cs new file mode 100644 index 0000000..5979c12 --- /dev/null +++ b/04.系统编码/App/Controllers/PointController.cs @@ -0,0 +1,41 @@ +using PetaPoco; +using System.Web.Mvc; +using System.Collections.Generic; + +using Pingchuan.BeijingSafeguard.BLL; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.App.Controllers +{ + public class PointController : BaseController + { + [HttpPost] + public JsonResult Add(Point point) + { + int id = PointBLL.Add(point); + return Json(id); + } + + [HttpPost] + public JsonResult Update(Point point) + { + int count = PointBLL.Update(point); + return Json(count); + } + + [HttpPost] + public JsonResult Delete(int id) + { + int count = PointBLL.Delete(id); + return Json(count); + } + + [HttpPost] + public JsonResult Query() + { + User user = GetLoginUser(); + List points = PointBLL.Query(user.Id); + return Json(points); + } + } +} \ No newline at end of file diff --git a/04.系统编码/BLL/PointBLL.cs b/04.系统编码/BLL/PointBLL.cs new file mode 100644 index 0000000..55427ca --- /dev/null +++ b/04.系统编码/BLL/PointBLL.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +using Pingchuan.BeijingSafeguard.DAL; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.BLL +{ + public class PointBLL + { + public static int Add(Point point) + { + return PointDAL.Add(point); + } + + public static int Update(Point point) + { + return PointDAL.Update(point); + } + + public static int Delete(int id) + { + return PointDAL.Delete(id); + } + + public static List Query(int userId) + { + return PointDAL.Query(userId); + } + } +} \ No newline at end of file diff --git a/04.系统编码/DAL/PointDAL.cs b/04.系统编码/DAL/PointDAL.cs new file mode 100644 index 0000000..48d275e --- /dev/null +++ b/04.系统编码/DAL/PointDAL.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.DAL +{ + public class PointDAL : BaseDAL + { + public static int Add(Point point) + { + object id = db.Insert(point); + return int.Parse(id.ToString()); + } + + public static int Update(Point point) + { + return db.Update(point); + } + + public static int Delete(int id) + { + return db.Delete(id); + } + + public static List Query(int userId) + { + string sql = $@"select * points where user_id = @0"; + return db.Fetch(sql, userId); + } + } +} \ No newline at end of file diff --git a/04.系统编码/Model/Point.cs b/04.系统编码/Model/Point.cs new file mode 100644 index 0000000..31ec687 --- /dev/null +++ b/04.系统编码/Model/Point.cs @@ -0,0 +1,22 @@ +using System; +using PetaPoco; + +namespace Pingchuan.BeijingSafeguard.Model +{ + [TableName("points")] + [PrimaryKey("id", AutoIncrement = true)] + public class Point + { + [Column("id")] + public int Id { get; set; } + + [Column("user_id")] + public int UserId { get; set; } + + [Column("title")] + public string Title { get; set; } + + [Column("icon")] + public string Icon { get; set; } + } +}