mirror of
https://github.com/zhufuyi/sponge.git
synced 2025-10-06 01:07:08 +08:00
feat: support parsing mysql data types bit(1) and decimal
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user