modify model
This commit is contained in:
@@ -15,7 +15,11 @@ import (
|
||||
"github.com/zeromicro/go-zero/tools/goctl/util/stringx"
|
||||
)
|
||||
|
||||
const timeImport = "time.Time"
|
||||
const (
|
||||
timeImport = "time.Time"
|
||||
decimalImport = "decimal.Decimal"
|
||||
decimalImportPtr = "*decimal.Decimal"
|
||||
)
|
||||
|
||||
type (
|
||||
// Table describes a mysql table
|
||||
@@ -263,6 +267,16 @@ func (t *Table) ContainsTime() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ContainsDecimal returns true if contains golang type decimal.Decimal
|
||||
func (t *Table) ContainsDecimal() bool {
|
||||
for _, item := range t.Fields {
|
||||
if item.DataType == decimalImport || item.DataType == decimalImportPtr {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ConvertDataType converts mysql data type into golang data type
|
||||
func ConvertDataType(table *model.Table, strict bool) (*Table, error) {
|
||||
isPrimaryDefaultNull := table.PrimaryKey.ColumnDefault == nil && table.PrimaryKey.IsNullAble == "YES"
|
||||
|
||||
Reference in New Issue
Block a user