2 Star 1 Fork 1

mosache / YFrame

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vo.go 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
ヤ沒脩袮兲︶ 提交于 2023-09-11 13:39 . temp
package gen
import (
"fmt"
)
type tableNameAndCommentFilterMapKey struct {
TableName string
TableComment string
}
type tableInfo struct {
TableName string
TableComment string
Package string
TableNamePrefix string
ModName string
IsNew bool
Columns []tableColumnInfo
}
type tableColumnInfo struct {
ColumnName string
DataType string // go 中的type
ColumType string
ColumnComment string
IsPrimaryKey bool
Tag string
}
func _getGoDataType(sqlDataType string) string {
switch sqlDataType {
case "bigint", "int", "tinyint":
return "int64"
case "decimal":
return "float64"
case "varchar", "text", "time", "mediumtext":
return "string"
default:
return ""
}
}
func _getFieldComment(comment string) string {
if len(comment) == 0 {
return ""
}
return fmt.Sprintf("// %s", comment)
}
func _getIsPrimaryKey(sqlIsPrimaryKey int64) bool {
if sqlIsPrimaryKey == 1 {
return true
}
return false
}
func _getModelFieldTag(columnName string, isPrimaryKey bool) string {
priStr := ""
if isPrimaryKey {
priStr = ";primary_key"
}
return fmt.Sprintf("`gorm:\"column:%s%s\"`", columnName, priStr)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mosache/YFrame.git
git@gitee.com:mosache/YFrame.git
mosache
YFrame
YFrame
v0.1.70

搜索帮助

344bd9b3 5694891 D2dac590 5694891