generated from pkg/go-template
feat : script service
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
ab78141e7d
commit
b3c49eaa34
|
@ -8,13 +8,12 @@ import (
|
|||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/service"
|
||||
"git.icechen.cn/monorepo/backend/pkg/api"
|
||||
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders"
|
||||
"git.icechen.cn/monorepo/backend/pkg/rpc"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
@ -90,25 +89,20 @@ func DeleteScriptsH(ctx *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
func GetScriptApi(ctx *fiber.Ctx) error {
|
||||
//todo:调通中间层
|
||||
//todo:换成服务
|
||||
conn, err := grpc.Dial("localhost:3000", grpc.WithInsecure(), grpc.WithBlock())
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
||||
outgoingContext, cancelFunc := pkg.TransFiberCtx2NewOutgoingContext(ctx, 3*time.Second)
|
||||
defer conn.Close()
|
||||
defer cancelFunc()
|
||||
c := murders.NewMurdersClient(conn)
|
||||
c := murders.NewMurdersClient(rpc.GetServiceConn("murder"))
|
||||
|
||||
page := ctx.Query("page", "1")
|
||||
limit := ctx.Query("size", "10")
|
||||
query := ctx.Query("query", "")
|
||||
|
||||
p, err := strconv.Atoi(page)
|
||||
if err != nil {
|
||||
ctxLogger.Error(ctx.UserContext(), pageIsNotInt.Error(), zap.String("page", page))
|
||||
return pageIsNotInt
|
||||
}
|
||||
|
||||
l, err := strconv.Atoi(limit)
|
||||
if err != nil {
|
||||
ctxLogger.Error(ctx.UserContext(), limitIsNotInt.Error(), zap.String("limit", limit))
|
||||
|
@ -116,11 +110,13 @@ func GetScriptApi(ctx *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
validate := validator.New()
|
||||
|
||||
err = validate.Var(p, "gte=0")
|
||||
if err != nil {
|
||||
ctxLogger.Error(ctx.UserContext(), limitIsNotInt.Error(), zap.String("limit", limit))
|
||||
return api.WarpFError(err)
|
||||
}
|
||||
|
||||
err = validate.Var(l, "gte=-1")
|
||||
if err != nil {
|
||||
ctxLogger.Error(ctx.UserContext(), limitIsNotInt.Error(), zap.String("limit", limit))
|
||||
|
@ -129,10 +125,11 @@ func GetScriptApi(ctx *fiber.Ctx) error {
|
|||
|
||||
p64 := int64(p)
|
||||
l64 := int64(l)
|
||||
|
||||
condition := murders.QueryCondition{
|
||||
Page: &p64,
|
||||
Size: &l64,
|
||||
QueryMap: nil,
|
||||
Page: &p64,
|
||||
Size: &l64,
|
||||
Query: &query,
|
||||
}
|
||||
|
||||
scripts, err := c.GetScripts(outgoingContext, &condition)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package model
|
||||
|
||||
type (
|
||||
Category struct {
|
||||
Value string `json:"value" gorm:"column:value"`
|
||||
Uuid string `json:"uuid" gorm:"primary_key" valid:"no_empty"`
|
||||
IsDel int `json:"-" gorm:"column:is_del"`
|
||||
Tags *[]Tag `json:"tags,omitempty" gorm:"many2many:c_tag;foreignKey:Uuid;joinForeignKey:CategoryUid;References:Uuid;JoinReferences:TagUid" valid:"no_empty"`
|
||||
}
|
||||
CategoriesTagDto struct {
|
||||
TIds []string `json:"tag_ids" valid:"no_empty"`
|
||||
Cid string `json:"category_id" valid:"no_empty"`
|
||||
}
|
||||
)
|
|
@ -11,9 +11,10 @@ type (
|
|||
)
|
||||
|
||||
type Scripts struct {
|
||||
ScriptName string `json:"script_name" gorm:"column:script_name"`
|
||||
ScriptIntro string `json:"script_intro" gorm:"column:script_intro"`
|
||||
ScriptTag ints `json:"script_tag" gorm:"column:script_tag"`
|
||||
ScriptName string `json:"script_name" gorm:"column:script_name"`
|
||||
ScriptIntro string `json:"script_intro" gorm:"column:script_intro"`
|
||||
//type json型
|
||||
ScriptTag ints `json:"script_tag" gorm:"column:script_tag" type:"json"`
|
||||
ScriptScore float64 `json:"script_score" gorm:"column:script_score"`
|
||||
GroupDuration int `json:"group_duration" gorm:"column:group_duration"`
|
||||
ScriptCoverUrl string `json:"script_cover_url" gorm:"column:script_cover_url"`
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package model
|
||||
|
||||
type (
|
||||
Tag struct {
|
||||
Value string `json:"value" gorm:"column:value"`
|
||||
Uuid int `json:"uuid" gorm:"primary_key" valid:"no_empty"`
|
||||
IsDel int `json:"-" gorm:"column:is_del" value:"1|0"`
|
||||
Cs *[]Category `json:"categories,omitempty" gorm:"many2many:c_tag;foreignKey:Uuid;joinForeignKey:TagUid;References:Uuid;JoinReferences:CategoryUid" valid:"no_empty"`
|
||||
}
|
||||
)
|
||||
|
||||
func (m *Tag) TableName() string {
|
||||
return "tag"
|
||||
}
|
|
@ -1 +1,189 @@
|
|||
package pkg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/service/token/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"github.com/pkg/errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
Normal = "Normal"
|
||||
JsonArray = "JsonArray"
|
||||
Array = "Array"
|
||||
)
|
||||
const (
|
||||
script = "script"
|
||||
)
|
||||
|
||||
type (
|
||||
entityName string
|
||||
entityKey string
|
||||
keyTag string
|
||||
|
||||
entityAttrMap map[entityName]nameAttr
|
||||
nameAttr map[entityKey]keyTag
|
||||
)
|
||||
|
||||
var (
|
||||
m1 entityAttrMap
|
||||
attr nameAttr
|
||||
)
|
||||
|
||||
func init() {
|
||||
m1 = make(entityAttrMap)
|
||||
m2 := make(map[entityName]interface{})
|
||||
m2[script] = new(model.Scripts)
|
||||
attr = make(nameAttr)
|
||||
getAttr(m2)
|
||||
}
|
||||
|
||||
type (
|
||||
RuleType struct {
|
||||
Rule string
|
||||
Value []string
|
||||
}
|
||||
QueryMap map[string]RuleType
|
||||
Kv map[string]string
|
||||
)
|
||||
|
||||
func GenerateKv(str string) (QueryMap, error) {
|
||||
kv := make(QueryMap)
|
||||
s := []byte(str)
|
||||
i := make([]string, 0)
|
||||
spilt := make([]string, 0)
|
||||
|
||||
if str != "" {
|
||||
spilt = strings.Split(string(s[1:len(s)-1]), ",")
|
||||
}
|
||||
for _, values := range spilt {
|
||||
if i = strings.Split(values, "="); len(i) != 2 {
|
||||
return nil, errors.New("无效字符串")
|
||||
}
|
||||
|
||||
s := keyTag("")
|
||||
ok := true
|
||||
|
||||
if s, ok = attr[entityKey(i[0])]; !ok {
|
||||
return nil, errors.New(fmt.Sprintf("无效的key:%v", i[0]))
|
||||
}
|
||||
|
||||
switch s {
|
||||
case JsonArray:
|
||||
jsonArr := ""
|
||||
isArr := true
|
||||
|
||||
if jsonArr, isArr = processJsonArr(i); !isArr {
|
||||
return nil, errors.New(fmt.Sprintf("无效的jsonArr:%v", i))
|
||||
}
|
||||
|
||||
kv[i[0]] = RuleType{
|
||||
Rule: JsonArray,
|
||||
Value: []string{
|
||||
jsonArr,
|
||||
},
|
||||
}
|
||||
case Array:
|
||||
i2 := make([]string, 0)
|
||||
|
||||
i2 = processArr(i[1])
|
||||
|
||||
kv[i[0]] = RuleType{
|
||||
Rule: Array,
|
||||
Value: i2,
|
||||
}
|
||||
case Normal:
|
||||
kv[i[0]] = RuleType{
|
||||
Rule: Normal,
|
||||
Value: []string{
|
||||
i[1],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return kv, nil
|
||||
}
|
||||
|
||||
func GetParam(queryMap *murders.QueryCondition) (page, limit int, query string) {
|
||||
if queryMap == nil {
|
||||
return
|
||||
}
|
||||
if q := queryMap.Query; q != nil {
|
||||
query = *q
|
||||
}
|
||||
if p := queryMap.Page; p != nil {
|
||||
page = int(*p)
|
||||
}
|
||||
if l := queryMap.Size; l != nil {
|
||||
limit = int(*l)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func getAttr(entity map[entityName]interface{}) {
|
||||
for name, body := range entity {
|
||||
m1[name] = attr
|
||||
|
||||
typ := reflect.TypeOf(body)
|
||||
val := reflect.ValueOf(body)
|
||||
|
||||
if val.Kind().String() != reflect.Ptr.String() {
|
||||
ctxLogger.Error(nil, "is not ptr")
|
||||
panic(errors.New("is not ptr"))
|
||||
}
|
||||
if val.IsNil() {
|
||||
ctxLogger.Error(nil, "nil ptr")
|
||||
panic(errors.New("nil ptr"))
|
||||
}
|
||||
|
||||
num := val.Elem().NumField()
|
||||
for i := 0; i < num; i++ {
|
||||
field := typ.Elem().Field(i)
|
||||
tag := field.Tag.Get("type")
|
||||
json := field.Tag.Get("json")
|
||||
attr[entityKey(json)] = keyTag(tag)
|
||||
if tag == "" {
|
||||
attr[entityKey(json)] = Normal
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func processJsonArr(pair []string) (string, bool) {
|
||||
value := fmt.Sprintf("JSON_CONTAINS(%v,JSON_ARRAY(", pair[0])
|
||||
s := []byte(pair[1])
|
||||
|
||||
//处理括号,遍历元素
|
||||
arr := strings.Split(string(s[1:len(s)-1]), "|")
|
||||
for _, v := range arr {
|
||||
//如果大括号里面没有元素
|
||||
if v == "" {
|
||||
return "", false
|
||||
}
|
||||
value = fmt.Sprintf("%v%v,", value, v)
|
||||
}
|
||||
|
||||
s1 := []byte(value)
|
||||
value = string(s1[0:len(s1)-1]) + "))"
|
||||
return value, true
|
||||
}
|
||||
|
||||
func processArr(str string) []string {
|
||||
s := []byte(str)
|
||||
|
||||
arr := strings.Split(string(s[1:len(s)-1]), "|")
|
||||
i := make([]string, len(arr))
|
||||
|
||||
for k, v := range i {
|
||||
i[k] = v
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
|
|
@ -3,33 +3,91 @@ package servesr
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/service/token/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/service/token/internal/pkg"
|
||||
"git.icechen.cn/monorepo/backend/pkg/orm"
|
||||
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders"
|
||||
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders/script"
|
||||
"github.com/jinzhu/copier"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
ParamCheck struct {
|
||||
kv pkg.Kv
|
||||
}
|
||||
|
||||
GrammarCheck struct {
|
||||
kv pkg.Kv
|
||||
}
|
||||
)
|
||||
|
||||
func (g GrammarCheck) Work(ctx context.Context, finishChan chan<- pkg.Finish) {
|
||||
go pkg.Watcher(ctx, finishChan)
|
||||
|
||||
}
|
||||
|
||||
func (p ParamCheck) Work(ctx context.Context, finishChan chan<- pkg.Finish) {
|
||||
|
||||
}
|
||||
|
||||
type Script struct {
|
||||
murders.UnimplementedMurdersServer
|
||||
pkg.WorkerInterFace
|
||||
queryMap *murders.QueryCondition
|
||||
scriptModel *[]model.Scripts
|
||||
queryMap *murders.QueryCondition
|
||||
scriptModel *[]model.Scripts
|
||||
ParamCheck ParamCheck
|
||||
GrammarCheck GrammarCheck
|
||||
total int64
|
||||
}
|
||||
|
||||
func (s *Script) GetScripts(ctx context.Context, queryMap *murders.QueryCondition) (*script.Scripts, error) {
|
||||
s.queryMap = queryMap
|
||||
err := pkg.Run(1*time.Second, ctx, s)
|
||||
|
||||
t := new(Tag)
|
||||
err := pkg.Run(1*time.Second, ctx, s, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
|
||||
m := make(map[int]string)
|
||||
for _, v := range *t.tagModel {
|
||||
m[v.Uuid] = v.Value
|
||||
}
|
||||
|
||||
scripts := make([]*script.Script, len(*s.scriptModel))
|
||||
|
||||
for k, v := range *s.scriptModel {
|
||||
tags := make([]string, len(v.ScriptTag))
|
||||
for k, v := range v.ScriptTag {
|
||||
if s, ok := m[v]; ok {
|
||||
tags[k] = s
|
||||
} else {
|
||||
return nil, errors.New(fmt.Sprintf("tag %v 没有对应value", k))
|
||||
}
|
||||
}
|
||||
s2 := new(script.Script)
|
||||
err = copier.Copy(s2, v)
|
||||
s2.ScriptTag = tags
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scripts[k] = s2
|
||||
}
|
||||
|
||||
s2 := new(script.Scripts)
|
||||
s2.Scripts = scripts
|
||||
s2.Total = s.total
|
||||
return s2, err
|
||||
}
|
||||
|
||||
func (s *Script) Work(ctx context.Context, finishChan chan<- pkg.Finish) {
|
||||
go pkg.Watcher(ctx, finishChan)
|
||||
db, err := orm.GetContextDB(ctx, orm.DB)
|
||||
num := int64(0)
|
||||
i := new([]model.Scripts)
|
||||
|
||||
db, err := orm.GetContextDB(ctx)
|
||||
if err != nil {
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: false,
|
||||
|
@ -37,15 +95,40 @@ func (s *Script) Work(ctx context.Context, finishChan chan<- pkg.Finish) {
|
|||
})
|
||||
}
|
||||
|
||||
i := new([]model.Scripts)
|
||||
if num := db.Find(i).RowsAffected; num < 0 {
|
||||
page, limit, query := pkg.GetParam(s.queryMap)
|
||||
queryMap, err := pkg.GenerateKv(query)
|
||||
|
||||
if err != nil {
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: false,
|
||||
Err: err,
|
||||
})
|
||||
}
|
||||
|
||||
for k, v := range queryMap {
|
||||
if v.Rule == pkg.Normal {
|
||||
db = db.Where(fmt.Sprintf("%v = ?", k), v.Value[0])
|
||||
}
|
||||
if v.Rule == pkg.JsonArray {
|
||||
db = db.Where(v.Value[0])
|
||||
}
|
||||
if v.Rule == pkg.Array {
|
||||
db = db.Where(fmt.Sprintf("%v IN ?", k), v.Value)
|
||||
}
|
||||
}
|
||||
if num = db.Find(i).RowsAffected; num < 0 {
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: false,
|
||||
Err: errors.New("RowsAffected < 0"),
|
||||
})
|
||||
}
|
||||
if limit > 0 {
|
||||
db = db.Limit(limit).Offset((page - 1) * limit)
|
||||
}
|
||||
db.Find(i)
|
||||
|
||||
s.scriptModel = i
|
||||
s.total = num
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: true,
|
||||
Err: nil,
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func RpcServer() {
|
||||
lis, err := net.Listen("tcp", ":3000")
|
||||
lis, err := net.Listen("tcp", ":3001")
|
||||
if err != nil {
|
||||
ctxLogger.Info(nil, "brahma server start up error", zap.String("error", err.Error()))
|
||||
}
|
||||
|
|
|
@ -1 +1,49 @@
|
|||
package servesr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/service/token/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/service/token/internal/pkg"
|
||||
"git.icechen.cn/monorepo/backend/pkg/orm"
|
||||
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders"
|
||||
"git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders/tag"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type Tag struct {
|
||||
murders.UnimplementedMurdersServer
|
||||
pkg.WorkerInterFace
|
||||
queryMap *murders.QueryCondition
|
||||
tagModel *[]model.Tag
|
||||
}
|
||||
|
||||
func (Tag) GetTags(ctx context.Context, q *murders.QueryCondition) (*tag.Tag, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTags not implemented")
|
||||
}
|
||||
|
||||
func (w *Tag) Work(ctx context.Context, finishChan chan<- pkg.Finish) {
|
||||
go pkg.Watcher(ctx, finishChan)
|
||||
db, err := orm.GetContextDB(ctx)
|
||||
if err != nil {
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: false,
|
||||
Err: err,
|
||||
})
|
||||
}
|
||||
|
||||
t := new([]model.Tag)
|
||||
if err = db.Where("type = ?", "script").Find(t).Error; err != nil {
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: false,
|
||||
Err: err,
|
||||
})
|
||||
}
|
||||
|
||||
w.tagModel = t
|
||||
pkg.SafeSend(finishChan, pkg.Finish{
|
||||
IsDone: true,
|
||||
Err: nil,
|
||||
})
|
||||
|
||||
}
|
||||
|
|
9
go.mod
9
go.mod
|
@ -3,6 +3,9 @@ module git.icechen.cn/monorepo/backend
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/go-playground/locales v0.13.0
|
||||
github.com/go-playground/universal-translator v0.17.0
|
||||
github.com/go-playground/validator/v10 v10.4.1
|
||||
github.com/gofiber/fiber/v2 v2.24.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/google/uuid v1.1.2
|
||||
|
@ -11,9 +14,11 @@ require (
|
|||
github.com/luizsuper/ctxLoggers v1.0.4
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/spf13/cast v1.4.1
|
||||
go.dedis.ch/protobuf v1.0.11
|
||||
go.etcd.io/etcd/client/v3 v3.5.1
|
||||
go.uber.org/zap v1.20.0
|
||||
google.golang.org/grpc v1.43.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
gorm.io/driver/mysql v1.2.3
|
||||
gorm.io/gorm v1.22.4
|
||||
)
|
||||
|
@ -24,9 +29,6 @@ require (
|
|||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/gin-gonic/gin v1.7.7 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.10.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
|
@ -52,6 +54,5 @@ require (
|
|||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
|
3
go.sum
3
go.sum
|
@ -384,8 +384,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
|||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
|
|
@ -12,11 +12,14 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func GetContextDB(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
|
||||
if err := db.Use(&TracePlugin{}); err != nil {
|
||||
return nil, err
|
||||
func init() {
|
||||
if err := DB.Use(&TracePlugin{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return db.WithContext(ctx), nil
|
||||
}
|
||||
|
||||
func GetContextDB(ctx context.Context) (*gorm.DB, error) {
|
||||
return DB.WithContext(ctx), nil
|
||||
}
|
||||
|
||||
type SQL struct {
|
||||
|
|
|
@ -201,6 +201,7 @@ type Scripts struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Scripts []*Script `protobuf:"bytes,1,rep,name=scripts,proto3" json:"scripts,omitempty"`
|
||||
Total int64 `protobuf:"zigzag64,2,opt,name=total,proto3" json:"total,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Scripts) Reset() {
|
||||
|
@ -242,6 +243,13 @@ func (x *Scripts) GetScripts() []*Script {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *Scripts) GetTotal() int64 {
|
||||
if x != nil {
|
||||
return x.Total
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_script_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_script_proto_rawDesc = []byte{
|
||||
|
@ -288,15 +296,17 @@ var file_script_proto_rawDesc = []byte{
|
|||
0x52, 0x12, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x53,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x69, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x03, 0x71, 0x69, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x69, 0x73, 0x5f, 0x64, 0x65, 0x6c,
|
||||
0x18, 0x11, 0x20, 0x01, 0x28, 0x12, 0x52, 0x05, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x22, 0x33, 0x0a,
|
||||
0x18, 0x11, 0x20, 0x01, 0x28, 0x12, 0x52, 0x05, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x22, 0x49, 0x0a,
|
||||
0x07, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x07, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x2e, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70,
|
||||
0x74, 0x73, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x2e, 0x69, 0x63, 0x65, 0x63, 0x68, 0x65,
|
||||
0x6e, 0x2e, 0x63, 0x6e, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f, 0x72, 0x65, 0x70, 0x6f, 0x2f, 0x62, 0x61,
|
||||
0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f,
|
||||
0x62, 0x72, 0x61, 0x68, 0x6d, 0x61, 0x2f, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x73,
|
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x12, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x2e,
|
||||
0x69, 0x63, 0x65, 0x63, 0x68, 0x65, 0x6e, 0x2e, 0x63, 0x6e, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f, 0x72,
|
||||
0x65, 0x70, 0x6f, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x62, 0x72, 0x61, 0x68, 0x6d, 0x61, 0x2f, 0x6d, 0x75, 0x72,
|
||||
0x64, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -24,4 +24,5 @@ message Script {
|
|||
|
||||
message Scripts {
|
||||
repeated Script scripts = 1;
|
||||
sint64 total = 2;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package murders
|
|||
|
||||
import (
|
||||
script "git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders/script"
|
||||
tag "git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders/tag"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
|
@ -26,9 +27,9 @@ type QueryCondition struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Page *int64 `protobuf:"zigzag64,1,opt,name=page,proto3,oneof" json:"page,omitempty"`
|
||||
Size *int64 `protobuf:"zigzag64,2,opt,name=size,proto3,oneof" json:"size,omitempty"`
|
||||
QueryMap map[string]string `protobuf:"bytes,3,rep,name=query_map,json=queryMap,proto3" json:"query_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Page *int64 `protobuf:"zigzag64,1,opt,name=page,proto3,oneof" json:"page,omitempty"`
|
||||
Size *int64 `protobuf:"zigzag64,2,opt,name=size,proto3,oneof" json:"size,omitempty"`
|
||||
Query *string `protobuf:"bytes,3,opt,name=query,proto3,oneof" json:"query,omitempty"`
|
||||
}
|
||||
|
||||
func (x *QueryCondition) Reset() {
|
||||
|
@ -77,11 +78,11 @@ func (x *QueryCondition) GetSize() int64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (x *QueryCondition) GetQueryMap() map[string]string {
|
||||
if x != nil {
|
||||
return x.QueryMap
|
||||
func (x *QueryCondition) GetQuery() string {
|
||||
if x != nil && x.Query != nil {
|
||||
return *x.Query
|
||||
}
|
||||
return nil
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_service_proto protoreflect.FileDescriptor
|
||||
|
@ -89,29 +90,27 @@ var File_service_proto protoreflect.FileDescriptor
|
|||
var file_service_proto_rawDesc = []byte{
|
||||
0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x06, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72, 0x1a, 0x13, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2f,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd4, 0x01, 0x0a,
|
||||
0x0e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12,
|
||||
0x17, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x12, 0x48, 0x00, 0x52,
|
||||
0x04, 0x70, 0x61, 0x67, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x12, 0x48, 0x01, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x88, 0x01,
|
||||
0x01, 0x12, 0x41, 0x0a, 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x03,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x51, 0x75,
|
||||
0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65,
|
||||
0x72, 0x79, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x71, 0x75, 0x65, 0x72,
|
||||
0x79, 0x4d, 0x61, 0x70, 0x1a, 0x3b, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x61, 0x70,
|
||||
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
|
||||
0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x32, 0x42, 0x0a, 0x07, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72, 0x73, 0x12, 0x37,
|
||||
0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x6d,
|
||||
0x75, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x0f, 0x2e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x63,
|
||||
0x72, 0x69, 0x70, 0x74, 0x73, 0x22, 0x00, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x2e, 0x69,
|
||||
0x63, 0x65, 0x63, 0x68, 0x65, 0x6e, 0x2e, 0x63, 0x6e, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f, 0x72, 0x65,
|
||||
0x70, 0x6f, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x62, 0x72, 0x61, 0x68, 0x6d, 0x61, 0x2f, 0x6d, 0x75, 0x72, 0x64,
|
||||
0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x74, 0x61,
|
||||
0x67, 0x2f, 0x74, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x79, 0x0a, 0x0e, 0x51,
|
||||
0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a,
|
||||
0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x12, 0x48, 0x00, 0x52, 0x04, 0x70,
|
||||
0x61, 0x67, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x12, 0x48, 0x01, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x88, 0x01, 0x01, 0x12,
|
||||
0x19, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02,
|
||||
0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x70,
|
||||
0x61, 0x67, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x42, 0x08, 0x0a, 0x06,
|
||||
0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x32, 0x71, 0x0a, 0x07, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72,
|
||||
0x73, 0x12, 0x37, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x12,
|
||||
0x16, 0x2e, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f,
|
||||
0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x0f, 0x2e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x2e, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x22, 0x00, 0x12, 0x2d, 0x0a, 0x07, 0x47, 0x65,
|
||||
0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x6d, 0x75, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x51,
|
||||
0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x08, 0x2e,
|
||||
0x74, 0x61, 0x67, 0x2e, 0x54, 0x61, 0x67, 0x22, 0x00, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74,
|
||||
0x2e, 0x69, 0x63, 0x65, 0x63, 0x68, 0x65, 0x6e, 0x2e, 0x63, 0x6e, 0x2f, 0x6d, 0x6f, 0x6e, 0x6f,
|
||||
0x72, 0x65, 0x70, 0x6f, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x70, 0x6b, 0x67,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x62, 0x72, 0x61, 0x68, 0x6d, 0x61, 0x2f, 0x6d, 0x75,
|
||||
0x72, 0x64, 0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -126,21 +125,22 @@ func file_service_proto_rawDescGZIP() []byte {
|
|||
return file_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_service_proto_goTypes = []interface{}{
|
||||
(*QueryCondition)(nil), // 0: murder.QueryCondition
|
||||
nil, // 1: murder.QueryCondition.QueryMapEntry
|
||||
(*script.Scripts)(nil), // 2: script.Scripts
|
||||
(*script.Scripts)(nil), // 1: script.Scripts
|
||||
(*tag.Tag)(nil), // 2: tag.Tag
|
||||
}
|
||||
var file_service_proto_depIdxs = []int32{
|
||||
1, // 0: murder.QueryCondition.query_map:type_name -> murder.QueryCondition.QueryMapEntry
|
||||
0, // 1: murder.murders.GetScripts:input_type -> murder.QueryCondition
|
||||
2, // 2: murder.murders.GetScripts:output_type -> script.Scripts
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
0, // 0: murder.murders.GetScripts:input_type -> murder.QueryCondition
|
||||
0, // 1: murder.murders.GetTags:input_type -> murder.QueryCondition
|
||||
1, // 2: murder.murders.GetScripts:output_type -> script.Scripts
|
||||
2, // 3: murder.murders.GetTags:output_type -> tag.Tag
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_service_proto_init() }
|
||||
|
@ -169,7 +169,7 @@ func file_service_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_service_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
syntax = "proto3";
|
||||
import "script/script.proto";
|
||||
import "tag/tag.proto";
|
||||
option go_package = "git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders";
|
||||
package murder;
|
||||
|
||||
service murders{
|
||||
rpc GetScripts(QueryCondition) returns(script.Scripts){}
|
||||
rpc GetTags(QueryCondition) returns(tag.Tag){}
|
||||
}
|
||||
|
||||
message QueryCondition {
|
||||
optional sint64 page = 1;
|
||||
optional sint64 size = 2;
|
||||
map<string, string> query_map = 3;
|
||||
optional string query =3;
|
||||
}
|
|
@ -9,6 +9,7 @@ package murders
|
|||
import (
|
||||
context "context"
|
||||
script "git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders/script"
|
||||
tag "git.icechen.cn/monorepo/backend/pkg/proto/brahma/murders/tag"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
@ -24,6 +25,7 @@ const _ = grpc.SupportPackageIsVersion7
|
|||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MurdersClient interface {
|
||||
GetScripts(ctx context.Context, in *QueryCondition, opts ...grpc.CallOption) (*script.Scripts, error)
|
||||
GetTags(ctx context.Context, in *QueryCondition, opts ...grpc.CallOption) (*tag.Tag, error)
|
||||
}
|
||||
|
||||
type murdersClient struct {
|
||||
|
@ -43,11 +45,21 @@ func (c *murdersClient) GetScripts(ctx context.Context, in *QueryCondition, opts
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *murdersClient) GetTags(ctx context.Context, in *QueryCondition, opts ...grpc.CallOption) (*tag.Tag, error) {
|
||||
out := new(tag.Tag)
|
||||
err := c.cc.Invoke(ctx, "/murder.murders/GetTags", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MurdersServer is the server API for Murders service.
|
||||
// All implementations must embed UnimplementedMurdersServer
|
||||
// for forward compatibility
|
||||
type MurdersServer interface {
|
||||
GetScripts(context.Context, *QueryCondition) (*script.Scripts, error)
|
||||
GetTags(context.Context, *QueryCondition) (*tag.Tag, error)
|
||||
mustEmbedUnimplementedMurdersServer()
|
||||
}
|
||||
|
||||
|
@ -58,6 +70,9 @@ type UnimplementedMurdersServer struct {
|
|||
func (UnimplementedMurdersServer) GetScripts(context.Context, *QueryCondition) (*script.Scripts, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetScripts not implemented")
|
||||
}
|
||||
func (UnimplementedMurdersServer) GetTags(context.Context, *QueryCondition) (*tag.Tag, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTags not implemented")
|
||||
}
|
||||
func (UnimplementedMurdersServer) mustEmbedUnimplementedMurdersServer() {}
|
||||
|
||||
// UnsafeMurdersServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
@ -89,6 +104,24 @@ func _Murders_GetScripts_Handler(srv interface{}, ctx context.Context, dec func(
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Murders_GetTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryCondition)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MurdersServer).GetTags(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/murder.murders/GetTags",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MurdersServer).GetTags(ctx, req.(*QueryCondition))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Murders_ServiceDesc is the grpc.ServiceDesc for Murders service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
@ -100,6 +133,10 @@ var Murders_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "GetScripts",
|
||||
Handler: _Murders_GetScripts_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetTags",
|
||||
Handler: _Murders_GetTags_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "service.proto",
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/pkg/env"
|
||||
_ "git.icechen.cn/monorepo/backend/pkg/orm"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"go.uber.org/zap"
|
||||
|
@ -31,7 +32,7 @@ func Interceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInf
|
|||
if err != nil {
|
||||
ctxLogger.Debug(ctx, serverName, zap.String("gRPC method", fmt.Sprintf(" %s", info.FullMethod)), zap.Float64("cost_time", costSeconds), zap.String("errorReason", err.Error()))
|
||||
} else {
|
||||
ctxLogger.Debug(ctx, serverName, zap.String("gRPC method", fmt.Sprintf(" %s, %v", info.FullMethod, resp)), zap.Float64("cost_time", costSeconds), zap.Any("resp", resp))
|
||||
//ctxLogger.Debug(ctx, serverName, zap.String("gRPC method", fmt.Sprintf(" %s, %v", info.FullMethod, resp)), zap.Float64("cost_time", costSeconds), zap.Any("resp", resp))
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue