This commit is contained in:
2025-06-17 03:10:31 +07:00
parent be8e7fa482
commit 9cc6646fe3
15 changed files with 432 additions and 131 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ import (
func CreateTeamsPdf(teams []*models.Team) ([]byte, error) {
pdf := &gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4}) // W: 595, H: 842
if err := pdf.AddTTFFont("main", "JetBrainsMono-Medium.ttf"); err != nil {
if err := pdf.AddTTFFont("main", "data/JetBrainsMono-Medium.ttf"); err != nil {
return nil, err
}
if err := pdf.SetFont("main", "", 10); err != nil {
+16
View File
@@ -6,9 +6,11 @@ import (
"encoding/json"
"evening_detective/internal/models"
"evening_detective/internal/modules/password"
"evening_detective/internal/services/pdf_service"
"evening_detective/internal/services/story_service"
"evening_detective/proto"
"fmt"
"time"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
@@ -184,6 +186,20 @@ func (s *Services) AddTeams(ctx context.Context, req *proto.AddTeamsReq) (*proto
return &proto.AddTeamsRsp{Teams: res}, err
}
func (s *Services) DownloadTeamsQrCodesFile(ctx context.Context, req *proto.DownloadTeamsQrCodesFileReq) (*proto.DownloadTeamsQrCodesFileRsp, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
teams, err := s.repository.GetTeams(ctx)
if err != nil {
return nil, err
}
b, err := pdf_service.CreateTeamsPdf(teams)
if err != nil {
return nil, err
}
return &proto.DownloadTeamsQrCodesFileRsp{Result: b}, nil
}
func (s *Services) getTeam(ctx context.Context) (*models.Team, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {