3 changed files with 94 additions and 0 deletions
@ -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<Org> Query(int pageIndex, int pageSize) |
|||
{ |
|||
return OrgDAL.Query(pageIndex, pageSize); |
|||
} |
|||
} |
|||
} |
@ -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<Org>(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<Org> Query(int pageIndex, int pageSize) |
|||
{ |
|||
string sql = $@"select * from orgs order by create_time desc"; |
|||
return db.Page<Org>(pageIndex, pageSize, sql); |
|||
} |
|||
} |
|||
} |
@ -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; } |
|||
} |
|||
} |
Loading…
Reference in new issue