feat: revision-check material writes
- add jz_bm_materials.revision (default 1), read-only for GORM
- bump it only on content changes (models.ReviseMaterial)
- PUT /materials/{id} locks the row and answers 409 to a stale revision
- management answers carry revision and updated_at, the student detail
carries revision
This commit is contained in:
@@ -36,6 +36,11 @@ type Material struct {
|
||||
AuthorUserID *uint `gorm:"column:author_user_id"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||
// Revision goes up by one on every content change (ReviseMaterial).
|
||||
// It is read-only for GORM, so a full-row Save of a stale in-memory
|
||||
// model never writes an old revision back; only ReviseMaterial changes
|
||||
// it.
|
||||
Revision uint `gorm:"column:revision;->"`
|
||||
|
||||
Tags []Tag `gorm:"many2many:jz_bm_material_tag;joinForeignKey:material_id;joinReferences:tag_id"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user