chanched handlers

This commit is contained in:
2023-08-12 19:26:50 +03:00
parent 85f4b92fa7
commit 17a09f7fb3
28 changed files with 503 additions and 1001 deletions

View File

@@ -24,5 +24,9 @@ insert into package(name, url, modules) values ($1, $2, $3);
insert into module(name, version, last_version) values
%s
returning id;
`
queryGetModule = `
select id, name, version, last_version from module
where id in %s ;
`
)

View File

@@ -1,28 +0,0 @@
package postgres
const (
queryListPackage = `
select
id,
name,
url,
comments
--modules,
--issues,
from package;
`
queryAddComment = `
with insert_comm as (
insert into comment(text) values ($1) returning id
)
update package set comments = array_append(comments, (select * from insert_comm)) where id=$2;
`
queryAddPackage = `
insert into package(name, url, modules) values ($1, $2, $3);
`
queryInsMsgGetIDs = `
insert into module(name, version, last_version) values
%s
returning id;
`
)

View File

@@ -6,7 +6,6 @@ import (
"embed"
"errors"
"fmt"
pb "go.unistack.org/unistack-org/pkgdash/proto"
"strings"
"github.com/golang-migrate/migrate/v4"
@@ -16,6 +15,7 @@ import (
"go.unistack.org/micro/v4/logger"
"go.unistack.org/unistack-org/pkgdash/config"
"go.unistack.org/unistack-org/pkgdash/models"
pb "go.unistack.org/unistack-org/pkgdash/proto"
)
const (
@@ -138,7 +138,7 @@ func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error
}
}()
res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage.Value)
res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage)
if err != nil {
return err
}
@@ -168,7 +168,7 @@ func (s *Postgres) AddPackage(ctx context.Context, req *pb.AddPackageReq) error
}
}()
res, err := tx.ExecContext(ctx, queryAddPackage, req.Name.Value, req.Url.Value, pq.Array(req.Modules))
res, err := tx.ExecContext(ctx, queryAddPackage, req.Name, req.Url, pq.Array(req.Modules))
if err != nil {
return err
}