generated from pkg/go-template
feat: murder项目整体迁移
parent
7398e7ab9e
commit
c7df390cec
|
@ -0,0 +1,103 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
clientV3 "go.etcd.io/etcd/client/v3"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
DsnPre = "dsn"
|
||||
Local = "local"
|
||||
Env = "env"
|
||||
Configs = "config"
|
||||
Etcd = "etcd"
|
||||
EtcdEnd = "endpoints"
|
||||
EtcdEndDefault = "127.0.0.1:2379"
|
||||
Port
|
||||
PortDefault = "8080"
|
||||
)
|
||||
|
||||
const (
|
||||
TestDB = "taihe"
|
||||
)
|
||||
|
||||
type Config map[string]string
|
||||
|
||||
var (
|
||||
client *clientV3.Client
|
||||
configMap = make(Config, 0)
|
||||
config clientV3.Config
|
||||
err error
|
||||
)
|
||||
|
||||
func GetConfig() {
|
||||
env := GetEnvDefault(Env, Local)
|
||||
host := GetEnvDefault(Configs, Etcd)
|
||||
switch host {
|
||||
case Etcd:
|
||||
etcdReader(env)
|
||||
}
|
||||
}
|
||||
|
||||
func etcdReader(env string) {
|
||||
kv := clientV3.NewKV(client)
|
||||
defer client.Close()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*3)
|
||||
defer cancel()
|
||||
if getResp, err := kv.Get(ctx, fmt.Sprintf("/config/%v/", env), clientV3.WithPrefix()); err == nil {
|
||||
for _, v := range getResp.Kvs {
|
||||
configMap[string(v.Key)] = string(v.Value)
|
||||
}
|
||||
} else {
|
||||
ctxLogger.Error(nil, error_process.EtcReadError, zap.String("", err.Error()))
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
func GetConfigMap() Config {
|
||||
return configMap
|
||||
}
|
||||
|
||||
func GetConfigKey(key string) string {
|
||||
configs := GetEnvDefault(Configs, "")
|
||||
env := GetEnvDefault(Env, "")
|
||||
switch configs {
|
||||
case Etcd:
|
||||
fmt.Printf("/config/%v/%v", env, key)
|
||||
return fmt.Sprintf("/config/%v/%v", env, key)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
connect()
|
||||
}
|
||||
|
||||
func connect() {
|
||||
envDefault := GetEnvDefault(EtcdEnd, EtcdEndDefault)
|
||||
ends := strings.Split(envDefault, ",")
|
||||
config = clientV3.Config{
|
||||
Endpoints: ends,
|
||||
DialTimeout: 5 * time.Second,
|
||||
}
|
||||
if client, err = clientV3.New(config); err != nil {
|
||||
ctxLogger.FError(nil, error_process.EtcConnError, zap.String("", err.Error()))
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
func GetEnvDefault(key, defVal string) string {
|
||||
val, ex := os.LookupEnv(key)
|
||||
if !ex {
|
||||
os.Setenv(key, defVal)
|
||||
return defVal
|
||||
}
|
||||
return val
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package error_process
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
dbNotFoundErr = errors.New("db初始化失败,未从map中获取相应db")
|
||||
numNotMatchErr = errors.New("数量匹配失败")
|
||||
emptyValueErr = errors.New("空值错误")
|
||||
extraValueErr = errors.New("额外值错误")
|
||||
)
|
||||
|
||||
const (
|
||||
// BodyParserErr body 解析错误
|
||||
BodyParserErr = "BodyParserErr"
|
||||
ServiceErr = "调用service时错误"
|
||||
EtcReadError = "etcdReaderErr"
|
||||
EtcConnError = "etcConnectError"
|
||||
PanicError = "panicError"
|
||||
GormError = "gormErr"
|
||||
NoPointError = "不是指针类型"
|
||||
NilPointError = "解析失败"
|
||||
IllegalValueError = "非法值错误"
|
||||
GrammerError = "语法错误"
|
||||
)
|
||||
|
||||
func DbNotFoundErr(dbKey string) error {
|
||||
return errors.Wrap(dbNotFoundErr, fmt.Sprintf("根据dbKey:%v没有找到db记录", dbKey))
|
||||
}
|
||||
func UpdateErr(body interface{}, condition interface{}) error {
|
||||
return errors.Wrap(numNotMatchErr, fmt.Sprintf("update操作失败,条件为:%v,updateBody:%v", condition, body))
|
||||
}
|
||||
func CreateErr(err error, body interface{}) error {
|
||||
return errors.Wrap(err, fmt.Sprintf("新增失败,createBody:%v", body))
|
||||
}
|
||||
func GetErr(err error, condition interface{}) error {
|
||||
return errors.Wrap(err, fmt.Sprintf("查询失败,queryMap:%v", condition))
|
||||
}
|
||||
func RecordNotMatchWithUniqueErr(condition interface{}, expected, actual int) error {
|
||||
return errors.WithMessage(numNotMatchErr, fmt.Sprintf("查询条件:%v,期望数量:%v,实际数量:%v", condition, expected, actual))
|
||||
}
|
||||
func EmptyValueErr(key string) error {
|
||||
return errors.WithMessage(emptyValueErr, fmt.Sprintf("空值key:%v", key))
|
||||
}
|
||||
func CommonErr(err error) error {
|
||||
return errors.Wrap(err, "")
|
||||
}
|
||||
func ExtraValueErr(key string) error {
|
||||
return errors.WithMessage(extraValueErr, fmt.Sprintf("key:%v只能为空值", key))
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package gorm_helper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/config"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MysqlMapType map[string]*gorm.DB
|
||||
|
||||
var mysqlMap = make(MysqlMapType, 0)
|
||||
|
||||
func GormMap(dsnPre string) error {
|
||||
dsn := fmt.Sprintf("%v/%v?charset=utf8mb4&parseTime=True&loc=Local", dsnPre, config.TestDB)
|
||||
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = db.Use(&TracePlugin{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mysqlMap[config.TestDB] = db
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetMap() MysqlMapType {
|
||||
return mysqlMap
|
||||
}
|
||||
|
||||
func GetContextDB(ctx *fiber.Ctx, name ...string) (*gorm.DB, error) {
|
||||
//自定义插件接收ctx 里面的 自定义context,打印日志
|
||||
_ctx := ctx.UserContext()
|
||||
db := GetMap()
|
||||
dbName := config.TestDB
|
||||
if len(name) != 0 {
|
||||
dbName = name[0]
|
||||
}
|
||||
if v, ok := db[dbName]; ok {
|
||||
return v.WithContext(_ctx), nil
|
||||
}
|
||||
return nil, error_process.DbNotFoundErr(dbName)
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package gorm_helper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"github.com/spf13/cast"
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SQL struct {
|
||||
Timestamp string `json:"timestamp"` // 时间,格式:2006-01-02 15:04:05
|
||||
Stack string `json:"stack"` // 文件地址和行号
|
||||
SQL string `json:"sql"` // SQL 语句
|
||||
Rows int64 `json:"rows_affected"` // 影响行数
|
||||
CostSeconds float64 `json:"cost_seconds"` // 执行时长(单位秒)
|
||||
}
|
||||
|
||||
const (
|
||||
callBackBeforeName = "core:before"
|
||||
callBackAfterName = "core:after"
|
||||
startTime = "_start_time"
|
||||
)
|
||||
|
||||
type TracePlugin struct{}
|
||||
|
||||
func (op *TracePlugin) Name() string {
|
||||
return "tracePlugin"
|
||||
}
|
||||
|
||||
func (op *TracePlugin) Initialize(db *gorm.DB) (err error) {
|
||||
// 开始前
|
||||
_ = db.Callback().Create().Before("gorm:before_create").Register(callBackBeforeName, before)
|
||||
_ = db.Callback().Query().Before("gorm:query").Register(callBackBeforeName, before)
|
||||
_ = db.Callback().Delete().Before("gorm:before_delete").Register(callBackBeforeName, before)
|
||||
_ = db.Callback().Update().Before("gorm:setup_reflect_value").Register(callBackBeforeName, before)
|
||||
_ = db.Callback().Row().Before("gorm:row").Register(callBackBeforeName, before)
|
||||
_ = db.Callback().Raw().Before("gorm:raw").Register(callBackBeforeName, before)
|
||||
|
||||
// 结束后
|
||||
_ = db.Callback().Create().After("gorm:after_create").Register(callBackAfterName, after)
|
||||
_ = db.Callback().Query().After("gorm:after_query").Register(callBackAfterName, after)
|
||||
_ = db.Callback().Delete().After("gorm:after_delete").Register(callBackAfterName, after)
|
||||
_ = db.Callback().Update().After("gorm:after_update").Register(callBackAfterName, after)
|
||||
_ = db.Callback().Row().After("gorm:row").Register(callBackAfterName, after)
|
||||
_ = db.Callback().Raw().After("gorm:raw").Register(callBackAfterName, after)
|
||||
return
|
||||
}
|
||||
|
||||
//记录db开始时间
|
||||
func before(db *gorm.DB) {
|
||||
db.InstanceSet(startTime, time.Now())
|
||||
return
|
||||
}
|
||||
|
||||
func after(db *gorm.DB) {
|
||||
_ctx := db.Statement.Context
|
||||
ctx, ok := _ctx.(context.Context)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
defer ctx.Done()
|
||||
_ts, isExist := db.InstanceGet(startTime)
|
||||
if !isExist {
|
||||
return
|
||||
}
|
||||
ts, ok := _ts.(time.Time)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
sql := db.Dialector.Explain(db.Statement.SQL.String(), db.Statement.Vars...)
|
||||
sqlInfo := new(SQL)
|
||||
sqlInfo.Timestamp = util.CSTLayoutString()
|
||||
sqlInfo.SQL = sql
|
||||
sqlInfo.Stack = utils.FileWithLineNum()
|
||||
sqlInfo.Rows = db.Statement.RowsAffected
|
||||
sqlInfo.CostSeconds = time.Since(ts).Seconds()
|
||||
|
||||
ctxLogger.FInfo(nil, "sql", zap.Any("info", sqlInfo), zap.String("trace_id", cast.ToString(ctx.Value(fiber.HeaderXRequestID))))
|
||||
|
||||
return
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/service"
|
||||
bgm "git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
CategoryReq struct {
|
||||
Category *model.Category `json:"category" `
|
||||
}
|
||||
CategoriesTagReq struct {
|
||||
Relation *model.CategoriesTagDto `json:"relation" `
|
||||
}
|
||||
)
|
||||
|
||||
func GetCategoryH(ctx *fiber.Ctx) error {
|
||||
page := ctx.Query("page", "1")
|
||||
limit := ctx.Query("size", "10")
|
||||
iPage, _ := strconv.Atoi(page)
|
||||
iLimit, _ := strconv.Atoi(limit)
|
||||
s := ctx.Query("query", "")
|
||||
queryMap := bgm.GetQueryMap(s)
|
||||
m, num, err := service.GetCategory(iPage, iLimit, queryMap, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(&Data{
|
||||
Elements: m,
|
||||
Total: num,
|
||||
}))
|
||||
}
|
||||
|
||||
//CreateCategoryH 创建类别
|
||||
func CreateCategoryH(ctx *fiber.Ctx) error {
|
||||
m := new(CategoryReq)
|
||||
if err := createCategoryParamCheck(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.CreateCategory(m.Category, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
func UpdateCategoryH(ctx *fiber.Ctx) error {
|
||||
m := new(CategoryReq)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.UpdateCategory(m.Category, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
func DeleteCategoryH(ctx *fiber.Ctx) error {
|
||||
m := new(CategoryReq)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.DeleteCategory(m.Category, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
// CreateTagForCategory 为Category 新增tag
|
||||
func CreateTagForCategory(ctx *fiber.Ctx) error {
|
||||
m := new(CategoriesTagReq)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.CreateTagForCategory(m.Relation, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
// DeleteTagForCategory 为Category 删除tag
|
||||
func DeleteTagForCategory(ctx *fiber.Ctx) error {
|
||||
m := new(CategoriesTagReq)
|
||||
if err := ctx.BodyParser(m); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.DeleteTagForCategory(m.Relation, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type pluginFunc func(interface{}) error
|
||||
|
||||
func checkParam(body interface{}, ctx *fiber.Ctx, plugins ...pluginFunc) error {
|
||||
//第一次执行解析body,并且调用插件方法
|
||||
if ctx != nil {
|
||||
err := ctx.BodyParser(body)
|
||||
if err != nil {
|
||||
return error_process.CommonErr(err)
|
||||
}
|
||||
for _, plugin := range plugins {
|
||||
if err = plugin(body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
//step1 校验是否是指针
|
||||
typ := reflect.TypeOf(body)
|
||||
val := reflect.ValueOf(body)
|
||||
if val.Kind().String() != reflect.Ptr.String() {
|
||||
return errors.New(error_process.NoPointError)
|
||||
}
|
||||
if val.IsNil() {
|
||||
return errors.New(error_process.NilPointError)
|
||||
}
|
||||
num := val.Elem().NumField()
|
||||
for i := 0; i < num; i++ {
|
||||
kind := val.Elem().Field(i).Kind().String()
|
||||
switch kind {
|
||||
case reflect.Ptr.String():
|
||||
//显示指定某些指针跳过校验
|
||||
if tag := typ.Elem().Field(i).Tag.Get("valid"); tag == "omitempty" {
|
||||
continue
|
||||
}
|
||||
//递归调用
|
||||
if err := checkParam(val.Elem().Field(i).Interface(), nil); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
//非空值验证
|
||||
if tag := typ.Elem().Field(i).Tag.Get("valid"); tag == "no_empty" {
|
||||
switch kind {
|
||||
case reflect.Ptr.String():
|
||||
if val.Elem().Field(i).IsNil() == true {
|
||||
return error_process.EmptyValueErr(typ.Elem().Field(i).Tag.Get("json"))
|
||||
}
|
||||
case reflect.Slice.String():
|
||||
if val.Elem().Field(i).IsNil() == true || val.Elem().Field(i).Len() == 0 {
|
||||
return error_process.EmptyValueErr(typ.Elem().Field(i).Tag.Get("json"))
|
||||
}
|
||||
default:
|
||||
if val.Elem().Field(i).IsZero() {
|
||||
return error_process.EmptyValueErr(typ.Elem().Field(i).Tag.Get("json"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//指定制验证
|
||||
if values := typ.Elem().Field(i).Tag.Get("value"); values != "" {
|
||||
eles := make([]string, 0)
|
||||
if eles = strings.Split(values, "|"); len(eles) == 0 {
|
||||
continue
|
||||
}
|
||||
switch kind {
|
||||
case reflect.Int.String():
|
||||
for _, v := range eles {
|
||||
if b := val.Elem().Field(i).Int(); b == cast.ToInt64(v) {
|
||||
//匹配到值定制跳出此次tag处理方法
|
||||
goto LOOP
|
||||
}
|
||||
}
|
||||
return errors.New(error_process.IllegalValueError)
|
||||
default:
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
}
|
||||
LOOP:
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//tag uuid 覆盖写
|
||||
func tagUuidPlugin(body interface{}) error {
|
||||
if req, ok := body.(*TagReq); ok {
|
||||
if req.Tag == nil {
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
//if req.Tag.Uuid == "" {
|
||||
// req.Tag.Uuid = xid.New().String()
|
||||
//}
|
||||
return nil
|
||||
}
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
|
||||
//category uuid 覆盖写
|
||||
func categoryUuidPlugin(body interface{}) error {
|
||||
if req, ok := body.(*CategoryReq); ok {
|
||||
if req.Category == nil {
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
if req.Category.Uuid == "" {
|
||||
req.Category.Uuid = uuid.New().String()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
|
||||
//script uuid 覆盖写
|
||||
func scriptUuidPlugin(body interface{}) error {
|
||||
if req, ok := body.(*model.Scripts); ok {
|
||||
if req == nil {
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
if req.Uuid == "" {
|
||||
req.Uuid = uuid.New().String()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New(error_process.BodyParserErr)
|
||||
}
|
||||
|
||||
func createTagParamCheck(body interface{}, ctx *fiber.Ctx) error {
|
||||
return checkParam(body, ctx, tagUuidPlugin)
|
||||
}
|
||||
|
||||
func createCategoryParamCheck(body interface{}, ctx *fiber.Ctx) error {
|
||||
return checkParam(body, ctx, categoryUuidPlugin)
|
||||
}
|
||||
|
||||
func createScriptParamCheck(body interface{}, ctx *fiber.Ctx) error {
|
||||
return checkParam(body, ctx, scriptUuidPlugin)
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package handler
|
||||
|
||||
const (
|
||||
ResponseCodeSuccess = 0
|
||||
ResponseCodeFail = -1
|
||||
ResponseSuccess = "success"
|
||||
ResponseFail = "fail"
|
||||
)
|
||||
|
||||
type (
|
||||
Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data *Data `json:"data,omitempty"`
|
||||
}
|
||||
Data struct {
|
||||
Elements interface{} `json:"elements"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
)
|
||||
|
||||
func fail(data *Data) Response {
|
||||
return Response{
|
||||
Code: ResponseCodeFail,
|
||||
Message: ResponseFail,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func success(data *Data) Response {
|
||||
return Response{
|
||||
Code: ResponseCodeSuccess,
|
||||
Message: ResponseSuccess,
|
||||
Data: data,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/service"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetScriptsH(ctx *fiber.Ctx) error {
|
||||
page := ctx.Query("page", "1")
|
||||
limit := ctx.Query("size", "10")
|
||||
iPage, _ := strconv.Atoi(page)
|
||||
iLimit, _ := strconv.Atoi(limit)
|
||||
s := ctx.Query("query", "")
|
||||
query := model.GetQuery{Query: s}
|
||||
processMap, err := query.ProcessMap()
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.GrammerError, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
m, num, err := service.GetScripts(iPage, iLimit, processMap, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(&Data{
|
||||
Elements: m,
|
||||
Total: num,
|
||||
}))
|
||||
}
|
||||
|
||||
func UpdateScriptsH(ctx *fiber.Ctx) error {
|
||||
m := new(model.Scripts)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.UpdateScripts(m, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
func CreateScriptsH(ctx *fiber.Ctx) error {
|
||||
m := new(model.Scripts)
|
||||
if err := createScriptParamCheck(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.CreateScripts(m, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
func DeleteScriptsH(ctx *fiber.Ctx) error {
|
||||
m := new(model.Scripts)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.DeleteScripts(m, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/service"
|
||||
bgm "git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
TagReq struct {
|
||||
Tag *model.Tag `json:"tag" `
|
||||
}
|
||||
TagCategoriesReq struct {
|
||||
Relation *model.TagCategoriesDto `json:"relation" `
|
||||
}
|
||||
)
|
||||
|
||||
func CreateTagH(ctx *fiber.Ctx) error {
|
||||
m := new(TagReq)
|
||||
if err := createTagParamCheck(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.CreateTag(m.Tag, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
func UpdateTagH(ctx *fiber.Ctx) error {
|
||||
m := new(TagReq)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.UpdateTag(m.Tag, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
func GetTagH(ctx *fiber.Ctx) error {
|
||||
page := ctx.Query("page", "1")
|
||||
limit := ctx.Query("size", "10")
|
||||
iPage, _ := strconv.Atoi(page)
|
||||
iLimit, _ := strconv.Atoi(limit)
|
||||
s := ctx.Query("query", "")
|
||||
queryMap := bgm.GetQueryMap(s)
|
||||
m, num, err := service.GetTag(iPage, iLimit, ctx, queryMap)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(&Data{
|
||||
Elements: m,
|
||||
Total: num,
|
||||
}))
|
||||
}
|
||||
|
||||
func DeleteTagH(ctx *fiber.Ctx) error {
|
||||
m := new(TagReq)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.DeleteTag(m.Tag, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
// CreateCategoryForTag 为Tag 新增分组
|
||||
func CreateCategoryForTag(ctx *fiber.Ctx) error {
|
||||
m := new(TagCategoriesReq)
|
||||
if err := checkParam(m, ctx); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.CreateCategoryForTag(m.Relation, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
||||
|
||||
// DeleteCategoryForTag 为Tag 删除分组
|
||||
func DeleteCategoryForTag(ctx *fiber.Ctx) error {
|
||||
m := new(TagCategoriesReq)
|
||||
if err := ctx.BodyParser(m); err != nil {
|
||||
ctxLogger.FError(ctx, error_process.BodyParserErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
err := service.DelCategoryForTag(m.Relation, ctx)
|
||||
if err != nil {
|
||||
ctxLogger.FError(ctx, error_process.ServiceErr, zap.String("", fmt.Sprintf("%+v", err)))
|
||||
return ctx.JSON(fail(nil))
|
||||
}
|
||||
return ctx.JSON(success(nil))
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
bgm "git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
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"`
|
||||
}
|
||||
)
|
||||
|
||||
func (m *Category) TableName() string {
|
||||
return "category"
|
||||
}
|
||||
|
||||
func GetCategoryM(page, size int, query bgm.QueryMap, db *gorm.DB) ([]Category, int64, error) {
|
||||
i := new([]Category)
|
||||
num := int64(0)
|
||||
for k, v := range query {
|
||||
db = db.Where(fmt.Sprintf("%v = ?", k), v)
|
||||
}
|
||||
if num = db.Find(i).RowsAffected; num <= 0 {
|
||||
return nil, 0, error_process.GetErr(errors.New(error_process.GormError), query)
|
||||
}
|
||||
if size > 0 {
|
||||
db = db.Limit(size).Offset((page - 1) * size)
|
||||
}
|
||||
if err := db.Preload("Tags").Find(i).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return *i, num, nil
|
||||
}
|
||||
|
||||
func CreateCategoryM(category *Category, db *gorm.DB) error {
|
||||
if err := db.Create(category).Error; err != nil {
|
||||
return error_process.CreateErr(err, category)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateCategoryM(category *Category, db *gorm.DB) error {
|
||||
if num := db.Model(Category{}).Where("uuid = ?", category.Uuid).Updates(*category).RowsAffected; num != 1 {
|
||||
return error_process.UpdateErr(category, category.Uuid)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateTagForCategoryM(cid string, tIds []string, db *gorm.DB) error {
|
||||
c := new(Category)
|
||||
//step1 getCategory
|
||||
if err := db.Where(&Category{
|
||||
Uuid: cid,
|
||||
}).Find(c).Error; err != nil {
|
||||
return error_process.GetErr(err, c)
|
||||
}
|
||||
//step2 get tags and check num is expected
|
||||
var ts []Tag
|
||||
if num := db.Where(tIds).Find(&ts).RowsAffected; num != cast.ToInt64(len(tIds)) {
|
||||
return error_process.RecordNotMatchWithUniqueErr(tIds, len(tIds), cast.ToInt(num))
|
||||
}
|
||||
//step3 add association
|
||||
if err := db.Model(c).Association("Tags").Append(ts); err != nil {
|
||||
return error_process.CommonErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DelTagForCategoryM(cid string, tIds []string, db *gorm.DB) error {
|
||||
c := new(Category)
|
||||
//step1 getCategory
|
||||
if err := db.Where(&Category{
|
||||
Uuid: cid,
|
||||
}).Find(c).Error; err != nil {
|
||||
return error_process.GetErr(err, c)
|
||||
}
|
||||
//step2 get tags and check num is expected
|
||||
var ts []Tag
|
||||
if num := db.Where(tIds).Find(&ts).RowsAffected; num != cast.ToInt64(len(tIds)) {
|
||||
return error_process.RecordNotMatchWithUniqueErr(tIds, len(tIds), cast.ToInt(num))
|
||||
}
|
||||
//step3 add association
|
||||
if err := db.Model(c).Association("Tags").Delete(ts); err != nil {
|
||||
return error_process.CommonErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
jsonArray = "jsonArr"
|
||||
normal = "normal"
|
||||
)
|
||||
|
||||
type (
|
||||
//区分query中不同规则
|
||||
ruleType struct {
|
||||
rule string
|
||||
value string
|
||||
}
|
||||
QueryMap map[string]ruleType
|
||||
)
|
||||
|
||||
type GetSqlMapFromQuery interface {
|
||||
// ProcessMap 生成queryMap
|
||||
ProcessMap() (QueryMap, error)
|
||||
}
|
||||
|
||||
type GetQuery struct {
|
||||
Query string
|
||||
}
|
||||
|
||||
type ScriptsDto struct {
|
||||
ScriptName string `json:"script_name" gorm:"column:script_name"`
|
||||
ScriptIntro string `json:"script_intro" gorm:"column:script_intro"`
|
||||
ScriptTag strs `json:"script_tag" gorm:"column:script_tag"`
|
||||
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"`
|
||||
ScriptTextContext string `json:"script_text_context" gorm:"column:script_text_context"`
|
||||
ScriptPlotScore float64 `json:"script_plot_score" gorm:"column:script_plot_score"`
|
||||
ScriptImageContent strs `json:"script_image_content" gorm:"column:script_image_content"`
|
||||
ScriptMalePlayer int `json:"script_male_player" gorm:"column:script_male_player"`
|
||||
ScriptFemalePlayer int `json:"script_female_player" gorm:"column:script_female_player"`
|
||||
ScriptDifficultDegree string `json:"script_difficult_degree" gorm:"column:script_difficult_degree"`
|
||||
ScriptPlayerLimit int `json:"script_player_limit" gorm:"column:script_player_limit"`
|
||||
Uuid string `json:"uuid" gorm:"column:uuid" valid:"no_empty"`
|
||||
ScriptComplexScore float64 `json:"script_complex_score" gorm:"column:script_complex_score"`
|
||||
}
|
||||
|
||||
//检查语法
|
||||
func checkGrammar(value string) bool {
|
||||
//如果 = 左右两侧 不是完整的key、value返回错误
|
||||
var pairs []string
|
||||
if pairs = strings.Split(value, "="); len(pairs) != 2 {
|
||||
return false
|
||||
}
|
||||
//如果 value 没有完整闭合括号则返回错误
|
||||
bytes := []byte(pairs[1])
|
||||
if (bytes[0] == '(' && bytes[len(bytes)-1] != ')') || (bytes[len(bytes)-1] == ')' && bytes[0] != '(') {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
//处理json数组
|
||||
func processJsonArr(pair []string) (string, bool) {
|
||||
value := fmt.Sprintf("JSON_CONTAINS(%v,JSON_ARRAY(", pair[0])
|
||||
//处理括号,遍历元素
|
||||
arrs := strings.Split(string([]byte(pair[1])[1:len([]byte(pair[1]))-1]), "|")
|
||||
for _, v := range arrs {
|
||||
//如果大括号里面没有元素
|
||||
if v == "" {
|
||||
return "", false
|
||||
}
|
||||
value = fmt.Sprintf("%v%v,", value, v)
|
||||
}
|
||||
s := []byte(value)
|
||||
value = string(s[0:len(s)-1]) + "))"
|
||||
return value, true
|
||||
|
||||
}
|
||||
|
||||
// ProcessMap 生成查询map
|
||||
func (g GetQuery) ProcessMap() (QueryMap, error) {
|
||||
m := make(QueryMap)
|
||||
//寻找没有软删掉的数据
|
||||
m["is_del"] = ruleType{rule: normal, value: `0`}
|
||||
//不满足最小查询条件直接返回
|
||||
if len([]byte(g.Query)) < 5 {
|
||||
return m, nil
|
||||
}
|
||||
//括号不匹配直接返回
|
||||
if bytes := []byte(g.Query); bytes[0] != '(' || bytes[len(bytes)-1] != ')' {
|
||||
return nil, errors.New(error_process.GrammerError)
|
||||
}
|
||||
//处理query字符串、掐头去尾
|
||||
g.Query = string([]byte(g.Query)[1 : len([]byte(g.Query))-1])
|
||||
//遍历处理过的字符串,根据query规则生成queryMap
|
||||
for _, v := range strings.Split(g.Query, ",") {
|
||||
if !checkGrammar(v) {
|
||||
return nil, errors.New(error_process.GrammerError)
|
||||
}
|
||||
pairs := strings.Split(v, "=")
|
||||
bytes := []byte(pairs[1])
|
||||
//是否是json数组
|
||||
if bytes[0] == '(' && bytes[len(bytes)-1] == ')' {
|
||||
if value, usable := processJsonArr(pairs); usable {
|
||||
m[pairs[0]] = ruleType{
|
||||
rule: jsonArray,
|
||||
value: value,
|
||||
}
|
||||
continue
|
||||
}
|
||||
return nil, errors.New(error_process.GrammerError)
|
||||
}
|
||||
//普通字段
|
||||
m[pairs[0]] = ruleType{
|
||||
rule: normal,
|
||||
value: pairs[1],
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type (
|
||||
ints []int
|
||||
strs []string
|
||||
)
|
||||
|
||||
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"`
|
||||
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"`
|
||||
ScriptTextContext string `json:"script_text_context" gorm:"column:script_text_context"`
|
||||
ScriptPlotScore float64 `json:"script_plot_score" gorm:"column:script_plot_score"`
|
||||
ScriptImageContent strs `json:"script_image_content" gorm:"column:script_image_content"`
|
||||
ScriptMalePlayer int `json:"script_male_player" gorm:"column:script_male_player"`
|
||||
ScriptFemalePlayer int `json:"script_female_player" gorm:"column:script_female_player"`
|
||||
ScriptDifficultDegree string `json:"script_difficult_degree" gorm:"column:script_difficult_degree"`
|
||||
ScriptPlayerLimit int `json:"script_player_limit" gorm:"column:script_player_limit"`
|
||||
Uuid string `json:"uuid" gorm:"column:uuid" valid:"no_empty"`
|
||||
ScriptComplexScore float64 `json:"script_complex_score" gorm:"column:script_complex_score"`
|
||||
Qid string `json:"qid" gorm:"column:qid"`
|
||||
IsDel int `json:"-" gorm:"column:is_del"`
|
||||
}
|
||||
|
||||
func (m *Scripts) TableName() string {
|
||||
return "scripts"
|
||||
}
|
||||
|
||||
func (p ints) Value() (driver.Value, error) {
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
func (p *ints) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), &p)
|
||||
}
|
||||
|
||||
func (p strs) Value() (driver.Value, error) {
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
func (p *strs) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), &p)
|
||||
}
|
||||
|
||||
func GetScriptsM(page, size int, query QueryMap, db *gorm.DB) ([]Scripts, int64, error) {
|
||||
i := new([]Scripts)
|
||||
num := int64(0)
|
||||
for k, v := range query {
|
||||
if v.rule == normal {
|
||||
db = db.Where(fmt.Sprintf("%v = ?", k), v.value)
|
||||
}
|
||||
if v.rule == jsonArray {
|
||||
db = db.Where(v.value)
|
||||
}
|
||||
}
|
||||
if num = db.Find(i).RowsAffected; num < 0 {
|
||||
return nil, 0, error_process.GetErr(errors.New(error_process.GormError), query)
|
||||
}
|
||||
if size > 0 {
|
||||
db = db.Limit(size).Offset((page - 1) * size)
|
||||
}
|
||||
db.Find(i)
|
||||
return *i, num, nil
|
||||
}
|
||||
|
||||
func UpdateScriptsM(scripts *Scripts, db *gorm.DB) error {
|
||||
if num := db.Model(Scripts{}).Where("uuid = ?", scripts.Uuid).Updates(scripts).RowsAffected; num != 1 {
|
||||
return error_process.UpdateErr(scripts, scripts.Uuid)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateScriptsM(script *Scripts, db *gorm.DB) error {
|
||||
if err := db.Create(script).Error; err != nil {
|
||||
return error_process.CreateErr(err, script)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
bgm "git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
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"`
|
||||
}
|
||||
// TagCategoriesDto 为标签新增分组
|
||||
TagCategoriesDto struct {
|
||||
CIds []string `json:"category_ids" valid:"no_empty"`
|
||||
Tid int `json:"tag_id" valid:"no_empty"`
|
||||
}
|
||||
)
|
||||
|
||||
func (m *Tag) TableName() string {
|
||||
return "tag"
|
||||
}
|
||||
|
||||
func CreateTagM(tag *Tag, db *gorm.DB) error {
|
||||
if err := db.Create(tag).Error; err != nil {
|
||||
return error_process.CreateErr(err, tag)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateTagM(tag *Tag, db *gorm.DB) error {
|
||||
if num := db.Model(Tag{}).Where("uuid = ?", tag.Uuid).Updates(*tag).RowsAffected; num != 1 {
|
||||
return error_process.UpdateErr(tag, fmt.Sprintf("uuid:%v", tag.Uuid))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetTagM(page, size int, query bgm.QueryMap, db *gorm.DB) ([]Tag, int64, error) {
|
||||
t := new([]Tag)
|
||||
num := int64(0)
|
||||
for k, v := range query {
|
||||
db = db.Where(fmt.Sprintf("%v = ?", k), v)
|
||||
}
|
||||
if num = db.Find(t).RowsAffected; num <= 0 {
|
||||
return nil, 0, error_process.GetErr(errors.New(error_process.GormError), query)
|
||||
}
|
||||
if size > 0 {
|
||||
db = db.Limit(size).Offset((page - 1) * size)
|
||||
}
|
||||
if err := db.Preload("Cs").Find(t).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return *t, num, nil
|
||||
}
|
||||
|
||||
func CreateCategoryForTagM(tid int, cIds []string, db *gorm.DB) error {
|
||||
t := new(Tag)
|
||||
//step1 getTag
|
||||
if err := db.Where(&Tag{
|
||||
Uuid: tid,
|
||||
}).Find(t).Error; err != nil {
|
||||
return error_process.GetErr(err, t)
|
||||
}
|
||||
//step2 get categories and check num is expected
|
||||
var cs []Category
|
||||
if num := db.Where(cIds).Find(&cs).RowsAffected; num != cast.ToInt64(len(cIds)) {
|
||||
return error_process.RecordNotMatchWithUniqueErr(cIds, len(cIds), cast.ToInt(num))
|
||||
}
|
||||
//step3 add association
|
||||
if err := db.Model(t).Association("Cs").Append(cs); err != nil {
|
||||
return error_process.CommonErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DelCategoryForTagM(tid int, cIds []string, db *gorm.DB) error {
|
||||
t := new(Tag)
|
||||
//step1 checkTagNum
|
||||
if err := db.Where(&Tag{
|
||||
Uuid: tid,
|
||||
}).Find(t).Error; err != nil {
|
||||
return error_process.GetErr(err, t)
|
||||
}
|
||||
//step2 check cIdsNum
|
||||
var cs []Category
|
||||
if num := db.Where(cIds).Find(&cs).RowsAffected; num != cast.ToInt64(len(cs)) {
|
||||
return error_process.RecordNotMatchWithUniqueErr(cIds, len(cIds), cast.ToInt(num))
|
||||
}
|
||||
//step3 add association
|
||||
err := db.Model(t).Association("Cs").Delete(cs)
|
||||
if err != nil {
|
||||
return error_process.CommonErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/gorm_helper"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
bgm "git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func CreateCategory(category *model.Category, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.CreateCategoryM(category, db)
|
||||
}
|
||||
|
||||
func GetCategory(page, limit int, query bgm.QueryMap, ctx *fiber.Ctx) ([]model.Category, int64, error) {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return model.GetCategoryM(page, limit, query, db)
|
||||
}
|
||||
|
||||
func UpdateCategory(category *model.Category, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.UpdateCategoryM(category, db)
|
||||
}
|
||||
|
||||
func DeleteCategory(category *model.Category, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
category.IsDel = 1
|
||||
//根据uuid对 is_del字段update,其他字段不允许传入
|
||||
if category.Value != "" {
|
||||
return error_process.ExtraValueErr("Value")
|
||||
}
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.UpdateCategoryM(category, db)
|
||||
}
|
||||
|
||||
// CreateTagForCategory 为Category 新增tag
|
||||
func CreateTagForCategory(cTags *model.CategoriesTagDto, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.CreateTagForCategoryM(cTags.Cid, cTags.TIds, db)
|
||||
}
|
||||
|
||||
// DeleteTagForCategory 删除Category分组
|
||||
func DeleteTagForCategory(cTags *model.CategoriesTagDto, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.DelTagForCategoryM(cTags.Cid, cTags.TIds, db)
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/gorm_helper"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetScripts(page, limit int, query model.QueryMap, ctx *fiber.Ctx) ([]model.ScriptsDto, int64, error) {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
queryMap := make(util.QueryMap)
|
||||
m := make(map[int]string)
|
||||
queryMap["type"] = "script"
|
||||
tag, _, err := model.GetTagM(-1, -1, queryMap, db)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
for _, v := range tag {
|
||||
m[v.Uuid] = v.Value
|
||||
}
|
||||
script, num, err := model.GetScriptsM(page, limit, query, db)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
dtos := make([]model.ScriptsDto, len(script))
|
||||
for k, v := range script {
|
||||
tags := make([]string, len(v.ScriptTag))
|
||||
for k1, v1 := range v.ScriptTag {
|
||||
if tag1, ok := m[v1]; !ok {
|
||||
return nil, 0, error_process.EmptyValueErr(strconv.Itoa(k1))
|
||||
} else {
|
||||
tags[k1] = tag1
|
||||
}
|
||||
|
||||
}
|
||||
dtos[k] = model.ScriptsDto{
|
||||
ScriptName: v.ScriptName,
|
||||
ScriptIntro: v.ScriptIntro,
|
||||
ScriptTag: tags,
|
||||
ScriptScore: v.ScriptScore,
|
||||
GroupDuration: v.GroupDuration,
|
||||
ScriptCoverUrl: v.ScriptCoverUrl,
|
||||
ScriptTextContext: v.ScriptTextContext,
|
||||
ScriptPlotScore: v.ScriptPlotScore,
|
||||
ScriptImageContent: v.ScriptImageContent,
|
||||
ScriptMalePlayer: v.ScriptMalePlayer,
|
||||
ScriptFemalePlayer: v.ScriptFemalePlayer,
|
||||
ScriptDifficultDegree: v.ScriptDifficultDegree,
|
||||
ScriptPlayerLimit: v.ScriptPlayerLimit,
|
||||
Uuid: v.Uuid,
|
||||
ScriptComplexScore: v.ScriptComplexScore,
|
||||
}
|
||||
}
|
||||
return dtos, num, nil
|
||||
}
|
||||
|
||||
func UpdateScripts(scripts *model.Scripts, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.UpdateScriptsM(scripts, db)
|
||||
}
|
||||
|
||||
func CreateScripts(scripts *model.Scripts, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.CreateScriptsM(scripts, db)
|
||||
}
|
||||
|
||||
func DeleteScripts(scripts *model.Scripts, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
scripts.IsDel = 1
|
||||
return model.UpdateScriptsM(scripts, db)
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/gorm_helper"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
|
||||
bgm "git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/util"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// CreateTag 新建Tag(暂不支持创建连带Category)
|
||||
func CreateTag(tag *model.Tag, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.CreateTagM(tag, db)
|
||||
}
|
||||
|
||||
func UpdateTag(tag *model.Tag, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.UpdateTagM(tag, db)
|
||||
}
|
||||
|
||||
func GetTag(page, limit int, ctx *fiber.Ctx, query bgm.QueryMap) ([]model.Tag, int64, error) {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return model.GetTagM(page, limit, query, db)
|
||||
}
|
||||
|
||||
func DeleteTag(tag *model.Tag, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
tag.IsDel = 1
|
||||
//根据uuid对 is_del字段update,其他字段不允许传入
|
||||
if tag.Value != "" {
|
||||
return error_process.ExtraValueErr("Value")
|
||||
}
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.UpdateTagM(tag, db)
|
||||
}
|
||||
|
||||
// CreateCategoryForTag 新增删除Category分组
|
||||
func CreateCategoryForTag(cTags *model.TagCategoriesDto, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.CreateCategoryForTagM(cTags.Tid, cTags.CIds, db)
|
||||
}
|
||||
|
||||
// DelCategoryForTag 删除Category分组
|
||||
func DelCategoryForTag(cTags *model.TagCategoriesDto, ctx *fiber.Ctx) error {
|
||||
var (
|
||||
db *gorm.DB
|
||||
err error
|
||||
)
|
||||
if db, err = gorm_helper.GetContextDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.DelCategoryForTagM(cTags.Tid, cTags.CIds, db)
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package util
|
||||
|
||||
import "strings"
|
||||
|
||||
type QueryMap map[string]string
|
||||
|
||||
// GetQueryMap 根据查询条件进行sql处理
|
||||
func GetQueryMap(s string) QueryMap {
|
||||
m := make(map[string]string)
|
||||
if s != "" {
|
||||
s = string([]byte(s)[1 : len([]byte(s))-1])
|
||||
for _, v := range strings.Split(s, ",") {
|
||||
split := strings.Split(v, "=")
|
||||
m[split[0]] = split[1]
|
||||
}
|
||||
}
|
||||
m["is_del"] = "0"
|
||||
return m
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package util
|
||||
|
||||
import "time"
|
||||
|
||||
var (
|
||||
cst *time.Location
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
if cst, err = time.LoadLocation("Asia/Shanghai"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 默认设置为中国时区
|
||||
time.Local = cst
|
||||
}
|
||||
|
||||
// CSTLayout China Standard Time Layout
|
||||
const CSTLayout = "2006-01-02 15:04:05"
|
||||
|
||||
func CSTLayoutString() string {
|
||||
ts := time.Now()
|
||||
return ts.In(cst).Format(CSTLayout)
|
||||
}
|
|
@ -1,7 +1,146 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/config"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/error_process"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/gorm_helper"
|
||||
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/handler"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
"github.com/gofiber/fiber/v2/middleware/requestid"
|
||||
ctxLogger "github.com/luizsuper/ctxLoggers"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
tag = "/tag"
|
||||
category = "/category"
|
||||
scripts = "/scripts"
|
||||
)
|
||||
|
||||
var (
|
||||
err error
|
||||
//Init App
|
||||
app = fiber.New(fiber.Config{
|
||||
ErrorHandler: func(ctx *fiber.Ctx, err error) error {
|
||||
return ctx.Status(fiber.StatusInternalServerError).JSON(handler.Response{Message: "服务器内部错误"})
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
ResourceInit()
|
||||
appInit()
|
||||
routerInit()
|
||||
}
|
||||
|
||||
// ResourceInit 读取配置初始化资源
|
||||
func ResourceInit() {
|
||||
|
||||
config.GetConfig()
|
||||
|
||||
err = gorm_helper.GormMap(config.GetConfigMap()[config.GetConfigKey(config.DsnPre)])
|
||||
if err != nil {
|
||||
ctxLogger.FError(nil, error_process.GormError, zap.String("", err.Error()))
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
func appInit() {
|
||||
//requestId
|
||||
app.Use(requestid.New())
|
||||
//logger
|
||||
app.Use(logger.New(logger.Config{
|
||||
Format: "${respHeader:X-Request-ID} ${status} - ${method} ${path} ${resBody}\n",
|
||||
}))
|
||||
//recover
|
||||
app.Use(recover.New(recover.Config{
|
||||
EnableStackTrace: true,
|
||||
StackTraceHandler: func(c *fiber.Ctx, e interface{}) {
|
||||
buf := make([]byte, 1024*1024)
|
||||
buf = buf[:runtime.Stack(buf, false)]
|
||||
fmt.Printf("panic: %v\n%s\n", e, buf)
|
||||
ctxLogger.FError(c, error_process.PanicError, zap.String("", fmt.Sprintf("panic: %v\n%s\n", e, buf)))
|
||||
},
|
||||
}))
|
||||
//requestId for gorm
|
||||
app.Use(func(ctx *fiber.Ctx) error {
|
||||
ctx.SetUserContext(context.WithValue(context.Background(), fiber.HeaderXRequestID, ctx.Response().Header.Peek(fiber.HeaderXRequestID)))
|
||||
return ctx.Next()
|
||||
})
|
||||
}
|
||||
|
||||
func routerInit() {
|
||||
//Tag router
|
||||
tagRoute := app.Group(tag)
|
||||
tagRoute.Get("", func(ctx *fiber.Ctx) error {
|
||||
return handler.GetTagH(ctx)
|
||||
})
|
||||
tagRoute.Post("", func(ctx *fiber.Ctx) error {
|
||||
return handler.CreateTagH(ctx)
|
||||
})
|
||||
tagRoute.Put("", func(ctx *fiber.Ctx) error {
|
||||
return handler.UpdateTagH(ctx)
|
||||
})
|
||||
tagRoute.Delete("", func(ctx *fiber.Ctx) error {
|
||||
return handler.DeleteTagH(ctx)
|
||||
})
|
||||
tagRoute.Post("/categories", func(ctx *fiber.Ctx) error {
|
||||
return handler.CreateCategoryForTag(ctx)
|
||||
})
|
||||
tagRoute.Delete("/categories", func(ctx *fiber.Ctx) error {
|
||||
return handler.DeleteCategoryForTag(ctx)
|
||||
})
|
||||
//Category router
|
||||
categoryRoute := app.Group(category)
|
||||
categoryRoute.Get("", func(ctx *fiber.Ctx) error {
|
||||
return handler.GetCategoryH(ctx)
|
||||
})
|
||||
categoryRoute.Post("", func(ctx *fiber.Ctx) error {
|
||||
return handler.CreateCategoryH(ctx)
|
||||
})
|
||||
categoryRoute.Put("", func(ctx *fiber.Ctx) error {
|
||||
return handler.UpdateCategoryH(ctx)
|
||||
})
|
||||
categoryRoute.Delete("", func(ctx *fiber.Ctx) error {
|
||||
return handler.DeleteCategoryH(ctx)
|
||||
})
|
||||
categoryRoute.Post("/tags", func(ctx *fiber.Ctx) error {
|
||||
return handler.CreateTagForCategory(ctx)
|
||||
})
|
||||
categoryRoute.Delete("/tags", func(ctx *fiber.Ctx) error {
|
||||
return handler.DeleteTagForCategory(ctx)
|
||||
})
|
||||
scriptsGroup := app.Group(scripts)
|
||||
scriptsGroup.Get("", func(ctx *fiber.Ctx) error {
|
||||
return handler.GetScriptsH(ctx)
|
||||
})
|
||||
scriptsGroup.Put("", func(ctx *fiber.Ctx) error {
|
||||
return handler.UpdateScriptsH(ctx)
|
||||
})
|
||||
scriptsGroup.Post("", func(ctx *fiber.Ctx) error {
|
||||
return handler.CreateScriptsH(ctx)
|
||||
})
|
||||
scriptsGroup.Delete("", func(ctx *fiber.Ctx) error {
|
||||
return handler.DeleteScriptsH(ctx)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func serverStart() {
|
||||
port := config.GetEnvDefault(config.Port, config.PortDefault)
|
||||
err = app.Listen(fmt.Sprintf(":%v", port))
|
||||
if err != nil {
|
||||
ctxLogger.Error(nil, "", zap.String("", err.Error()))
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("我是个示例")
|
||||
serverStart()
|
||||
}
|
||||
|
|
20
go.mod
20
go.mod
|
@ -5,10 +5,14 @@ go 1.17
|
|||
require (
|
||||
github.com/gofiber/fiber/v2 v2.24.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/google/uuid v1.1.2
|
||||
github.com/jinzhu/copier v0.3.4
|
||||
github.com/larksuite/oapi-sdk-go v1.1.43
|
||||
github.com/luizsuper/ctxLoggers v1.0.3
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/spf13/cast v1.4.1
|
||||
go.etcd.io/etcd/client/v3 v3.5.1
|
||||
go.uber.org/zap v1.19.1
|
||||
google.golang.org/grpc v1.43.0
|
||||
gorm.io/driver/mysql v1.2.3
|
||||
gorm.io/gorm v1.22.4
|
||||
|
@ -18,11 +22,24 @@ require (
|
|||
github.com/andybalholm/brotli v1.0.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
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.13.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.4.1 // 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
|
||||
github.com/jinzhu/now v1.1.3 // indirect
|
||||
github.com/json-iterator/go v1.1.11 // indirect
|
||||
github.com/klauspost/compress v1.13.4 // indirect
|
||||
github.com/leodido/go-urn v1.2.0 // indirect
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
|
||||
github.com/lestrrat-go/strftime v1.0.5 // indirect
|
||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/ugorji/go/codec v1.1.7 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.31.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
|
@ -30,10 +47,11 @@ require (
|
|||
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.17.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
|
||||
google.golang.org/protobuf v1.26.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0 // indirect
|
||||
)
|
||||
|
|
43
go.sum
43
go.sum
|
@ -9,6 +9,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
|
|||
github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=
|
||||
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
|
@ -40,23 +42,32 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
|
|||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-redis/redis/v8 v8.2.2/go.mod h1:ysgGY09J/QeDYbu3HikWEIPCwaeOkuNoTgKayTEaEOw=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gofiber/fiber/v2 v2.23.0/go.mod h1:MR1usVH3JHYRyQwMe2eZXRSZHRX38fkV+A7CPB+DlDQ=
|
||||
github.com/gofiber/fiber/v2 v2.24.0 h1:18rpLoQMJBVlLtX/PwgHj3hIxPSeWfN1YeDJ2lEnzjU=
|
||||
github.com/gofiber/fiber/v2 v2.24.0/go.mod h1:MR1usVH3JHYRyQwMe2eZXRSZHRX38fkV+A7CPB+DlDQ=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
|
@ -90,6 +101,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
|
@ -100,10 +112,13 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
|||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI=
|
||||
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
|
@ -114,17 +129,31 @@ github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8
|
|||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/larksuite/oapi-sdk-go v1.1.43 h1:DVUAbiYOfE+1yPyTKYofxcEpB027nhq9Lfk2DaLX960=
|
||||
github.com/larksuite/oapi-sdk-go v1.1.43/go.mod h1:7ybKAbVdKBjXuX0YrMTfnWUyCaIe/zeI1wqjNfN9XOk=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||
github.com/lestrrat-go/strftime v1.0.5 h1:A7H3tT8DhTz8u65w+JRpiBxM4dINQhUXAZnhBa2xeOE=
|
||||
github.com/lestrrat-go/strftime v1.0.5/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
|
||||
github.com/luizsuper/ctxLoggers v1.0.3 h1:u7YGzxhXb2uHm2sJxoO70xfpHz97PC7wIsmsX43Auzc=
|
||||
github.com/luizsuper/ctxLoggers v1.0.3/go.mod h1:wjnYowzWZwBJ7eWVwtcZN9Vbb4DdW8VHKSXzCvsdjIo=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
|
@ -161,6 +190,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
|
|||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
|
||||
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
|
@ -170,7 +201,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
|||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
|
@ -191,19 +224,24 @@ go.opentelemetry.io/otel v0.11.0/go.mod h1:G8UCk+KooF2HLkgo8RHX9epABH/aRGYET7gQO
|
|||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4=
|
||||
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI=
|
||||
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
|
@ -283,6 +321,7 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK
|
|||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
@ -319,6 +358,8 @@ google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/l
|
|||
google.golang.org/protobuf v1.26.0/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=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
|
|
Loading…
Reference in New Issue