feat: add other services
This commit is contained in:
parent
5050f18a2f
commit
56135ff5df
2 changed files with 98 additions and 0 deletions
49
internal/services/language.go
Normal file
49
internal/services/language.go
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LanguageStorage interface {
|
||||||
|
CreateLanguage(ctx context.Context, language *models.Language) (int32, error)
|
||||||
|
ReadLanguageById(ctx context.Context, id int32) (*models.Language, error)
|
||||||
|
UpdateLanguage(ctx context.Context, language *models.Language) error
|
||||||
|
DeleteLanguage(ctx context.Context, id int32) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type LanguageService struct {
|
||||||
|
languageStorage LanguageStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLanguageService(
|
||||||
|
languageStorage LanguageStorage,
|
||||||
|
) *LanguageService {
|
||||||
|
return &LanguageService{
|
||||||
|
languageStorage: languageStorage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *LanguageService) CreateLanguage(ctx context.Context, language *models.Language) (int32, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.languageStorage.CreateLanguage(ctx, language)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *LanguageService) ReadLanguageById(ctx context.Context, id int32) (*models.Language, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.languageStorage.ReadLanguageById(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *LanguageService) UpdateLanguage(ctx context.Context, language *models.Language) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.languageStorage.UpdateLanguage(ctx, language)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *LanguageService) DeleteLanguage(ctx context.Context, id int32) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.languageStorage.DeleteLanguage(ctx, id)
|
||||||
|
}
|
49
internal/services/participants.go
Normal file
49
internal/services/participants.go
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"git.sch9.ru/new_gate/ms-tester/internal/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ParticipantStorage interface {
|
||||||
|
CreateParticipant(ctx context.Context, participant *models.Participant) (int32, error)
|
||||||
|
ReadParticipantById(ctx context.Context, id int32) (*models.Participant, error)
|
||||||
|
UpdateParticipant(ctx context.Context, participant *models.Participant) error
|
||||||
|
DeleteParticipant(ctx context.Context, id int32) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type ParticipantService struct {
|
||||||
|
participantStorage ParticipantStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewParticipantService(
|
||||||
|
participantStorage ParticipantStorage,
|
||||||
|
) *ParticipantService {
|
||||||
|
return &ParticipantService{
|
||||||
|
participantStorage: participantStorage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ParticipantService) CreateParticipant(ctx context.Context, participant *models.Participant) (int32, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.participantStorage.CreateParticipant(ctx, participant)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ParticipantService) ReadParticipantById(ctx context.Context, id int32) (*models.Participant, error) {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.participantStorage.ReadParticipantById(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ParticipantService) UpdateParticipant(ctx context.Context, participant *models.Participant) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.participantStorage.UpdateParticipant(ctx, participant)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *ParticipantService) DeleteParticipant(ctx context.Context, id int32) error {
|
||||||
|
userId := ctx.Value("user_id").(int32)
|
||||||
|
panic("access control is not implemented yet")
|
||||||
|
return service.participantStorage.DeleteParticipant(ctx, id)
|
||||||
|
}
|
Loading…
Reference in a new issue