开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from robergroup/chiner
关闭
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
develop
分支 (2)
标签 (4)
develop
master
v3.1.0
v3.0.2
v3.0.1
v3.0.0
develop
分支 (2)
标签 (4)
develop
master
v3.1.0
v3.0.2
v3.0.1
v3.0.0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
develop
分支 (2)
标签 (4)
develop
master
v3.1.0
v3.0.2
v3.0.1
v3.0.0
chiner
/
src
/
lib
/
generatefile
/
markdown.js
chiner
/
src
/
lib
/
generatefile
/
markdown.js
markdown.js 7.28 KB
一键复制 编辑 原始数据 按行查看 历史
龙猫 提交于 2021年07月17日 16:11 +08:00 . 3.0版本集中后,初始化版本
/* eslint-disable */
import _object from 'lodash/object';
const groupList = '分组清单';
const relation = '关联关系';
const tableList = '表清单';
const tableColumnList = '表列清单';
const name = '名称';
const code = '代码';
const dataType = '数据类型';
const main = '主键';
const remark = '备注';
const getFieldType = (datatypes, type, code) => {
const data = (datatypes || []).filter(dt => dt.defKey === type)[0];
return data?.[code] || type;
};
const escapingChar = (str) => {
// \ 反斜线
// ` 反引号
// * 星号
// _ 下划线
// {} 大括号
// [] 中括号
// () 小括号
// # 井号
// + 加号
// - 减号(连字符)
// . 句点
// ! 感叹号
// 针对某些markdown编辑器无法正确显示特殊字符的情况,需要给特殊字符添加转义字符
return str.replace(/[`*_{}[\]()#+-.!]/g, (a) => {
return `\\${a}`;
});
};
const generateHeader = (dataSource) => {
/*
- ### 1.分组清单
- #### [1.1. 测试分组](#groupTset "测试分组")
- ##### 1.1.1. 关联关系
- ##### 1.1.2. 表清单
- ##### 1.1.3. 表列清单
- ###### 1.1.3.1. 用户信息表1
- ###### 1.1.3.1. 用户信息表2
- ###### 1.1.3.1. 用户信息表3
*/
let groupString = ` - ### 1. ${groupList}\n`;
const viewGroups = _object.get(dataSource, 'viewGroups', []);
viewGroups.forEach((group, index) => {
const entityRefs = _object.get(group, 'refEntities', []);
const entities = (dataSource?.entities || []).filter(e => entityRefs.includes(e.defKey));
groupString += `- [<h4 id="group-${group.defKey}-from">1.${index + 1}. ${escapingChar(group.defName || group.defKey)}</h4>](#group-${group.defKey} "${group.defKey}")\n`;
groupString += `\t- [<h5 id="group-${group.defKey}-relation}-from">1.${index + 1}.1. ${relation}</h5>](#group-${group.defKey}-relation "${relation}")\n`;
groupString += `\t- [<h5 id="group-${group.defKey}-tableList-from">1.${index + 1}.2. ${tableList}</h5>](#group-${group.defKey}-tableList "${tableList}")\n`;
groupString += `\t- [<h5 id="group-${group.defKey}-tableColumnList-from">1.${index + 1}.3. ${tableColumnList}</h5>](#group-${group.defKey}-tableColumnList "${tableColumnList}")\n`;
entities.forEach((entity, entityIndex) => {
groupString += `\t\t- [<h6 id="group-${group.defKey}-tableColumnList-${entity.defKey}-from">1.${index + 1}.3.${entityIndex + 1}${escapingChar(entity.defKey)}${entity.defName || ''}】</h6>](#group-${group.defKey}-tableColumnList-${entity.defKey} "${entity.defKey}")\n`
})
});
return groupString;
};
const generateTableListTable = (dataSource, groupKey) => {
/*
| 名称 | 代码 |
| ------------ | ------------ |
| 用户信息 | userManage |
*/
let tableString = `| ${name} | ${code} | ${remark} |\n`;
tableString += `| ------------ | ------------ | ------------ |\n`;
const viewGroups = _object.get(dataSource, 'viewGroups', []);
viewGroups.forEach((group) => {
if (group.defKey === groupKey) {
const entityRefs = _object.get(group, 'refEntities', []);
const entities = (dataSource?.entities || []).filter(e => entityRefs.includes(e.defKey));
entities.forEach((entity) => {
tableString += `| ${entity.defName || ''} | ${escapingChar(entity.defKey)} | ${entity.comment || ''} |\n`;
})
}
});
return tableString;
};
const generateTableColumnListTable = (dataSource, groupKey, tableKey) => {
/*
| 名称 | 代码 |
| ------------ | ------------ |
| 用户信息 | userManage |
*/
const datatypes = _object.get(dataSource, 'dataTypeMapping.mappings', []);
const defaultDb = _object.get(dataSource, 'profile.default.dbs', '');
let tableString = `| ${code} | ${name} | ${dataType}${defaultDb} | ${main} | ${remark} |\n`;
tableString += `| ------------ | ------------ | ------------ | ------------ | ------------ |\n`;
const viewGroups = _object.get(dataSource, 'viewGroups', []);
viewGroups.forEach((group) => {
if (group.defKey === groupKey) {
const entities = _object.get(dataSource, 'entities', []);
entities.forEach((entity) => {
if (entity.defKey === tableKey) {
// 循环实体的属性
(entity.fields || []).forEach((field) => {
// 获取每一个属性对应的每一个数据的数据类型
const fieldType = field.type;
tableString += `| ${escapingChar(field.defKey)} | ${field.defName || ''} | ${fieldType} | ${field.primaryKey && '' || ''} | ${field.comment || ''} |\n`;
});
}
})
}
});
return tableString;
};
const generateRelation = (groupKey, images) => {
/*
![Alt text](/path/to/img.jpg "Optional title")
*/
if (images[groupKey]) {
return images[groupKey]
.map((i) => `\n![image](${i})\n`)
.join('\n');
}
return `\n该模块未配置关系图\n`;
};
const generateModuleBody = (dataSource, images = []) => {
/*
---
### 1. 分组清单
#### 1.1. 测试分组
- #### 1.1.1 关联关系
- #### 1.1.2 表清单
---
| 名称 | 代码 |
| ------------ | ------------ |
| 用户信息 | userManage |
---
- #### 1.1.3 列清单
---
- ##### 用户信息表1
---
- ##### 用户信息表2
---
- ##### 用户信息表3
---
*/
let groupsString = ` ---\n\n`;
groupsString += `### 1. ${groupList}\n`;
const viewGroups = _object.get(dataSource, 'viewGroups', []);
// 循环所有的分组
// 生成关系图
// 生成该分组的表清单
viewGroups.forEach((group, index) => {
groupsString += ` - [<h4 id="group-${group.defKey}">1.${index + 1}. ${group.defName || group.defKey}</h4>](#group-${group.defKey}-from)\n`;
// 关系图
groupsString += ` - [<h5 id="group-${group.defKey}-relation">1.${index + 1}.1 ${relation}</h5>](#group-${group.defKey}-relation-from)\n`;
groupsString += ` ---\n\n`;
if (index === 0){
groupsString += `${generateRelation(group.defKey, images)}\n`;
}
groupsString += ` ---\n\n`;
// 表清单
groupsString += ` - [<h5 id="group-${group.defKey}-tableList">1.${index + 1}.2 ${tableList}</h5>](#group-${group.defKey}-tableList-from)\n\n`;
groupsString += ` ---\n\n`;
groupsString += `${generateTableListTable(dataSource, group.defKey)}\n`;
groupsString += ` ---\n\n`;
// 列清单
// 循环所有的表
groupsString += ` - [<h5 id="group-${group.defKey}-tableColumnList">1.${index + 1}.3 ${tableColumnList}</h5>](#group-${group.defKey}-tableColumnList-from)\n\n`;
groupsString += ` ---\n\n`;
const entityRefs = _object.get(group, 'refEntities', []);
const entities = (dataSource?.entities || []).filter(e => entityRefs.includes(e.defKey));
entities.forEach((entity) => {
groupsString += ` - [<h6 id="group-${group.defKey}-tableColumnList-${entity.defKey}">${entity.defKey}${entity.defName || ''}】</h6>](#group-${group.defKey}-tableColumnList-${entity.defKey}-from)\n\n`;
groupsString += `${generateTableColumnListTable(dataSource, group.defKey, entity.defKey)}\n`;
groupsString += ` ---\n\n`;
});
});
// 生成该分组的表列清单
return groupsString;
};
export const markdown = (dataSource, images, projectName, callBack) => {
const index = '## <center>目录</center>\n';
const header = generateHeader(dataSource);
const body = generateModuleBody(dataSource, images);
callBack && callBack(`${index}${header}${body}`);
};
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

元数建模,一款丰富数据库生态,独立于具体数据库之外的,数据库关系模型设计平台。
暂无标签
MulanPubL-2.0
使用 MulanPubL-2.0 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/sync-github/chiner.git
git@gitee.com:sync-github/chiner.git
sync-github
chiner
chiner
develop
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /