merch initial
This commit is contained in:
parent
09e3c30cf6
commit
303086e2a3
5 changed files with 111 additions and 0 deletions
11
internal/api/merch/controller.go
Normal file
11
internal/api/merch/controller.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package merch
|
||||
|
||||
type controller struct {
|
||||
service *service
|
||||
}
|
||||
|
||||
func newController(service *service) *controller {
|
||||
return &controller{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
27
internal/api/merch/handler.go
Normal file
27
internal/api/merch/handler.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package merch
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
repo repository
|
||||
service *service
|
||||
controller *controller
|
||||
}
|
||||
|
||||
type Deps struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func NewHandler(deps Deps) *Handler {
|
||||
r := NewRepo(deps.DB)
|
||||
s := newService(r)
|
||||
c := newController(s)
|
||||
|
||||
return &Handler{
|
||||
repo: r,
|
||||
service: s,
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
47
internal/api/merch/model.go
Normal file
47
internal/api/merch/model.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package merch
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Merch struct {
|
||||
Id uint `json:"id" gorm:"primary_key"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"updated_at"`
|
||||
DeletedAt time.Time `json:"deleted_at" gorm:"deleted_at"`
|
||||
MerchUuid string `json:"merch_uuid" gorm:"type:varchar(36);unique_index"`
|
||||
UserUuid string `json:"user_uuid" gorm:"type:varchar(36)"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
Origin string `json:"origin" gorm:"column:origin"`
|
||||
}
|
||||
|
||||
func (Merch) TableName() string {
|
||||
return "merch"
|
||||
}
|
||||
|
||||
type Surugaya struct {
|
||||
Id uint `gorm:"primary_key" json:"-"`
|
||||
DeletedAt time.Time `gorm:"index" json:"-"`
|
||||
MerchUuid uuid.UUID `gorm:"index" json:"-"`
|
||||
Link string `json:"link"`
|
||||
ParseTag string `json:"parse_tag"`
|
||||
ParseSubstring string `json:"parse_substring"`
|
||||
CookieValues string `json:"cookie_values"`
|
||||
Separator string `json:"separator"`
|
||||
}
|
||||
|
||||
func (Surugaya) TableName() string {
|
||||
return "origin_surugaya"
|
||||
}
|
||||
|
||||
type Mandarake struct {
|
||||
Id uint `gorm:"primary_key" json:"-"`
|
||||
DeletedAt time.Time `gorm:"index" json:"-"`
|
||||
MerchUuid uuid.UUID `gorm:"index" json:"-"`
|
||||
Link string `json:"link"`
|
||||
}
|
||||
|
||||
func (Mandarake) TableName() string {
|
||||
return "origin_mandarake"
|
||||
}
|
||||
15
internal/api/merch/repository.go
Normal file
15
internal/api/merch/repository.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package merch
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Repo struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewRepo(db *gorm.DB) *Repo {
|
||||
return &Repo{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
type repository interface{}
|
||||
11
internal/api/merch/service.go
Normal file
11
internal/api/merch/service.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package merch
|
||||
|
||||
type service struct {
|
||||
repo repository
|
||||
}
|
||||
|
||||
func newService(repo repository) *service {
|
||||
return &service{
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue