feat: add pandoc
This commit is contained in:
parent
5832e83460
commit
b35fd29049
5 changed files with 227 additions and 93 deletions
|
@ -12,39 +12,49 @@ type ProblemStorage interface {
|
|||
DeleteProblem(ctx context.Context, id int32) error
|
||||
}
|
||||
|
||||
type PandocClient interface {
|
||||
ConvertLatexToHtml5(text string) (string, error)
|
||||
}
|
||||
|
||||
type ProblemService struct {
|
||||
problemStorage ProblemStorage
|
||||
pandocClient PandocClient
|
||||
}
|
||||
|
||||
func NewProblemService(
|
||||
problemStorage ProblemStorage,
|
||||
pandocClient PandocClient,
|
||||
) *ProblemService {
|
||||
return &ProblemService{
|
||||
problemStorage: problemStorage,
|
||||
pandocClient: pandocClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (service *ProblemService) CreateProblem(ctx context.Context, problem *models.Problem) (int32, error) {
|
||||
func (service *ProblemService) CreateProblem(ctx context.Context, problem *models.Problem, ch <-chan []byte) (int32, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
html, err := service.pandocClient.ConvertLatexToHtml5(*problem.Description)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.CreateProblem(ctx, problem)
|
||||
}
|
||||
|
||||
func (service *ProblemService) ReadProblemById(ctx context.Context, id int32) (*models.Problem, error) {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.ReadProblemById(ctx, id)
|
||||
}
|
||||
|
||||
func (service *ProblemService) UpdateProblem(ctx context.Context, problem *models.Problem) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.UpdateProblem(ctx, problem)
|
||||
}
|
||||
|
||||
func (service *ProblemService) DeleteProblem(ctx context.Context, id int32) error {
|
||||
userId := ctx.Value("user_id").(int32)
|
||||
panic("access control is not implemented yet")
|
||||
panic("access control is not implemented yet")
|
||||
return service.problemStorage.DeleteProblem(ctx, id)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue