Konvertiere RequestActions zu IOTA
This commit is contained in:
parent
8603087ed5
commit
3495fb5f50
2 changed files with 9 additions and 5 deletions
|
@ -1,18 +1,22 @@
|
||||||
// request
|
// request
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
type RequestAction int
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
Id int
|
Id int
|
||||||
OfficeHour OfficeHour
|
OfficeHour OfficeHour
|
||||||
Action int
|
Action RequestAction
|
||||||
Secret string
|
Secret string
|
||||||
}
|
}
|
||||||
|
|
||||||
const RequestActivate int = 1 // Fix integer to represent request for activation of an office hour.
|
const (
|
||||||
const RequestDelete int = 2 // Fix integer to represent request for deletion of an office hour.
|
RequestActivate RequestAction = iota // Fix integer to represent request for activation of an office hour.
|
||||||
|
RequestDelete // Fix integer to represent request for deletion of an office hour.
|
||||||
|
)
|
||||||
|
|
||||||
type RequestRepository interface {
|
type RequestRepository interface {
|
||||||
Add(officeHour OfficeHour, action int) (int, error)
|
Add(officeHour OfficeHour, action RequestAction) (int, error)
|
||||||
FindBySecret(secret string) (Request, error)
|
FindBySecret(secret string) (Request, error)
|
||||||
Execute(request Request) error
|
Execute(request Request) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (r *RequestRepo) FindByOfficeHour(officeHour models.OfficeHour) ([]models.R
|
||||||
|
|
||||||
// Add a request to the database if it doesnt already exist.
|
// Add a request to the database if it doesnt already exist.
|
||||||
// Send a mail with the secret to the confirmation address in any case.
|
// Send a mail with the secret to the confirmation address in any case.
|
||||||
func (r *RequestRepo) Add(officeHour models.OfficeHour, action int) (int, error) {
|
func (r *RequestRepo) Add(officeHour models.OfficeHour, action models.RequestAction) (int, error) {
|
||||||
existents, err := r.FindByOfficeHour(officeHour)
|
existents, err := r.FindByOfficeHour(officeHour)
|
||||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
Loading…
Reference in a new issue