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.
|
|
|
|
#!/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
|