package service import ( "time" "github.com/casehub/ticket-workbench/internal/model" "gorm.io/gorm" ) func ListNotes(db *gorm.DB, ticketid int) ([]model.TicketNote, error) { var notes []model.TicketNote err := db.Where("ticketid = ?", ticketid).Order("createtime ASC").Find(¬es).Error return notes, err } func AddNote(db *gorm.DB, ticketid, authorid int, content string) (*model.TicketNote, error) { note := &model.TicketNote{ Ticketid: ticketid, Authorid: authorid, Content: content, Createtime: time.Now(), } if err := db.Create(note).Error; err != nil { return nil, err } AddOperationLog(db, ticketid, authorid, "note", "添加备注: "+content) return note, nil }