54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
"go.unistack.org/unistack-org/pkgdash/proto/go_generate"
|
|
|
|
cmsstorage "go.unistack.org/cms-service/storage"
|
|
"go.unistack.org/micro/v3"
|
|
"go.unistack.org/micro/v3/errors"
|
|
"go.unistack.org/unistack-org/pkgdash/config"
|
|
"golang.org/x/mod/sumdb/storage"
|
|
)
|
|
|
|
type Handler struct {
|
|
//db *xorm.Engine
|
|
|
|
svc micro.Service
|
|
store storage.Storage
|
|
}
|
|
|
|
func (h *Handler) ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (h *Handler) UpdateInfo(ctx context.Context, req *go_generate.UpdateInfoPackageRsp, rsp *go_generate.UpdateInfoPackageReq) error {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (h *Handler) AddComment(ctx context.Context, req *go_generate.CommentRsp, rsp *go_generate.CommentReq) error {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func NewHandler(svc micro.Service) *Handler {
|
|
return &Handler{svc: svc}
|
|
}
|
|
|
|
func (h *Handler) Init(ctx context.Context) error {
|
|
store := cmsstorage.InterfaceFromContext(h.svc.Options().Context)
|
|
if store == nil {
|
|
return cmsstorage.ErrMissingStorage
|
|
}
|
|
st, ok := store.(storage.Storage)
|
|
if !ok {
|
|
return errors.New(config.ServiceName, "error init storage", 1)
|
|
}
|
|
|
|
h.store = st
|
|
|
|
return nil
|
|
}
|