Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
dengpengju committed Nov 2, 2023
1 parent e5fb3ee commit ff08df0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion arm/IModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type IModel interface {
TableName() *TableName
Apply(model *Model)
Exist() bool
IModel(properties ...him.IProperty) IModel
NewModel(properties ...him.IProperty) IModel
Begin(opts ...*sql.TxOptions) *him.TX
TX(tx *gorm.DB) *Model
}
2 changes: 1 addition & 1 deletion arm/Model.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (this *Model) GormDB() *gorm.DB {
}

func (this *Model) Builder(dao IDao, fn func()) IDao {
model := this.model.IModel()
model := this.model.NewModel()
if this.begin {
model.TX(this.db.GormDB())
}
Expand Down
11 changes: 5 additions & 6 deletions gen/Entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ func (this *Entity) gen() {
rowProperty := this.replaceRowProperty(p.upperProperty, blankFirst, p.propertyType, blankSecond, blankThree, p.tableField, p.tableFieldComment)
if p.upperProperty == UpperCreateTime {
rowTimeNow = "time.Now()"
createTime = rowProperty
}
if p.upperProperty == UpperUpdateTime {
createTime = p.upperProperty
} else if p.upperProperty == UpperUpdateTime {
rowTimeNow = "time.Now()"
updateTime = rowProperty
updateTime = p.upperProperty
}
this.mergeProperty(rowProperty)
}
Expand Down Expand Up @@ -233,7 +232,7 @@ func (this *Entity) replaceUpperPrimaryKey(upperPrimaryKey string) {

func (this *Entity) replaceTimeNow(timeNow string) {
if timeNow != "" {
timeNow = "\n" + LeftStrPad(fmt.Sprintf("%s", timeNow), 4, " ")
timeNow = "\n" + LeftStrPad(fmt.Sprintf("tn := %s", timeNow), 4, " ")
}
this.stubContext = strings.Replace(this.stubContext, "%TIME_NOW%", timeNow, 1)
}
Expand All @@ -247,7 +246,7 @@ func (this *Entity) replaceCreateUpdateTime(createTime, updateTime string) {
if row != "" {
row += ", "
}
row = fmt.Sprintf("%s: tn", updateTime)
row += fmt.Sprintf("%s: tn", updateTime)
}
this.stubContext = strings.Replace(this.stubContext, "%CREATE_UPDATE_TIME%", row, 1)
}
2 changes: 1 addition & 1 deletion gen/stubs/model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (this *Model) New(properties ...him.IProperty) *Model {
return this
}

func (this *Model) IModel(properties ...him.IProperty) arm.IModel {
func (this *Model) NewModel(properties ...him.IProperty) arm.IModel {
return New(properties...)
}

Expand Down
2 changes: 1 addition & 1 deletion test/model/School/Model.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (this *Model) New(properties ...him.IProperty) *Model {
return this
}

func (this *Model) IModel(properties ...him.IProperty) arm.IModel {
func (this *Model) NewModel(properties ...him.IProperty) arm.IModel {
return New(properties...)
}

Expand Down

0 comments on commit ff08df0

Please sign in to comment.