You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

62 lines
2.7 KiB

package main
import (
"fmt"
"github.com/miaogaolin/gotl/common/sql2gorm/parser"
"github.com/spf13/pflag"
)
var (
input = pflag.StringP("input", "i", "", "input ddl string")
)
func main() {
pflag.Parse()
s := `
CREATE TABLE IF NOT EXISTS gb_service_people (
id int(10) NOT NULL AUTO_INCREMENT,
name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名字',
avatar varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像',
description varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '描述',
show_status int(1) DEFAULT NULL COMMENT '显示状态:1->显示;2->不显示',
duty_date varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '值班时间,数组,每周天数 1,2,3,4,5,6,7',
type_id int(11) NOT NULL COMMENT '分类ID',
type_name varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
sort int(5) NULL DEFAULT 1 COMMENT '排序',
create_time int(11) NULL DEFAULT 0 COMMENT '创建时间',
update_time int(11) NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '服务保障人员信息' ROW_FORMAT = Compact;
CREATE TABLE IF NOT EXISTS gb_service_message (
id int(10) NOT NULL AUTO_INCREMENT,
people_id bigint(20) DEFAULT NULL COMMENT '关联的服务人员id',
commenter varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '留言者名字',
commenter_contact varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '留言者联系方式',
comment text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '留言内容',
status int(1) DEFAULT NULL COMMENT '显示状态:1->显示;2->不显示',
create_time int(11) NULL DEFAULT 0 COMMENT '创建时间',
update_time int(11) NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '服务保障留言信息' ROW_FORMAT = Compact;
CREATE TABLE IF NOT EXISTS gb_service_type (
id bigint(20) NOT NULL AUTO_INCREMENT,
name varchar(64) DEFAULT NULL COMMENT '分类名称',
sort int(11) DEFAULT NULL COMMENT '排序',
icon varchar(255) DEFAULT NULL COMMENT '图标',
description text DEFAULT NULL COMMENT '描述',
PRIMARY KEY (id)
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = '服务保障分类';
`
res, err := parser.ParseSqlFormat(s,
parser.WithGormType(),
parser.WithJsonTag(),
)
if err != nil {
return
}
fmt.Println(string(res))
}