Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请求大佬增加 mysql ddl 生成库 #80

Open
hanwenbo opened this issue Mar 2, 2022 · 3 comments
Open

请求大佬增加 mysql ddl 生成库 #80

hanwenbo opened this issue Mar 2, 2022 · 3 comments
Labels

Comments

@hanwenbo
Copy link

hanwenbo commented Mar 2, 2022

目前npm 搜索ddl 没找到相关的库
社区有 ddl 2 json的 但是没有 链式操作 生成ddl的库

我目前的需求是根据markdown 生成 msyql的语句建表,因为这样写好文档就相当于写好了mysql

markdown 根据 table 解析为json 已经解决

ddl生成目前采用的 https://github.com/easy-swoole/ddl
不过我觉得生成代码这种工作 放在前端比较好 所以希望社区增加该类型的库

这是我现在用php生成的文件
1.markdown table语法 转为json
2.根据json循环生成 sql文件
3.复制sql内容到Navicat

image

CREATE TABLE IF NOT EXISTS `fa_anubis_order` (
  `id` int(10) UNSIGNED ZEROFILL NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'ID',
  `order_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '订单id',
  `tracking_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '运单id',
  `partner_order_code` varchar(64) NULL DEFAULT NULL COMMENT '外部订单号',
  `serial_number` varchar(64) NULL DEFAULT NULL COMMENT '商家订单流水号',
  `order_status` tinyint(6) UNSIGNED NULL DEFAULT NULL COMMENT '订单状态|ENUM:0:订单生成,1:运单生成成功,20:骑手接单,80:骑手到店,2:配送中,3:已完成,4:已取消,5:配送异常',
  `carrier_driver_id` varchar(64) NULL DEFAULT NULL COMMENT '配送员id',
  `carrier_driver_name` varchar(32) NULL DEFAULT NULL COMMENT '配送员姓名',
  `carrier_driver_phone` varchar(20) NULL DEFAULT NULL COMMENT '配送员电话',
  `estimate_arrive_time` bigint(13) UNSIGNED NULL DEFAULT NULL COMMENT '预计送达时间(毫秒)',
  `overtime_compensation_cost_cent` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '时效赔付',
  `if_can_add_tip` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '调度费支持|ENUM:0:不可以,1:可以',
  `order_tip_amount_cent` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '订单当前小费总金额分',
  `delivery_fetch_photos` varchar NULL DEFAULT NULL COMMENT '骑手取货照片地址',
  `order_total_amount_cent` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '原始配送费金额无需关注',
  `order_actual_amount_cent` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '订单实际配送支付总金额',
  `price_detail` varchar NULL DEFAULT NULL COMMENT '配送费价格明细',
  `abnormal_code` varchar(20) NULL DEFAULT NULL COMMENT '运单异常原因code',
  `abnormal_desc` varchar(255) NULL DEFAULT NULL COMMENT '运单异常原因描述',
  `event_log_details` varchar NULL DEFAULT NULL COMMENT '运单事件节点信息',
  `complaint_id` bigint(20) NULL DEFAULT NULL COMMENT '投诉编号',
  `complaint_reason_desc` varchar(255) NULL DEFAULT NULL COMMENT '投诉原因描述',
  `complaint_status` tinyint(6) NULL DEFAULT NULL COMMENT '投诉状态|ENUM:1:待处理,2:成功,3:失败',
  `claim_id` bigint(20) NULL DEFAULT NULL COMMENT '索赔id',
  `claim_reason_desc` varchar(255) NULL DEFAULT NULL COMMENT '索赔原因描述',
  `claim_status` tinyint(6) UNSIGNED NULL DEFAULT NULL COMMENT '索赔状态|ENUM:1:待处理,2:成功,3:失败',
  `temperature` varchar(20) NULL DEFAULT NULL COMMENT '骑手体温',
  `order_distance` decimal(10,2) NULL DEFAULT NULL COMMENT '配送距离',
  `created_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_time` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  `delete_time` int(10) NOT NULL DEFAULT 0 COMMENT '删除时间'
)
ENGINE = MYISAM DEFAULT COLLATE = 'utf8mb4_general_ci' COMMENT = 'anubis_order';
@hanwenbo hanwenbo added the ✨ Feature Request 新需求 label Mar 2, 2022
@hanwenbo
Copy link
Author

hanwenbo commented Mar 2, 2022

该markdown是从蜂鸟开放平台复制的html 改的 平时要对接10几个开放平台 上千个字段,手动建表写代码工作量太大,所以目前是根据别人的文档生成mysql和部分前后端代码来减少50%的工作量

image

@hanwenbo
Copy link
Author

hanwenbo commented Mar 2, 2022

生成的json文件,拿这些json文件再转为sql语句,目前缺ddl这一步,用php实现的,理想状态是我在web的网页上直接生成sql,但现在还需要借助php 多一步

{"order_id":{"type":"bigint(20) Unsigned","desc":"订单id","enum":"","remark":""},"tracking_id":{"type":"bigint(20) Unsigned","desc":"运单id","enum":"","remark":""},"partner_order_code":{"type":"varchar(64)","desc":"外部订单号","enum":"","remark":""},"serial_number":{"type":"varchar(64)","desc":"商家订单流水号","enum":"","remark":""},"order_status":{"type":"tinyint(6) Unsigned","desc":"订单状态","enum":"0:订单生成,1:运单生成成功,20:骑手接单, 80:骑手到店,2:配送中,3:已完成, 4:已取消,5:配送异常","remark":""},"carrier_driver_id":{"type":"varchar(64)","desc":"配送员ID","enum":"","remark":""},"carrier_driver_name":{"type":"varchar(32)","desc":"配送员姓名","enum":"","remark":""},"carrier_driver_phone":{"type":"varchar(20)","desc":"配送员电话","enum":"","remark":""},"estimate_arrive_time":{"type":"bigint(13) Unsigned","desc":"预计送达时间(毫秒)","enum":"","remark":""},"overtime_compensation_cost_cent":{"type":"int(10 )Unsigned","desc":"时效赔付","enum":"","remark":""},"if_can_add_tip":{"type":"int(10) Unsigned","desc":"调度费支持","enum":"0:不可以,1:可以","remark":"是否支持添加调度费 1可以,0不可以"},"order_tip_amount_cent":{"type":"int(10) Unsigned","desc":"订单当前小费总金额 分","enum":"","remark":""},"delivery_fetch_photos":{"type":"json","desc":"骑手取货照片地址","enum":"","remark":""},"order_total_amount_cent":{"type":"int(10) Unsigned","desc":"原始配送费金额无需关注","enum":"","remark":"原始配送费金额(优惠 前的纯配送费,不含 小费等) 该字段无需关注分"},"order_actual_amount _cent":{"type":"int(10) Unsigned","desc":"订单实际配送支付总 金额","enum":"","remark":"订单实际配送支付总 金额(优惠后 含小费等 一般关注这个字段即可)分"},"price_detail":{"type":"json","desc":"配送费价格明细","enum":"","remark":"PriceOpenapiDetail 详情见上文预下单文档"},"abnormal_code":{"type":"varchar(20)","desc":"运单异常原因code","enum":"","remark":""},"abnormal_desc":{"type":"varchar(255)","desc":"运单异常原因描述","enum":"","remark":""},"event_log_details":{"type":"json","desc":"运单事件节点信息","enum":"","remark":"示例: [ { <strong>&quot;order_status&quot;</strong>:<strong>1</strong>, <strong>&quot;occur_time&quot;</strong>:<strong>1469088084269</strong>, <strong>&quot;carrier_driver_name&quot;</strong>:<strong>&quot;张三&quot;</strong>, <strong>&quot;carrier_driver_phone&quot;</strong>:<strong>&quot;13112345678&quot;</strong> }, { <strong>&quot;order_status&quot;</strong>:<strong>3</strong>, <strong>&quot;occur_time&quot;</strong>:<strong>1469088084269</strong>, <strong>&quot;carrier_driver_name&quot;</strong>:<strong>&quot;&quot;</strong>, <strong>&quot;carrier_driver_phone&quot;</strong>:<strong>&quot;&quot;</strong> }]"},"complaint_id":{"type":"bigint(20)","desc":"投诉编号","enum":"","remark":""},"complaint_reason_desc":{"type":"varchar(255)","desc":"投诉原因描述","enum":"","remark":""},"complaint_status":{"type":"tinyint(6)","desc":"投诉状态","enum":"1:待处理, 2:成功,3:失败","remark":"投诉状态 1待处理, 2成功,3失败"},"claim_id":{"type":"bigint(20)","desc":"索赔id","enum":"","remark":""},"claim_reason_desc":{"type":"varchar(255)","desc":"索赔原因描述","enum":"","remark":""},"claim_status":{"type":"tinyint(6) Unsigned","desc":"索赔状态","enum":"1:待处理, 2:成功,3:失败","remark":"索赔状态"},"temperature":{"type":"varchar(20)","desc":"骑手体温","enum":"","remark":"示例:骑手体温36.5℃"},"order_distance":{"type":"decimal(10,2)","desc":"配送距离","enum":"","remark":"单位:m"}}

@wangxingkang
Copy link
Member

我先看下哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants