bill-server-go/internal/label/domain.go

46 lines
1004 B
Go
Raw Normal View History

2023-05-31 16:36:45 +08:00
package label
2023-06-01 19:40:48 +08:00
import (
"context"
"gorm.io/gorm"
)
2023-05-31 16:36:45 +08:00
type Label struct {
2023-06-01 19:40:48 +08:00
gorm.Model
2023-06-01 20:06:43 +08:00
Type string
Name string
Count int
2023-05-31 16:36:45 +08:00
}
2023-06-02 16:07:54 +08:00
type LabelDTO struct {
ID int `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Count int `json:"count"`
}
func (l *Label) Dto() interface{} {
return LabelDTO{
ID: int(l.ID),
Type: l.Type,
Name: l.Name,
Count: l.Count,
}
}
2023-05-31 16:36:45 +08:00
type LabelRepository interface {
2023-06-01 19:40:48 +08:00
GetLabels(ctx context.Context) ([]Label, error)
2023-05-31 16:36:45 +08:00
GetLabelById(ctx context.Context, id int) (*Label, error)
CreateLabel(ctx context.Context, label *Label) error
UpdateLabel(ctx context.Context, label *Label) error
DeleteLabel(ctx context.Context, id int) error
}
type LabelService interface {
2023-06-02 16:07:54 +08:00
GetLabels(ctx context.Context) ([]interface{}, error)
GetLabelById(ctx context.Context, id int) (interface{}, error)
2023-05-31 16:36:45 +08:00
CreateLabel(ctx context.Context, label *Label) error
UpdateLabel(ctx context.Context, label *Label) error
DeleteLabel(ctx context.Context, id int) error
}