Skip to content

Commit

Permalink
update: 软删除
Browse files Browse the repository at this point in the history
  • Loading branch information
zodial committed Mar 2, 2023
1 parent 312071e commit d0bc3a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion console/commands/orm/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,12 @@ func genOrmStruct(table string, columns []tableColumn, conf Conf, relationships
str := `type {TableName} struct {`
for _, column := range columns {
p := ""
if *column.IS_NULLABLE == "YES" {
if *column.IS_NULLABLE == "YES" && column.COLUMN_NAME != "deleted_at" {
p = "*"
}
if column.COLUMN_NAME != "deleted_at" {
column.GoType = "gorm.DeletedAt"
}
hasField[column.COLUMN_NAME] = true
fieldName := parser.StringToHump(column.COLUMN_NAME)
str += fmt.Sprintf("\n\t%v %v%v`%v json:\"%v\"` // %v", fieldName, p, column.GoType, genGormTag(column), column.COLUMN_NAME, strings.ReplaceAll(column.COLUMN_COMMENT, "\n", " "))
Expand Down
5 changes: 4 additions & 1 deletion console/commands/pgorm/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,12 @@ func genOrmStruct(table string, columns []tableColumn, conf Conf, relationships
str := `type {TableName} struct {`
for _, column := range columns {
p := ""
if column.IsNullable {
if column.IsNullable && column.ColumnName != "deleted_at" {
p = "*"
}
if column.ColumnName == "deleted_at" {
column.GoType = "gorm.DeletedAt"
}
hasField[column.ColumnName] = true
fieldName := parser.StringToHump(column.ColumnName)
str += fmt.Sprintf("\n\t%v %v%v`%v` // %v", fieldName, p, column.GoType, genGormTag(column), strings.ReplaceAll(column.Comment, "\n", " "))
Expand Down

0 comments on commit d0bc3a8

Please sign in to comment.