probo/models/answer.go

28 lines
394 B
Go
Raw Normal View History

2022-06-23 11:25:35 +02:00
package models
2023-11-13 21:01:12 +01:00
import (
"crypto/sha256"
"fmt"
)
2022-06-23 11:25:35 +02:00
type Answer struct {
2023-10-28 20:50:06 +02:00
ID string `json:"id" gorm:"primaryKey"`
2023-07-12 09:30:56 +02:00
Text string `json:"text"`
2022-06-23 11:25:35 +02:00
}
2023-11-13 21:01:12 +01:00
func (a *Answer) String() string {
return a.Text
}
func (a *Answer) GetID() string {
return a.ID
}
func (a *Answer) SetID(id string) {
a.ID = id
}
func (a *Answer) GetHash() string {
return fmt.Sprintf("%x", sha256.Sum256([]byte(a.Text)))
}