diff --git a/04.系统编码/BLL/OrgBLL.cs b/04.系统编码/BLL/OrgBLL.cs new file mode 100644 index 0000000..34a913d --- /dev/null +++ b/04.系统编码/BLL/OrgBLL.cs @@ -0,0 +1,33 @@ +using System; +using PetaPoco; + +using Pingchuan.BeijingSafeguard.DAL; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.BLL +{ + public class OrgBLL + { + public static int Add(Org org) + { + org.Enabled = 1; + org.CreateTime = DateTime.Now; + return OrgDAL.Add(org); + } + + public static int Update(Org org) + { + return OrgDAL.Update(org); + } + + public static int Delete(int id) + { + return OrgDAL.Delete(id); + } + + public static Page Query(int pageIndex, int pageSize) + { + return OrgDAL.Query(pageIndex, pageSize); + } + } +} \ No newline at end of file diff --git a/04.系统编码/DAL/OrgDAL.cs b/04.系统编码/DAL/OrgDAL.cs new file mode 100644 index 0000000..a56a82e --- /dev/null +++ b/04.系统编码/DAL/OrgDAL.cs @@ -0,0 +1,36 @@ +using System; +using PetaPoco; +using Pingchuan.BeijingSafeguard.Model; + +namespace Pingchuan.BeijingSafeguard.DAL +{ + public class OrgDAL : BaseDAL + { + public static int Add(Org org) + { + return (int)db.Insert(org); + } + + public static int Update(Org org) + { + return db.Update(org); + } + + public static int Delete(int id) + { + return db.Delete(id); + } + + public static int Enable(int id, int enable) + { + string sql = $@"update orgs set enable = {enable} where id = {id}"; + return db.Execute(sql); + } + + public static Page Query(int pageIndex, int pageSize) + { + string sql = $@"select * from orgs order by create_time desc"; + return db.Page(pageIndex, pageSize, sql); + } + } +} diff --git a/04.系统编码/Model/Org.cs b/04.系统编码/Model/Org.cs new file mode 100644 index 0000000..f861349 --- /dev/null +++ b/04.系统编码/Model/Org.cs @@ -0,0 +1,25 @@ +using System; +using PetaPoco; + +namespace Pingchuan.BeijingSafeguard.Model +{ + [TableName("orgs")] + [PrimaryKey("id", AutoIncrement = true)] + public class Org + { + [Column("id")] + public int Id { get; set; } + + [Column("name")] + public string Name { get; set; } + + [Column("enabled")] + public int Enabled { get; set; } + + [Column("creater_id")] + public int CreaterId { get; set; } + + [Column("create_time")] + public DateTime? CreateTime { get; set; } + } +}