Skip to content

Commit 36d0cf8

Browse files
committed
feat: upgrade protos to v0.5.0
1 parent ff85334 commit 36d0cf8

File tree

166 files changed

+32357
-32091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+32357
-32091
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ require (
2222
github.com/gofiber/fiber/v2 v2.52.6
2323
github.com/gofiber/template/html/v2 v2.1.3
2424
github.com/golang-jwt/jwt/v5 v5.2.2
25-
github.com/google/go-cmp v0.7.0
2625
github.com/google/uuid v1.6.0
2726
github.com/google/wire v0.6.0
2827
github.com/hashicorp/consul/api v1.31.2
@@ -36,7 +35,7 @@ require (
3635
github.com/redis/go-redis/v9 v9.7.3
3736
github.com/samber/lo v1.49.1
3837
github.com/sony/sonyflake v1.2.0
39-
github.com/tuihub/protos v0.4.25
38+
github.com/tuihub/protos v0.5.0
4039
go.opentelemetry.io/otel v1.34.0
4140
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.10.0
4241
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.10.0
@@ -118,6 +117,7 @@ require (
118117
github.com/golang/protobuf v1.5.4 // indirect
119118
github.com/golang/snappy v0.0.4 // indirect
120119
github.com/google/cel-go v0.23.2 // indirect
120+
github.com/google/go-cmp v0.7.0 // indirect
121121
github.com/gorilla/mux v1.8.1 // indirect
122122
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
123123
github.com/hashicorp/errwrap v1.1.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@ github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ
702702
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
703703
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
704704
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
705-
github.com/tuihub/protos v0.4.25 h1:TaNV9mQRaXJEIyNYOKE0cBNFJgI49cGU+z86U9WjUvE=
706-
github.com/tuihub/protos v0.4.25/go.mod h1:wtL6Qtrb6w+S8GgQfhEq4hxxws6eVyw4XecX1IAlL2o=
705+
github.com/tuihub/protos v0.5.0 h1:j53mBoPlMd0BSx0G9J3RFe+4aWKzmzEqlQid9tcfDYM=
706+
github.com/tuihub/protos v0.5.0/go.mod h1:NzgjndKsJmA1tPevx2MTFbBLeIVC+ykrW87YpTp/ibA=
707707
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
708708
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
709709
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=

internal/biz/bizgebura/app.go

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ package bizgebura
22

33
import (
44
"context"
5+
"time"
56

67
"github.com/tuihub/librarian/internal/biz/bizutils"
78
"github.com/tuihub/librarian/internal/lib/libauth"
89
"github.com/tuihub/librarian/internal/model"
910
"github.com/tuihub/librarian/internal/model/modelgebura"
1011
pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1"
11-
12-
"github.com/go-kratos/kratos/v2/errors"
1312
)
1413

1514
func (g *Gebura) CreateApp(
1615
ctx context.Context,
1716
a *modelgebura.App,
18-
) (*modelgebura.App, *errors.Error) {
17+
) (*modelgebura.App, error) {
1918
claims := libauth.FromContextAssertUserType(ctx)
2019
if claims == nil {
2120
return nil, bizutils.NoPermissionError()
@@ -25,18 +24,27 @@ func (g *Gebura) CreateApp(
2524
return nil, pb.ErrorErrorReasonUnspecified("%s", err)
2625
}
2726
a.ID = id
27+
a.VersionNumber = 1
28+
a.VersionDate = time.Now()
2829
if err = g.repo.CreateApp(ctx, claims.UserID, a); err != nil {
2930
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
3031
}
3132
return a, nil
3233
}
3334

34-
func (g *Gebura) UpdateApp(ctx context.Context, a *modelgebura.App) *errors.Error {
35+
func (g *Gebura) UpdateApp(ctx context.Context, a *modelgebura.App) error {
3536
claims := libauth.FromContextAssertUserType(ctx)
3637
if claims == nil {
3738
return bizutils.NoPermissionError()
3839
}
39-
err := g.repo.UpdateApp(ctx, claims.UserID, a)
40+
old, err := g.repo.GetApp(ctx, a.ID)
41+
if err != nil {
42+
return pb.ErrorErrorReasonUnspecified("%s", err.Error())
43+
}
44+
if old.BoundStoreAppID != 0 && !a.StopStoreManage {
45+
return pb.ErrorErrorReasonBadRequest("under store manage")
46+
}
47+
err = g.repo.UpdateApp(ctx, claims.UserID, a)
4048
if err != nil {
4149
return pb.ErrorErrorReasonUnspecified("%s", err.Error())
4250
}
@@ -47,9 +55,8 @@ func (g *Gebura) ListApps(
4755
ctx context.Context,
4856
paging model.Paging,
4957
ownerIDs []model.InternalID,
50-
appInfoIDs []model.InternalID,
5158
ids []model.InternalID,
52-
) ([]*modelgebura.App, int, *errors.Error) {
59+
) ([]*modelgebura.App, int, error) {
5360
claims := libauth.FromContextAssertUserType(ctx)
5461
if claims == nil {
5562
return nil, 0, bizutils.NoPermissionError()
@@ -59,43 +66,43 @@ func (g *Gebura) ListApps(
5966
ownerIDs = []model.InternalID{claims.UserID}
6067
publicOnly = false
6168
}
62-
res, total, err := g.repo.ListApps(ctx, paging, ownerIDs, appInfoIDs, ids, publicOnly)
69+
res, total, err := g.repo.ListApps(ctx, paging, ownerIDs, ids, publicOnly)
6370
if err != nil {
6471
return nil, 0, pb.ErrorErrorReasonUnspecified("%s", err.Error())
6572
}
6673
return res, total, nil
6774
}
6875

69-
func (g *Gebura) AssignApp(
70-
ctx context.Context,
71-
appID model.InternalID,
72-
appInfoID model.InternalID,
73-
) *errors.Error {
74-
claims := libauth.FromContextAssertUserType(ctx)
75-
if claims == nil {
76-
return bizutils.NoPermissionError()
77-
}
78-
err := g.repo.AssignApp(ctx, claims.UserID, appID, appInfoID)
79-
if err != nil {
80-
return pb.ErrorErrorReasonUnspecified("%s", err)
81-
}
82-
return nil
83-
}
84-
85-
func (g *Gebura) UnAssignApp(ctx context.Context, appID model.InternalID) *errors.Error {
86-
claims := libauth.FromContextAssertUserType(ctx)
87-
if claims == nil {
88-
return bizutils.NoPermissionError()
89-
} else {
90-
err := g.repo.UnAssignApp(ctx, claims.UserID, appID)
91-
if err != nil {
92-
return pb.ErrorErrorReasonUnspecified("%s", err)
93-
}
94-
}
95-
return nil
96-
}
76+
// func (g *Gebura) AssignApp(
77+
// ctx context.Context,
78+
// appID model.InternalID,
79+
// appInfoID model.InternalID,
80+
// ) error {
81+
// claims := libauth.FromContextAssertUserType(ctx)
82+
// if claims == nil {
83+
// return bizutils.NoPermissionError()
84+
// }
85+
// err := g.repo.AssignApp(ctx, claims.UserID, appID, appInfoID)
86+
// if err != nil {
87+
// return pb.ErrorErrorReasonUnspecified("%s", err)
88+
// }
89+
// return nil
90+
//}
91+
//
92+
// func (g *Gebura) UnAssignApp(ctx context.Context, appID model.InternalID) error {
93+
// claims := libauth.FromContextAssertUserType(ctx)
94+
// if claims == nil {
95+
// return bizutils.NoPermissionError()
96+
// } else {
97+
// err := g.repo.UnAssignApp(ctx, claims.UserID, appID)
98+
// if err != nil {
99+
// return pb.ErrorErrorReasonUnspecified("%s", err)
100+
// }
101+
// }
102+
// return nil
103+
//}
97104

98-
// func (g *Gebura) NewReportAppPackageHandler(ctx context.Context) (ReportAppPackageHandler, *errors.Error) {
105+
// func (g *Gebura) NewReportAppPackageHandler(ctx context.Context) (ReportAppPackageHandler, error) {
99106
// claims := libauth.FromContext(ctx)
100107
// if claims == nil {
101108
// return nil, bizutils.NoPermissionError()
@@ -118,7 +125,7 @@ func (g *Gebura) UnAssignApp(ctx context.Context, appID model.InternalID) *error
118125
// sha256 []string
119126
//}
120127
//
121-
// func (r *reportAppPackageHandler) Handle(ctx context.Context, binaries []*modelgebura.AppBinary) *errors.Error {
128+
// func (r *reportAppPackageHandler) Handle(ctx context.Context, binaries []*modelgebura.AppBinary) error {
122129
// var vl []*mapper.Vertex
123130
// packages := make([]*modelgebura.App, 0, len(binaries))
124131
// ids, err := r.g.searcher.NewBatchIDs(ctx, len(binaries))

0 commit comments

Comments
 (0)