feat: support parsing mysql data types bit(1) and decimal

This commit is contained in:
zhuyasen
2025-01-19 21:55:27 +08:00
parent 2e313280ff
commit 44493211a5
6 changed files with 197 additions and 99 deletions

View File

@@ -168,6 +168,7 @@ func getCommonHandlerStructCodes(data tmplData, jsonNamedType int) (string, erro
} else {
field.JSONName = customToCamel(field.ColName) // camel case (default)
}
field.GoType = getHandlerGoType(&field)
newFields = append(newFields, field)
}
data.Fields = newFields
@@ -388,3 +389,23 @@ func customEndOfLetterToLower(srcStr string, str string) string {
return str
}
func getHandlerGoType(field *tmplField) string {
var goType = field.GoType
if field.DBDriver == DBDriverMysql || field.DBDriver == DBDriverPostgresql || field.DBDriver == DBDriverTidb {
if field.rewriterField != nil {
switch field.rewriterField.goType {
case jsonTypeName:
goType = "string"
case boolTypeName:
goType = "*bool"
case decimalTypeName:
goType = "string"
}
}
}
if field.GoType == "time.Time" {
goType = "*time.Time"
}
return goType
}