跟我一起学extjs5(34--单个模块的设计[2建立表单表bean])

跟我一起学extjs5(34--单个模块的设计[2建立表单表及bean])

         建立表单方案表:
CREATE TABLE [dbo].[_ModuleFormScheme](
	[tf_formSchemeId] [int] NOT NULL,
	[tf_moduleId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[tf_schemeOrder] [int] NOT NULL,
	[tf_schemeName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[tf_isSystemScheme] [bit] NULL,
	[tf_windowHeight] [int] NULL,
	[tf_windowWidth] [int] NULL,
	[tf_numCols] [int] NULL,
	[tf_displayMode] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[tf_otherSetting] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK___ModuleFormSchem__30F848ED] PRIMARY KEY CLUSTERED 
(
	[tf_formSchemeId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [_ModuleFormScheme_ix1] UNIQUE NONCLUSTERED 
(
	[tf_moduleId] ASC,
	[tf_schemeOrder] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[_ModuleFormScheme]  WITH CHECK ADD  CONSTRAINT [_ModuleFormScheme_fk1] FOREIGN KEY([tf_moduleId])
REFERENCES [dbo].[_Module] ([tf_moduleId])
ON UPDATE CASCADE
ON DELETE CASCADE
        表单方案表的java bean:
package com.jfok.server.hibernate.system;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;
import com.jfok.server.common.annotation.FieldDefine;
import com.jfok.server.common.annotation.TableDefine;

@SuppressWarnings("serial")
@Entity
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@TableDefine(group = "系统模块", id = 9907, title = "模块Form方案", shortname = "Form方案")
public class _ModuleFormScheme implements _IModuleControlInterface, Serializable {

	@Id
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	@FieldDefine(title = "ID号", number = 10)
	private Integer tf_formSchemeId;

	@JsonIgnore
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
	@JoinColumn(name = "tf_moduleId", nullable = false)
	@FieldDefine(title = "模块", number = 20)
	private _Module tf_Module;

	@FieldDefine(title = "顺序号", number = 30)
	@Column(nullable = false)
	private Integer tf_schemeOrder;

	@FieldDefine(title = "方案名称", nameField = true, number = 40)
	@Column(nullable = false, length = 50)
	private String tf_schemeName;

	@FieldDefine(title = "系统方案", number = 50)
	private Boolean tf_isSystemScheme;

	@FieldDefine(title = "窗口高", number = 60)
	private Integer tf_windowHeight;

	@FieldDefine(title = "窗口宽", number = 70)
	private Integer tf_windowWidth;

	@FieldDefine(title = "分栏数", number = 80)
	private Integer tf_numCols;

	@FieldDefine(title = "Form类型", number = 90)
	private String tf_displayMode;

	@FieldDefine(title = "附加设置", number = 100)
	private String tf_otherSetting;

	@OneToMany(targetEntity = _ModuleFormSchemeGroup.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "tf_formSchemeId")
	@OrderBy("tf_formGroupOrder")	
	private List<_ModuleFormSchemeGroup> moduleFormSchemeGroups;

	public _ModuleFormScheme() {

	}
 //getter and setter
}


        表单分组的表的定义及bean:
CREATE TABLE [dbo].[_ModuleFormSchemeGroup](
	[tf_formGroupId] [int] NOT NULL,
	[tf_formSchemeId] [int] NOT NULL,
	[tf_formGroupOrder] [int] NOT NULL,
	[tf_formGroupName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[tf_displayMode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[tf_collapsible] [bit] NULL,
	[tf_collapsed] [bit] NULL,
	[tf_numCols] [int] NULL,
	[tf_auditingGroup] [bit] NULL,
	[tf_approveGroup] [bit] NULL,
	[tf_subModuleName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[tf_otherSetting] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK___ModuleFormSchem__5070F446] PRIMARY KEY CLUSTERED 
(
	[tf_formGroupId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[_ModuleFormSchemeGroup]  WITH CHECK ADD  CONSTRAINT [_ModuleFormSchemeGroup_fk1] FOREIGN KEY([tf_formSchemeId])
REFERENCES [dbo].[_ModuleFormScheme] ([tf_formSchemeId])
ON DELETE CASCADE

package com.jfok.server.hibernate.system;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;
import com.jfok.server.common.annotation.FieldDefine;
import com.jfok.server.common.annotation.TableDefine;

@SuppressWarnings("serial")
@Entity
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@TableDefine(group = "系统模块", id = 9908, title = "模块Form字段分组", shortname = "Form字段分组")
public class _ModuleFormSchemeGroup implements _IModuleControlInterface, Serializable {

	public static final String FORMGROUPID = "tf_formGroupId";

	@Id
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	@FieldDefine(title = "ID号", number = 10)
	private Integer tf_formGroupId;

	@JsonIgnore
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
	@JoinColumn(name = "tf_formSchemeId", nullable = false)
	@FieldDefine(title = "模块Form方案", number = 20)
	private _ModuleFormScheme tf_ModuleFormScheme;

	@FieldDefine(title = "顺序号", number = 30)
	@Column(nullable = false)
	private Integer tf_formGroupOrder;

	@FieldDefine(title = "分组名称", nameField = true, number = 40)
	@Column(nullable = false, length = 50)
	private String tf_formGroupName;

	@FieldDefine(title = "显示方式", number = 50)
	@Column(length = 50)
	private String tf_displayMode;

	@FieldDefine(title = "分栏数", number = 60)
	private Integer tf_numCols;

	@FieldDefine(title = "审核组", number = 70)
	private Boolean tf_auditingGroup;

	@FieldDefine(title = "审批组", number = 80)
	private Boolean tf_approveGroup;

	@FieldDefine(title = "可折叠", number = 90)
	private Boolean tf_collapsible;

	@FieldDefine(title = "默认折叠", number = 100)
	private Boolean tf_collapsed;

	@FieldDefine(title = "子模块名称", remark = "设置此项,则在此组中显示该子模块", number = 110)
	@Column(length = 50)
	private String tf_subModuleName;

	@FieldDefine(title = "其他设置", number = 120)
	private String tf_otherSetting;

	@OneToMany(targetEntity = _ModuleFormSchemeGroupField.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "tf_formGroupId")
	@OrderBy("tf_formFieldOrder")
	private List<_ModuleFormSchemeGroupField> moduleFormSchemeGroupFields;

	public _ModuleFormSchemeGroup() {

	}

//getter and setter
}

        表单字段定义和bean:
CREATE TABLE [dbo].[_ModuleFormSchemeGroupField](
	[tf_formFieldId] [int] NOT NULL,
	[tf_formGroupId] [int] NOT NULL,
	[tf_formFieldOrder] [int] NOT NULL,
	[tf_fieldId] [int] NOT NULL,
	[tf_width] [int] NULL,
	[tf_height] [int] NULL,
	[tf_colspan] [int] NULL,
	[tf_isAllowApprove] [bit] NULL,
	[tf_isStartRow] [bit] NULL,
	[tf_isEndrow] [bit] NULL,
	[tf_otherSetting] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK___ModuleFormSchem__6FE99F9F] PRIMARY KEY CLUSTERED 
(
	[tf_formFieldId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [_ModuleFormSchemeGroupField_ix1] UNIQUE NONCLUSTERED 
(
	[tf_formGroupId] ASC,
	[tf_fieldId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[_ModuleFormSchemeGroupField]  WITH CHECK ADD  CONSTRAINT [_ModuleFormSchemeGroupField_fk1] FOREIGN KEY([tf_formGroupId])
REFERENCES [dbo].[_ModuleFormSchemeGroup] ([tf_formGroupId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[_ModuleFormSchemeGroupField]  WITH CHECK ADD  CONSTRAINT [_ModuleFormSchemeGroupField_fk2] FOREIGN KEY([tf_fieldId])
REFERENCES [dbo].[_ModuleField] ([tf_fieldId])
ON UPDATE CASCADE
ON DELETE CASCADE

package com.jfok.server.hibernate.system;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;
import com.jfok.server.common.annotation.FieldDefine;
import com.jfok.server.common.annotation.TableDefine;

@SuppressWarnings("serial")
@Entity
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@TableDefine(group = "系统模块", id = 9909, title = "模块Form字段", shortname = "Form字段")
public class _ModuleFormSchemeGroupField implements _IModuleControlInterface, Serializable {
	@Id
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	@FieldDefine(title = "ID号", hidden = true, number = 10)
	private Integer tf_formFieldId;

	@JsonIgnore
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name = "tf_formGroupId", nullable = false)
	@FieldDefine(title = "模块Form字段分组", number = 20)
	private _ModuleFormSchemeGroup tf_ModuleFormSchemeGroup;

	@FieldDefine(title = "顺序号", number = 30)
	@Column(nullable = false)
	private Integer tf_formFieldOrder;

	@JsonIgnore
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
	@JoinColumn(name = "tf_fieldId", nullable = false)
	@FieldDefine(title = "模块字段", nameField = true, number = 40)
	private _ModuleField tf_ModuleField;

	// 这个字段用于将数据转成json传到前台时候,加入moduleField的id
	@Column(insertable = false, updatable = false)
	private Integer tf_fieldId;

	@FieldDefine(title = "宽度", number = 50)
	private Integer tf_width;

	@FieldDefine(title = "栏数", number = 60)
	private Integer tf_colspan;

	@FieldDefine(title = "结束行", number = 70)
	private Boolean tf_isEndRow;

	@FieldDefine(title = "附加设置", number = 80)
	private String tf_otherSetting;

	public _ModuleFormSchemeGroupField() {

	}

//getter and setter

}

        这样把字段,列表,表单的表和bean都加入好了,然后需要在_Module.java中加入下列语句:
	@OneToMany(targetEntity = _MenuModule.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "tf_moduleId")
	@OrderBy("tf_fieldOrder")
	private List<_ModuleField> moduleFields;

	@OneToMany(targetEntity = _ModuleFormScheme.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "tf_moduleId")
	@OrderBy("tf_schemeOrder")
	private List<_ModuleFormScheme> moduleFormSchemes;

	@OneToMany(targetEntity = _ModuleGridScheme.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "tf_moduleId")
	@OrderBy("tf_schemeOrder")
	private List<_ModuleGridScheme> moduleGridSchemes;


//getter and setter

        把这三个模块的数据都加到“模块”的bean中,在将模块数据传递到前台的时候一起将字段,列表,表单的信息都传至前台。





郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。