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

24 lines
624 B
Bash

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
# 使用方法:
# ./genModel.sh
# 再将./genModel下的文件剪切到对应服务的model目录里面记得改package
#待生成的表名
tables=("user" "user_login_record" "role" "rel_user_role")
#生成路径
targetDir=./genModel
templateDir=../../doc/template
# 数据库配置
host=192.168.1.100
port=3306
dbname=qxb
username=root
passwd=root
for table in "${tables[@]}"; do
echo "开始创建库:$dbname 的表:${table}"
goctl model mysql datasource --url "${username}:${passwd}@tcp(${host}:${port})/${dbname}" -t "${table}" -d "${targetDir}" --style go_zero --home "${templateDir}"
done