gofiber-study/model/casbin_model/generate/config.yml
Shikong c5819c1ce6 添加 casbin model 定义
casbin 初始化 && 测试
2022-10-05 16:02:09 +08:00

36 lines
1.1 KiB
YAML

kind: reverse
name: models
source:
database: mysql
conn_str: 'root:12341234@tcp(10.10.10.100:3306)/gofiber?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai'
targets:
- type: codes
language: golang
output_dir: ../models
table_mapper: snake # how table name map to class or struct name
column_mapper: snake # how column name map to class or struct field name
include_tables: # tables included, you can use **
- casbin_model
table_prefix: ""
multiple_files: true # generate multiple files or one
template: | # template for code file, it has higher perior than template_path
package models
{{$ilen := len .Imports}}
{{if gt $ilen 0}}
import (
{{range .Imports}}"{{.}}"{{end}}
)
{{end}}
{{range .Tables}}
type {{TableMapper .Name}} struct {
{{$table := .}}
{{range .ColumnsSeq}}{{$col := $table.GetColumn .}} {{ColumnMapper $col.Name}} {{Type $col}} `{{Tag $table $col}}`
{{end}}
}
func (m *{{TableMapper .Name}}) TableName() string {
return "{{$table.Name}}"
}
{{end}}