From 49ab346d37d69e51102d52ed592fbe978faca0da Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 10 May 2019 19:46:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4AddMaps=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess/DbManager.cs | 16 +--------------- Bootstrap.DataAccess/Dict.cs | 2 ++ Bootstrap.DataAccess/Exceptions.cs | 1 + Bootstrap.DataAccess/Group.cs | 3 +++ Bootstrap.DataAccess/Log.cs | 1 + Bootstrap.DataAccess/Role.cs | 3 +++ Bootstrap.DataAccess/Task.cs | 4 +++- Bootstrap.DataAccess/Trace.cs | 1 + Bootstrap.DataAccess/User.cs | 5 +++++ 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Bootstrap.DataAccess/DbManager.cs b/Bootstrap.DataAccess/DbManager.cs index a735a9ba..9a3ed949 100644 --- a/Bootstrap.DataAccess/DbManager.cs +++ b/Bootstrap.DataAccess/DbManager.cs @@ -18,21 +18,7 @@ namespace Bootstrap.DataAccess { var db = Longbow.Data.DbManager.Create(connectionName, keepAlive); db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand }); - return db.AddMaps(); - } - - private static IDatabase AddMaps(this IDatabase database) - { - database.AddMap("Dicts"); - database.AddMap("Users", new string[] { "Checked", "Period", "NewPassword", "UserStatus" }); - database.AddMap("Exceptions", new string[] { "Period" }); - database.AddMap("Groups", new string[] { "Checked" }); - database.AddMap("Logs"); - database.AddMap("Navigations", new string[] { "ParentName", "CategoryName", "Active", "Menus" }); - database.AddMap("Roles", new string[] { "Checked" }); - database.AddMap("Tasks"); - database.AddMap("Traces"); - return database; + return db; } } } diff --git a/Bootstrap.DataAccess/Dict.cs b/Bootstrap.DataAccess/Dict.cs index 9ef34098..d78081d4 100644 --- a/Bootstrap.DataAccess/Dict.cs +++ b/Bootstrap.DataAccess/Dict.cs @@ -1,6 +1,7 @@ using Bootstrap.Security; using Bootstrap.Security.DataAccess; using Longbow; +using PetaPoco; using System; using System.Collections.Generic; using System.Linq; @@ -10,6 +11,7 @@ namespace Bootstrap.DataAccess /// /// /// + [TableName("Dicts")] public class Dict : BootstrapDict { /// diff --git a/Bootstrap.DataAccess/Exceptions.cs b/Bootstrap.DataAccess/Exceptions.cs index d6fb6620..8eaab64a 100644 --- a/Bootstrap.DataAccess/Exceptions.cs +++ b/Bootstrap.DataAccess/Exceptions.cs @@ -60,6 +60,7 @@ namespace Bootstrap.DataAccess /// /// 获得/设置 时间描述 2分钟内为刚刚 /// + [ResultColumn] public string Period { get; set; } /// diff --git a/Bootstrap.DataAccess/Group.cs b/Bootstrap.DataAccess/Group.cs index ee0cab30..37489531 100644 --- a/Bootstrap.DataAccess/Group.cs +++ b/Bootstrap.DataAccess/Group.cs @@ -1,5 +1,6 @@ using Bootstrap.Security.DataAccess; using Longbow.Data; +using PetaPoco; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Bootstrap.DataAccess /// /// /// + [TableName("Groups")] public class Group { /// @@ -29,6 +31,7 @@ namespace Bootstrap.DataAccess /// /// 获取/设置 用户群组关联状态 checked 标示已经关联 '' 标示未关联 /// + [ResultColumn] public string Checked { get; set; } /// diff --git a/Bootstrap.DataAccess/Log.cs b/Bootstrap.DataAccess/Log.cs index bf498b96..a6c5a294 100644 --- a/Bootstrap.DataAccess/Log.cs +++ b/Bootstrap.DataAccess/Log.cs @@ -7,6 +7,7 @@ namespace Bootstrap.DataAccess /// /// /// + [TableName("Logs")] public class Log : Trace { /// diff --git a/Bootstrap.DataAccess/Role.cs b/Bootstrap.DataAccess/Role.cs index c47cef26..3d2c7172 100644 --- a/Bootstrap.DataAccess/Role.cs +++ b/Bootstrap.DataAccess/Role.cs @@ -1,5 +1,6 @@ using Bootstrap.Security.DataAccess; using Longbow.Data; +using PetaPoco; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Bootstrap.DataAccess /// /// /// + [TableName("Roles")] public class Role { /// @@ -29,6 +31,7 @@ namespace Bootstrap.DataAccess /// /// 获取/设置 用户角色关联状态 checked 标示已经关联 '' 标示未关联 /// + [ResultColumn] public string Checked { get; set; } /// diff --git a/Bootstrap.DataAccess/Task.cs b/Bootstrap.DataAccess/Task.cs index 59f41c56..0faceec1 100644 --- a/Bootstrap.DataAccess/Task.cs +++ b/Bootstrap.DataAccess/Task.cs @@ -1,4 +1,5 @@ -using System; +using PetaPoco; +using System; using System.Collections.Generic; namespace Bootstrap.DataAccess @@ -6,6 +7,7 @@ namespace Bootstrap.DataAccess /// /// /// + [TableName("Tasks")] public class Task { /// diff --git a/Bootstrap.DataAccess/Trace.cs b/Bootstrap.DataAccess/Trace.cs index f7b1ba14..1509718c 100644 --- a/Bootstrap.DataAccess/Trace.cs +++ b/Bootstrap.DataAccess/Trace.cs @@ -7,6 +7,7 @@ namespace Bootstrap.DataAccess /// /// /// + [TableName("Traces")] public class Trace { /// diff --git a/Bootstrap.DataAccess/User.cs b/Bootstrap.DataAccess/User.cs index a46d0dc5..ce8becd3 100644 --- a/Bootstrap.DataAccess/User.cs +++ b/Bootstrap.DataAccess/User.cs @@ -12,6 +12,7 @@ namespace Bootstrap.DataAccess /// /// 用户表实体类 /// + [TableName("Users")] public class User : BootstrapUser { /// @@ -32,6 +33,7 @@ namespace Bootstrap.DataAccess /// /// 获取/设置 角色用户关联状态 checked 标示已经关联 '' 标示未关联 /// + [ResultColumn] public string Checked { get; set; } /// @@ -57,16 +59,19 @@ namespace Bootstrap.DataAccess /// /// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户注册 2 表示更改密码 3 表示更改个人皮肤 4 表示更改显示名称 5 批复新用户注册操作 /// + [ResultColumn] public UserStates UserStatus { get; set; } /// /// 获得/设置 通知描述 2分钟内为刚刚 /// + [ResultColumn] public string Period { get; set; } /// /// 获得/设置 新密码 /// + [ResultColumn] public string NewPassword { get; set; } ///