rust-web-server-cli
Generate rust web server code via mustache template.
rust-web-server-cli ╋ mustache code
〓 rust-web-server-example
- cli: generate code
- mapper: generate sql and model
- trans: transform source code to mustache code
Source to use
git clone https://github.com/SimonOsaka/rust-web-server-cli.git
git clone https://github.com/SimonOsaka/rust-web-server-mustache.git
cd rust-web-server-cli
vi mustache.config.toml
- modify mustache path and example path.
mustache_path = "<input 'mustache code' path>"
example_path = "<input path to generate>"
- Everything is
ok
, run commandcargo run
, code will be generate in example_path.
Binary to use
Run cargo build
or cargo build --release
, after that open folder target/debug
or target/release
, open it in terminal and input command
./gen -m <mustache-config-path> -d # -d will output gen detail
for example
./gen -m /path/to/mustache.config.toml
output below
Gen...
Gen success!
Code generation is done.
SQL
Database postgresql, SQL structure => https://github.com/SimonOsaka/my_adventures_api#postgresql-13
.
Database mysql,
CREATE TABLE `my_adventures` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(40) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`is_deleted` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '0:删除,1:正常',
`image_url` varchar(255) NOT NULL DEFAULT '',
`item_type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '类型',
`link` varchar(255) NOT NULL DEFAULT '' COMMENT '外链',
`source` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '来源',
`journey_destiny` varchar(12) NOT NULL DEFAULT '' COMMENT '旅游目的地',
`script_content` varchar(140) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' COMMENT '剧本内容',
`play_list` varchar(16) NOT NULL DEFAULT '' COMMENT '播放列表',
`douban_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'douban subject id',
`douban_rank` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '豆瓣电影排名',
`address` varchar(100) NOT NULL DEFAULT '' COMMENT '地址',
`shop_name` varchar(20) NOT NULL DEFAULT '' COMMENT '商店名称',
`province` varchar(7) NOT NULL DEFAULT '' COMMENT '省',
`city` varchar(10) NOT NULL DEFAULT '' COMMENT '市',
`district` varchar(10) NOT NULL DEFAULT '' COMMENT '区',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;