You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool-biz/zero/template/1.4.3/model/delete.tpl

15 lines
683 B
Smarty

2 years ago
func (m *default{{.upperStartCamelObject}}Model) Delete(ctx context.Context, tx *gorm.DB, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error {
{{if .withCache}}data, err:=m.FindOne(ctx, {{.lowerStartCamelPrimaryKey}})
if err!=nil{
if err == ErrNotFound {
return nil
}
return err
}
err = m.ExecCtx(ctx, func(conn *gorm.DB) error {
return gormx.WithTx(ctx, conn, tx).Delete(&{{.upperStartCamelObject}}{}, {{.lowerStartCamelPrimaryKey}}).Error
}, m.getCacheKeys(data)...){{else}} err:= gormx.WithTx(ctx, m.DB, tx).Delete(&{{.upperStartCamelObject}}{}, {{.lowerStartCamelPrimaryKey}}).Error
{{end}}
return err
}