通用性站点管理后台(Bee OPOA Platform) (2)- 快速开发特性

接上篇(通用性站点管理后台(Bee OPOA Platform) (1))

该篇将介绍一下快速开发的方式。该方式主要是基于Entity类的Property的Attribute实现的。 以下将结合项目(http://beeopoa.codeplex.com/)介绍。

建立表结构

本实例演示如何实现一个员工管理的. 该项目共有两个Sqlite数据库文件AuthDB.db, Data.db, 均在$\trunk\Bee.OPOADemo\App_Data目录下.

先在库Data建立如下表:

CREATE TABLE [Employee] (
  [Id] INTEGER PRIMARY KEY AUTOINCREMENT, 
  [UserName] NVARCHAR, 
  [Sex] INT, 
  [Birthday] DATE, 
  [Nation] NVARCHAR(20), 
  [PartyId] INT, 
  [EducationId] INT, 
  [Jiguan] NVARCHAR(20), 
  [MarryId] INT, 
  [HealthId] INT, 
  [ShenFenId] NVARCHAR(40), 
  [Phone] NVARCHAR(20), 
  [Address] NVARCHAR(200), 
  [Abode] NVARCHAR(200), 
  [Remark] NVARCHAR(200), 
  [UserId] INTEGER, 
  [DepartmentId] INT, 
  [CreateTime] DATETIME, 
  [UpdateTime] DATETIME, 
  [DelFlag] BOOL);

运行项目登入(初始用户名密码均为admin)进入后, 在基础资料->生成表实体类:

 

建立Controller

快速生成该表类后, 再建立对应的Controller:

namespace Bee.OPOADemo.Controllers
{
    public class EmployeeController : ControllerBase<Employee>
    {
        protected override Bee.Data.DbSession GetDbSession(bool useTransaction)
        {
            return new DbSession("Data", useTransaction);
        }
    }
}

配置权限(入口页)

在权限上配置该业务的页面:

点击访问后, 该页面布局很难看的, 但是均能操作及查看.

个性化页面

然后我们可以通过给该实体类增加不同的Attribute来定制化该业务逻辑. 对Bee.Web.ModelProperty的简要说明:

1:Queryable是表明该字段是否可查询,

2:QueryType是表明该字段查询类型

3:MappingName是表明将采用哪个数据字典。

[Bee.Data.OrmTable(TableName = "Employee")]
    [Bee.Web.Model(PageSize = 15, DefaultOrderAscFlag=true)]
    public class User
    {
        #region Properties

        [Bee.Web.ModelProperty(OrderableFlag = true)]
        public Int32 Id { get; set; }

        [Bee.Web.ModelProperty(Description="姓名", OrderableFlag=true,
            Queryable = true, QueryType=Bee.Web.ModelQueryType.Contains)]
        public String UserName { get; set; }

        [Bee.Web.ModelProperty(Description = "部门", MappingName = "DepartmentInfo"
            , Queryable = true, QueryType = Bee.Web.ModelQueryType.Equal)]
        public Int32 DepartmentId { get; set; }

        [Bee.Web.ModelProperty(Description="性别", OrderableFlag=false,MappingName="SexInfo")]
        public int Sex { get; set; }

        [Bee.Web.ModelProperty(Description = "生日", Queryable = true, QueryType = Bee.Web.ModelQueryType.Between)]
        public DateTime Birthday { get; set; }

        [Bee.Web.ModelProperty(Description = "民族")]
        public String Nation { get; set; }

        [Bee.Web.ModelProperty(Description = "政治面貌",  MappingName="PartyInfo")]
        public Int32 PartyId { get; set; }

        [Bee.Web.ModelProperty(Description = "文化程度", MappingName = "EducationInfo")]
        public Int32 EducationId { get; set; }

        [Bee.Web.ModelProperty(Description = "籍贯")]
        public String Jiguan { get; set; }

        [Bee.Web.ModelProperty(Description = "婚姻状况",  MappingName="MarriageInfo")]
        public Int32 MarryId { get; set; }

        [Bee.Web.ModelProperty(Description = "健康状况", MappingName = "HealthInfo")]
        public Int32 HealthId { get; set; }

        [Bee.Web.ModelProperty(Description = "身份证号")]
        public String ShenFenId { get; set; }
        [Bee.Web.ModelProperty(Description = "联系电话", Visible=false)]
        public String Phone { get; set; }

        [Bee.Web.ModelProperty(Description = "家庭地址", Visible=false)]
        public String Address { get; set; }
        [Bee.Web.ModelProperty(Description = "现居住地址", Visible = false)]
        public String Abode { get; set; }

        [Bee.Web.ModelProperty(Description = "个人简介", Visible = false)]
        public String Remark { get; set; }

        [Bee.Web.ModelProperty(Visible = false)]
        public Int32 UserId { get; set; }

        

        [Bee.Web.ModelProperty(Visible = false)]
        public DateTime CreateTime { get; set; }

        [Bee.Web.ModelProperty(Visible = false)]
        public DateTime UpdateTime { get; set; }

        #endregion

    }

修改一下EmployeeController的继承类为ControllerBase<User>; 再配置一下数据字典:

运行预览一下, 新增, 删除, 修改, 查询均已实现:

 

到目前为止MVC三层中我们还没有编码过View层, 这是因为系统根据Entity的定义, 自动生成View,已满足基本的需求。 若需要更加个性化, 则需要编码View层。

更多详细关于MVC层的说明, 将在下篇说明。

posted @ 2012-12-07 12:55    阅读(3914)  评论(3编辑  收藏  举报