tableModel生成

当前新版本的代码生成器,tableModel的生成已经变成隐藏模式,你在使用时,不会明显的感觉到tableModel的结构。而且tableModel的结构也从XML文件转换为json文件,存储在molicode安装目录下的:tableModel/project_${projectId} 目录下,以表名为文件名称进行存储。

tableModel是数据库表结构的XML描述性文件,它一般有这样的结构:(该结构已经转换为json,以下XML结构仅供参考)。

<?xml version="1.0" encoding="UTF-8" ?>
<tableModel>
  <tableDefine id='AcCommonExtInfo' cnname='扩展信息' dbTableName='ac_common_ext_info'>
    <column dataName='id' columnName='id' cnname='id' columnType='INT' canBeNull='false' readonly='false' isPK='true' length='10' jspTag='TEXT' dictName='' comment='id' />
    <column dataName='ownerType' columnName='owner_type' cnname='归属类型' columnType='INT' canBeNull='false' readonly='false' isPK='false' length='10' jspTag='SELECT' dictName='acCommonExtInfo_ownerType_DICT' comment='归属类型:1.系统,2.项目' />
    <column dataName='ownerCode' columnName='owner_code' cnname='归属码' columnType='VARCHAR' canBeNull='false' readonly='false' isPK='false' length='50' jspTag='TEXT' dictName='' comment='归属码' />
    <column dataName='extKey' columnName='ext_key' cnname='扩展key' columnType='VARCHAR' canBeNull='false' readonly='false' isPK='false' length='50' jspTag='TEXT' dictName='' comment='扩展key' />
    <column dataName='extValue' columnName='ext_value' cnname='扩展值' columnType='VARCHAR' canBeNull='true' readonly='false' isPK='false' length='200' jspTag='TEXT' dictName='' comment='扩展值' />
    <column dataName='type' columnName='type' cnname='类型' columnType='INT' canBeNull='false' readonly='false' isPK='false' length='10' jspTag='SELECT' dictName='acCommonExtInfo_type_DICT' comment='类型:1.文本,2.json,3.xml, 4.properties, 5.开关' />
    <column dataName='creator' columnName='creator' cnname='创建人' columnType='VARCHAR' canBeNull='true' readonly='false' isPK='false' length='20' jspTag='TEXT' dictName='' comment='创建人' />
    <column dataName='operator' columnName='operator' cnname='修改人' columnType='VARCHAR' canBeNull='true' readonly='false' isPK='false' length='20' jspTag='TEXT' dictName='' comment='修改人' />
    <column dataName='concurrentVersion' columnName='concurrent_version' cnname='并发版本号' columnType='BIGINT' canBeNull='true' readonly='false' isPK='false' length='19' jspTag='TEXT' dictName='' comment='并发版本号' />
    <column dataName='dataVersion' columnName='data_version' cnname='数据版本' columnType='BIGINT' canBeNull='true' readonly='false' isPK='false' length='19' jspTag='TEXT' dictName='' comment='数据版本' />
    <column dataName='status' columnName='status' cnname='状态' columnType='TINYINT' canBeNull='true' readonly='false' isPK='false' length='3' jspTag='SELECT' dictName='acCommonExtInfo_status_DICT' comment='状态:1.有效,-1.无效' />
    <column dataName='created' columnName='created' cnname='创建时间' columnType='DATETIME' canBeNull='true' readonly='false' isPK='false' length='19' jspTag='DATETIME' dictName='' comment='创建时间' />
    <column dataName='modified' columnName='modified' cnname='修改时间' columnType='DATETIME' canBeNull='true' readonly='false' isPK='false' length='19' jspTag='DATETIME' dictName='' comment='修改时间' />
  </tableDefine>
  <orderColumns>
    <orderColumn orderType='desc'>id</orderColumn>
  </orderColumns>
  <bizFieldsMap>
    <bizFields key='createTime'>created</bizFields>
    <bizFields key='updateTime'>modified</bizFields>
    <bizFields key='queryList'>id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status,modified</bizFields>
    <bizFields key='addList'>id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status</bizFields>
    <bizFields key='updateList'>id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status</bizFields>
    <bizFields key='viewList'>id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status,created,modified</bizFields>
    <bizFields key='searchKey'>id,owner_type,type,status</bizFields>
    <bizFields key='allColumn'>id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status,created,modified</bizFields>
  </bizFieldsMap>
  <dicts>
    <dict id='acCommonExtInfo_type_DICT' name='type字段的字典项'>
      <option value='1' cssClass=''>文本</option>
      <option value='2' cssClass=''>json</option>
      <option value='3' cssClass=''>xml</option>
      <option value='4' cssClass=''>properties</option>
      <option value='5' cssClass=''>开关</option>
    </dict>
    <dict id='acCommonExtInfo_ownerType_DICT' name='owner_type字段的字典项'>
      <option value='1' cssClass=''>系统</option>
      <option value='2' cssClass=''>项目</option>
    </dict>
    <dict id='acCommonExtInfo_status_DICT' name='status字段的字典项'>
      <option value='1' cssClass=''>有效</option>
      <option value='-1' cssClass=''>无效</option>
    </dict>
  </dicts>
</tableModel>

调整为json模式的存储结构如下图所示:

{
	'bizFieldsMap':{
		'viewList':'id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status,created,modified',
		'createTime':'created',
		'allColumn':'id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status,created,modified',
		'addList':'id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status',
		'updateTime':'modified',
		'searchKey':'id,owner_type,owner_code,type,status',
		'queryList':'id,owner_type,owner_code,type,creator,operator,concurrent_version,data_version,status,created,modified',
		'updateList':'id,owner_type,owner_code,ext_key,ext_value,type,creator,operator,concurrent_version,data_version,status'
	},
	'dictMap':{
		'acCommonExtInfo_type_DICT':{
			'id':'acCommonExtInfo_type_DICT',
			'name':'type字段的字典项',
			'optionList':[
				{
					'name':'文本',
					'value':'1'
				},
				{
					'name':'json',
					'value':'2'
				},
				{
					'name':'xml',
					'value':'3'
				},
				{
					'name':'properties',
					'value':'4'
				},
				{
					'name':'开关',
					'value':'5'
				}
			]
		},
		'acCommonExtInfo_ownerType_DICT':{
			'id':'acCommonExtInfo_ownerType_DICT',
			'name':'owner_type字段的字典项',
			'optionList':[
				{
					'name':'系统',
					'value':'1'
				},
				{
					'name':'项目',
					'value':'2'
				}
			]
		},
		'acCommonExtInfo_status_DICT':{
			'id':'acCommonExtInfo_status_DICT',
			'name':'status字段的字典项',
			'optionList':[
				{
					'name':'有效',
					'value':'1'
				},
				{
					'name':'无效',
					'value':'-1'
				}
			]
		}
	},
	'tableDefine':{
		'cnname':'通用扩展属性',
		'columns':[
			{
				'canBeNull':false,
				'cnname':'id',
				'columnName':'id',
				'columnType':'INT',
				'comment':'id',
				'dataName':'id',
				'isPK':true,
				'jspTag':'TEXT',
				'length':10,
				'readonly':false
			},
			{
				'canBeNull':false,
				'cnname':'归属类型',
				'columnName':'owner_type',
				'columnType':'INT',
				'comment':'归属类型:1.系统,2.项目',
				'dataName':'ownerType',
				'dictName':'acCommonExtInfo_ownerType_DICT',
				'isPK':false,
				'jspTag':'SELECT',
				'length':10,
				'readonly':false
			},
			{
				'canBeNull':false,
				'cnname':'归属码',
				'columnName':'owner_code',
				'columnType':'VARCHAR',
				'comment':'归属码',
				'dataName':'ownerCode',
				'isPK':false,
				'jspTag':'TEXT',
				'length':50,
				'readonly':false
			},
			{
				'canBeNull':false,
				'cnname':'扩展key',
				'columnName':'ext_key',
				'columnType':'VARCHAR',
				'comment':'扩展key',
				'dataName':'extKey',
				'isPK':false,
				'jspTag':'TEXT',
				'length':50,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'扩展值',
				'columnName':'ext_value',
				'columnType':'VARCHAR',
				'comment':'扩展值',
				'dataName':'extValue',
				'isPK':false,
				'jspTag':'TEXT',
				'length':200,
				'readonly':false
			},
			{
				'canBeNull':false,
				'cnname':'类型',
				'columnName':'type',
				'columnType':'INT',
				'comment':'类型:1.文本,2.json,3.xml, 4.properties, 5.开关',
				'dataName':'type',
				'dictName':'acCommonExtInfo_type_DICT',
				'isPK':false,
				'jspTag':'SELECT',
				'length':10,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'创建人',
				'columnName':'creator',
				'columnType':'VARCHAR',
				'comment':'创建人',
				'dataName':'creator',
				'isPK':false,
				'jspTag':'TEXT',
				'length':20,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'修改人',
				'columnName':'operator',
				'columnType':'VARCHAR',
				'comment':'修改人',
				'dataName':'operator',
				'isPK':false,
				'jspTag':'TEXT',
				'length':20,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'并发版本号',
				'columnName':'concurrent_version',
				'columnType':'BIGINT',
				'comment':'并发版本号',
				'dataName':'concurrentVersion',
				'isPK':false,
				'jspTag':'TEXT',
				'length':19,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'数据版本',
				'columnName':'data_version',
				'columnType':'BIGINT',
				'comment':'数据版本',
				'dataName':'dataVersion',
				'isPK':false,
				'jspTag':'TEXT',
				'length':19,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'状态',
				'columnName':'status',
				'columnType':'TINYINT',
				'comment':'状态:1.有效,-1.无效',
				'dataName':'status',
				'dictName':'acCommonExtInfo_status_DICT',
				'isPK':false,
				'jspTag':'SELECT',
				'length':3,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'创建时间',
				'columnName':'created',
				'columnType':'DATETIME',
				'comment':'创建时间',
				'dataName':'created',
				'isPK':false,
				'jspTag':'DATETIME',
				'length':19,
				'readonly':false
			},
			{
				'canBeNull':true,
				'cnname':'修改时间',
				'columnName':'modified',
				'columnType':'DATETIME',
				'comment':'修改时间',
				'dataName':'modified',
				'isPK':false,
				'jspTag':'DATETIME',
				'length':19,
				'readonly':false
			}
		],
		'dbTableName':'ac_common_ext_info',
		'id':'AcCommonExtInfo',
		'pkColumn':{
			'canBeNull':false,
			'cnname':'id',
			'columnName':'id',
			'columnType':'INT',
			'comment':'id',
			'dataName':'id',
			'isPK':true,
			'jspTag':'TEXT',
			'length':10,
			'readonly':false
		},
		'varDomainName':'acCommonExtInfo'
	}
}

生成说明

在通过数据库方式生成代码的时候,拉取table列表后,点击【配置生成代码】;

生成完毕后,会输出到:tableModel存放目录下。

tableModel 【图】 tableModel生成

优化说明

如果非常必要,后续可以提供一个直接选择多个表结构然后一键完成tableModel生产和代码生成的快捷通道,当然,目前因为时间原因,这个需求并不紧迫。