-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_category.go
45 lines (39 loc) · 1.53 KB
/
product_category.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package domain
import (
"e-course/pkg/resp"
"mime/multipart"
"time"
"gorm.io/gorm"
)
type ProductCategory struct {
ID int64 `json:"id"`
Name string `json:"name"`
Image *string `json:"image"`
CreatedByID *int64 `json:"created_by" gorm:"column:created_by"`
CreatedBy *Admin `json:"-" gorm:"foreignKey:CreatedByID;references:ID"`
UpdatedByID *int64 `json:"updated_by" gorm:"column:updated_by"`
UpdatedBy *Admin `json:"-" gorm:"foreignKey:UpdatedByID;references:ID"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"deleted_at"`
}
type ProductCategoryRepository interface {
FindAll(offset, limit int) []ProductCategory
FindOneByID(id int) (*ProductCategory, *resp.ErrorResp)
Create(data ProductCategory) (*ProductCategory, *resp.ErrorResp)
Update(data ProductCategory) (*ProductCategory, *resp.ErrorResp)
Delete(data ProductCategory) *resp.ErrorResp
}
type ProductCategoryUsecase interface {
FindAll(offset, limit int) []ProductCategory
FindOneByID(id int) (*ProductCategory, *resp.ErrorResp)
Create(data ProductCategoryRequestBody) (*ProductCategory, *resp.ErrorResp)
Update(id int, data ProductCategoryRequestBody) (*ProductCategory, *resp.ErrorResp)
Delete(id int) *resp.ErrorResp
}
type ProductCategoryRequestBody struct {
Name string `form:"name" binding:"required"`
Image *multipart.FileHeader `form:"image"`
CreatedBy *int64
UpdatedBy *int64
}