![](http://pic.cnblogs.com/face/u35584.jpg)
最理想的状态就是,大家的习惯是一致的,这样设计出来的东西别人好理解,好接手,更容易搞明白你的设计是什么意图,别人想在你的管理软件上做接口也更容易一些,集成多个软件系统也容易一些。
最理想的状态就是,大家的习惯是一致的,这样设计出来的东西别人好理解,好接手,更容易搞明白你的设计是什么意图,别人想在你的管理软件上做接口也更容易一些,集成多个软件系统也容易一些。
我们中国人的一个特色:谁提出个什么提议,大家都觉得不好,那你让他来吧,他更不行,就是你的这个不行,行的还没有,还没诞生,还在脑海里,这个坏习惯影响了严重我们的团队作战能力,反正我就不服,让我弄我也不会,就是你这个不行,哪里不行,我也说不出来,如何更行没有,那这个问题如何解决?多人协调配合方面,我们跟日本人、韩国人的差距很大,上大学时就被深深的影响过韩国人的团结。
有时候学会放弃是最大的进步,能提高效率,我比较支持秦始皇、成吉思汗、希特勒,都是统一方面的强硬派。
废话少说:
我经常用的字段有如下:需要注意的一点就是,你存的是ID,还是FullName?还是Code 应该区分开来比较好。
ID:主键,每个实体都有他唯一的标识码,就像我们的身份证号码,一般建议采用单主键,好做外键,设置数据库主外键关联约束。
Code:编号,可以不输入,但是不能重复,我有时候会用程序判断,有时候会建立唯一索引,这样也自动不能重复了。
UserName:登录名,用数字或者拼音,登录时方便输入,例如“jirigala”。
FullName:姓名,这是真实的姓名,例如“吉日嘎拉”。
CompanyID:这个数据当时是归属于哪个公司的,因为员工是有可能换工作,调公司的。
DepartmentID:这个数据当时是归属于哪个部门的。
WorkgroupID:这个数据当时是归属于哪个工作组的。
StaffID:这个数据当时是归属于哪个员工的。
Enabled:数据是否已生效,很可能输入的数据经过审核后才会生效的。
DeleteMark:数据是否被删除了,我不能把数据真删了,那就找不回来了。
AuditStatus:审核状态,审核流程放在另外表里,只是状态,写在这个表里了,按严格来说,状态也不应该放在这个表里,应该放在工作流表里。
Description:设计的字段再多,也永远满足不了客户不断在变化的需求,多弄一个备注字段,所有放不下的,没地方放的内容,全部可以塞在这个字段里了,否则你就是设置1000个字段,可能会出现第10001个需求。SortCode:
CreateUserID:这个数据是谁创建的?把主键记录起来,因为直接记录姓名,可能会有姓名重复的可能性,例如在内蒙古我的名字重复的概率就高很多。
CreateUserRealname:创建人的姓名,虽然有些冗余,但是在列表里显示数据很方便,现在硬盘也大,冗余一些也无所谓。
CreateDate:这个数据是什么时候被建立的,出了事情还能知道是什么时候搞出来的,公安是非常重视,什么时候人被咔嚓了,最好是能详细到几点,在什么地点发生的。
ModifyUserID:谁修改了数据?
ModifyUserRealname:谁?
ModifyDate:什么时间修改的数据?
审核状态我一般分,若觉得哪里不妥或者命名有错的,我马上修改:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
//------------------------------------------------------------
2
// All Rights Reserved , Copyright (C) 2009 , Jirisoft , Ltd.
3
//------------------------------------------------------------
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
using System;
6![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
namespace DotNet.Common.Utilities
8![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
9![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
10
/// AuditStatus
11
/// 审核状态。
12
///
13
/// 修改纪录
14
///
15
/// 2009.09.04 版本:1.0 JiRiGaLa 重新调整代码的规范化。
16
///
17
/// 版本:1.0
18
///
19
/// <author>
20
/// <name>JiRiGaLa</name>
21
/// <date>2009.09.04</date>
22
/// </author>
23
/// </summary>
24![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
public enum AuditStatus 审核状态#region public enum AuditStatus 审核状态
25
public enum AuditStatus
26![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
27![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
28
/// 01 递交成功
29
/// </summary>
30
SubmitOK = 1,
31![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
33
/// 02 开始审核
34
/// </summary>
35
StartAudit = 2,
36![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
38
/// 03 待审核
39
/// </summary>
40
WaitForAudit = 3,
41
42![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
43
/// 04 审核通过
44
/// </summary>
45
AuditPass = 4,
46
47![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
48
/// 05 已驳回
49
/// </summary>
50
AuditReject = 5,
51
52![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
53
/// 06 审核结束
54
/// </summary>
55
AuditComplete = 6,
56![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
58
/// 07 撤销失败
59
/// </summary>
60
QuashFail = 7
61
}
62
#endregion
63
}
64![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
65![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
我都会把表结构定义也成一个文件,可以参考代码,当然这个是表结构设计好后用代码生成器生成的,手写太累:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
//------------------------------------------------------------
2
// All Rights Reserved , Copyright (C) 2009 , Jirisoft , Ltd.
3
//------------------------------------------------------------
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
using System;
6![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
namespace DotNet.Common.Model
8![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
9![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
10
/// BaseUserTable
11
/// 用户表结构定义
12
///
13
/// 修改纪录
14
///
15
/// 2009.09.11 版本:4.5 JiRiGaLa 增加 AuditStatus。
16
/// 2008.10.02 版本:4.4 JiRiGaLa 增加 Duty、Title。
17
/// 2008.09.28 版本:4.3 JiRiGaLa 多余字段去掉。
18
/// 2008.09.27 版本:4.2 JiRiGaLa CanVisit 增强,后来又去掉了。
19
/// 2008.02.26 版本:4.1 JiRiGaLa 要求查询账户的在线状态,及该登录账户的电脑IP,MAC信息。
20
/// 2007.01.05 版本:4.0 JiRiGaLa 重新整理代码。
21
/// 2006.12.15 版本:3.0 JiRiGaLa 重新整理代码。
22
/// 2006.11.23 版本:2.0 JiRiGaLa 结构优化整理。
23
/// 2006.02.05 版本:1.1 JiRiGaLa 重新调整代码的规范化。
24
/// 2006.02.02 版本:1.0 JiRiGaLa 书写格式进行整理。
25
/// 2005.01.23 版本:1.0 JiRiGaLa 代码整理。
26
///
27
/// 版本:4.4
28
///
29
/// <author>
30
/// <name>JiRiGaLa</name>
31
/// <date>2008.10.02</date>
32
/// </author>
33
/// </summary>
34
[Serializable]
35
public class BaseUserTable
36![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
37![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
38
/// 表名
39
/// </summary>
40
public static String TableName = "Base_User";
41![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
42![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
43
/// 代码
44
/// </summary>
45
public static String FieldID = "ID";
46![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
48
/// 编号
49
/// </summary>
50
public static String FieldCode = "Code";
51![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
52![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
53
/// 用户名
54
/// </summary>
55
public static String FieldUsername = "Username";
56![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
58
/// 姓名
59
/// </summary>
60
public static String FieldRealname = "Realname";
61![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
62![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////<summary>
63
/// 性别
64
///</summary>
65
public static String FieldSex = "Sex";
66![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////<summary>
68
/// 出生日期
69
///</summary>
70
public static String FieldBirthday = "Birthday";
71![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
72![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////<summary>
73
/// 手机
74
///</summary>
75
public static String FieldMobile = "Mobile";
76![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////<summary>
78
/// QQ号码
79
///</summary>
80
public static String FieldOICQ = "OICQ";
81![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
82![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////<summary>
83
/// 家庭住址
84
///</summary>
85
public static String FieldHomeAddress = "HomeAddress";
86![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
88
/// 默认角色
89
/// </summary>
90
public static String FieldRole = "Role";
91![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
92![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
93
/// 公司
94
/// </summary>
95
public static String FieldCompany = "Company";
96![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
97![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
98
/// 部门
99
/// </summary>
100
public static String FieldDepartment = "Department";
101![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
102![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
103
/// 工作组
104
/// </summary>
105
public static String FieldWorkgroup = "Workgroup";
106![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
107![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
108
/// 岗位
109
/// </summary>
110
public static String FieldDuty = "Duty";
111![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
112![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
113
/// 职称
114
/// </summary>
115
public static String FieldTitle = "Title";
116![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
117![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
118
/// 用户密码
119
/// </summary>
120
public static String FieldUserPassword = "UserPassword";
121![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
122![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
123
/// 电子邮件
124
/// </summary>
125
public static String FieldEmail = "Email";
126![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
127![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
128
/// 系统语言选择
129
/// </summary>
130
public static String FieldLang = "Lang";
131![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
132![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
133
/// 系统样式选择
134
/// </summary>
135
public static String FieldTheme = "Theme";
136![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
137![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
138
/// 第一次访问时间
139
/// </summary>
140
public static String FieldFirstVisit = "FirstVisit";
141![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
142![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
143
/// 上一次访问时间
144
/// </summary>
145
public static String FieldPreviousVisit = "PreviousVisit";
146![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
147![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
148
/// 最后访问时间
149
/// </summary>
150
public static String FieldLastVisit = "LastVisit";
151![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
152![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
153
/// 登录次数
154
/// </summary>
155
public static String FieldLoginCount = "LoginCount";
156![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
157![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
158
/// 是否职员
159
/// </summary>
160
public static String FieldIsStaff = "IsStaff";
161![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
162![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
163
/// 有效[是否锁定帐户同一个功能]
164
/// </summary>
165
public static String FieldEnabled = "Enabled";
166![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
167![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
168
/// 当前记录的审核状态
169
/// </summary>
170
public static String FieldAuditStatus = "AuditStatus";
171![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
172![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
173
/// 是否显示
174
/// </summary>
175
public static String FieldIsVisible = "IsVisible";
176![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
177![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
178
/// 是否在线
179
/// </summary>
180
public static String FieldUserOnLine = "UserOnLine";
181![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
182![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
183
/// IP地址
184
/// </summary>
185
public static String FieldIPAddress = "IPAddress";
186![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
187![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
188
/// MAC地址
189
/// </summary>
190
public static String FieldMACAddress = "MACAddress";
191![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
192![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
193
/// 当点登录标示
194
/// </summary>
195
public static String FieldSUID = "SUID";
196![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
197![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////<summary>
198
/// 删除
199
///</summary>
200
public static String FieldDeleteMark = "DeleteMark";
201![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
202![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
203
/// 备注
204
/// </summary>
205
public static String FieldDescription = "Description";
206![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
207![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
208
/// 密码提示问题代码
209
/// </summary>
210
public static String FieldQuestion = "Question";
211![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
212![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
213
/// 密码提示答案
214
/// </summary>
215
public static String FieldAnswerQuestion = "AnswerQuestion";
216![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
217![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
218
/// 排序码
219
/// </summary>
220
public static String FieldSortCode = "SortCode";
221![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
222![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
223
/// 创建者代码
224
/// </summary>
225
public static String FieldCreateUserID = "CreateUserID";
226![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
227![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
228
/// 创建时间
229
/// </summary>
230
public static String FieldCreateDate = "CreateDate";
231![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
232![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
233
/// 最后修改者代码
234
/// </summary>
235
public static String FieldModifyUserID = "ModifyUserID";
236![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
237![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
238
/// 最后修改时间
239
/// </summary>
240
public static String FieldModifyDate = "ModifyDate";
241
}
242
}由于我们设计水平有限,表结构会经常修改来修改去,这样都定义了,修改表字段名,我的程序就在编译阶段知道都影响了哪里了,我就不太担心表结构变来变去了,当然是在适当的范围内,总比经不起折腾好点吧。
还有就是,程序不变,表结构有变化,需要集成到现有的系统表结构上,那可以考虑采用视图方式或表结构映射方式例如
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
<?xml version="1.0" encoding="utf-8" ?>
2
<sqlMap>
3
<resultMaps>
4
<resultMap id="BasePermissionEntityResult" class="BasePermissionEntity">
5
<result property="ID" column="ID" />
6
<result property="ParentID" column="ParentID" />
7
<result property="Code" column="Code" />
8
<result property="FullName" column="FullName" />
9
<result property="SortCode" column="SortCode" />
10
<result property="IsScope" column="IsScope" />
11
<result property="Enabled" column="Enabled" />
12
<result property="AllowEdit" column="AllowEdit" />
13
<result property="AllowDelete" column="AllowDelete" />
14
<result property="Description" column="Description" />
15
<result property="CreateUserID" column="CreateUserID" />
16
<result property="CreateDate" column="CreateDate" />
17
<result property="ModifyUserID" column="ModifyUserID" />
18
<result property="ModifyDate" column="ModifyDate" />
19
</resultMap>
20
</resultMaps>
21
</sqlMap>很多人有一个坏习惯,软件用都不用就说不好用,所以我把用户什么时候第一次用的,最后一次什么时候用的,登录了几次我都记录下来,可以跟别人对账,一次都没用过,你怎么知道我的软件不好用?就用了几次,你就知道了?神仙啊?
我都说了,最好的程序是经得起折腾,你有水平就说我哪个字段应该修改为什么名字,如何修改,为什么不对,我的程序好处就是经得起折腾,经得起修改。
我最讨厌你参考RBAC吧,RBAC里有个鬼啊,啥也没有的空洞理念啊,你让我参考啥?你有水平就直接说,我应该哪个字段修改什么名字,为是什么?或者你干脆告诉我,找个资深老美设计师来改一下就不就可以了。
为什么我们会为公司的信息应用系统分散而零乱而发愁?就是因为我们连达成统一的用户表的这么第一步都很难,看下面的回复,这个表统一难道真的很不重要吗?那什么才重要?研发操作系统才重要吗?