generated from VLADIMIR/template
add pdf
This commit is contained in:
@@ -59,3 +59,7 @@ func (s *Server) GameStop(ctx context.Context, req *proto.GameStopReq) (*proto.G
|
||||
func (s *Server) GiveApplications(ctx context.Context, req *proto.GiveApplicationsReq) (*proto.GiveApplicationsRsp, error) {
|
||||
return s.services.GiveApplications(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) DownloadTeamsQrCodesFile(ctx context.Context, req *proto.DownloadTeamsQrCodesFileReq) (*proto.DownloadTeamsQrCodesFileRsp, error) {
|
||||
return s.services.DownloadTeamsQrCodesFile(ctx, req)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user