gensc

package module
v0.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

README

gensc

Quick started

  • Download gensc byb using:
go install github.com/lujingwei/gensc/bin/gensc

功能

  • 从xlsx表格生成配置
  • 生成协议
  • 生成model, dao

配置生成

例子

@xlsx("xxx.xlsx")
class TaskConf {
    Name string;
}

源格式

列名1 列名2 列名3 列名4
注释 注释 注释 注释
名字1 名字2 名字3 名字4
名字1 名字2 名字4 名字4
类型 类型 类型 类型
数值 数值 数值 数值

类型

类型 解释 golang lua
bool
int8
int16
int32
int64
uint8
uint16
uint32
uint64
string
json
[]string
[]int8
[]int16
[]int32
[]int64

export script



export("xlsx路径名", lua, converter, "目标路径")


model

loader

bundle

协议生成

例子


namespace Login {
    const MessageId = 1001;
    class Request {
		first: string;
        last?: string;
    }
    class Response {
		ErrorCode: number
    }
}

参考

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGenNotChange   = errors.New("doc file not changed")
	ErrTODO           = errors.New("TODO")
	ErrDbNotSupport   = errors.New("db not support")
	ErrNullPointer    = errors.New("null pointer")
	ErrDataNotExist   = errors.New("data not exist")
	ErrDataDeleteFail = errors.New("data delete fail")
	ErrDataNotFound   = errors.New("data not found")
)

Functions

func ExtraAnnotate

func ExtraAnnotate(comments []*ast.Comment) (map[string]*Annotate, error)

func ExtraComment

func ExtraComment(commentGroup *ast.CommentGroup) ([]string, error)

func Make1Key_int

func Make1Key_int[T any](arr []*T, dict map[int]*T, key string) error

func Make1Key_int32

func Make1Key_int32[T any](arr []*T, dict map[int32]*T, key string) error

func Make1Key_int64

func Make1Key_int64[T any](arr []*T, dict map[int64]*T, key string) error

func Make1Key_string

func Make1Key_string[T any](arr []*T, dict map[string]*T, key string) error

func Make2Key_int64_int64

func Make2Key_int64_int64[T any](arr []*T, dict map[int64]map[int64]*T, key1 string, key2 string) error

func Make2Key_int64_string

func Make2Key_int64_string[T any](arr []*T, dict map[int64]map[string]*T, key1 string, key2 string) error

func Make2Key_int_int

func Make2Key_int_int[T any](arr []*T, dict map[int]map[int]*T, key1 string, key2 string) error

func Make2Key_string_int64

func Make2Key_string_int64[T any](arr []*T, dict map[string]map[int64]*T, key1 string, key2 string) error

func Make3Key_int64_int64_int64

func Make3Key_int64_int64_int64[T any](arr []*T, dict map[int64]map[int64]map[int64]*T, key1 string, key2 string, key3 string) error

Types

type Annotate

type Annotate struct {
	Name   string
	Values []string
}

func (*Annotate) String

func (a *Annotate) String() string

type Config

type Config struct {
	GenResource    GenResourceConfig
	GenProtocol    GenProtocolConfig
	GenModel       GenModelConfig
	GenConst       GenConstConfig
	GenBehavior    GenBehaviorConfig
	GenApplication GenApplicationConfig
	Macro          MacroConfig
}

type DbClient

type DbClient interface {
	Uri() string
}

type DbDao

type DbDao interface {
	UseClient(client DbClient) error
}

type GenApplicationConfig

type GenApplicationConfig struct {
	SrcGenApplicationDir string
	DocDir               string
}

type GenBehaviorConfig

type GenBehaviorConfig struct {
	Module    string
	SrcGenDir string
	DocDir    string
	GenXmlDir string
}

type GenConstConfig

type GenConstConfig struct {
	SrcGenDir string
	ExcelDir  string
	DocDir    string
}

type GenModelConfig

type GenModelConfig struct {
	Module      string
	SrcGenDir   string // src/gen/model
	DocDir      string // doc/model
	GenProtoDir string // gen/model
}

type GenProtocolConfig

type GenProtocolConfig struct {
	GenProtocolDir    string
	SrcGenProtocolDir string
	DocProtocolDir    string
}

type GenResourceConfig

type GenResourceConfig struct {
	Module             string
	DocDir             string // gen/
	ResourceDir        string // resource/
	GenDir             string // gen/resource/
	SrcGenDir          string // src/gen/resource/
	ExcelDir           string // .
	RespositoryVersion string // 仓库版本
	Force              bool
}

type Logger

type Logger interface {
	Infow(msg string, kvs ...interface{})
	Errorw(msg string, kvs ...interface{})
	Debugw(msg string, kvs ...interface{})
	Fatalw(msg string, kvs ...interface{})
	Warnw(msg string, kvs ...interface{})
	Info(args ...interface{})
	Error(args ...interface{})
	Debug(args ...interface{})
	Fatal(args ...interface{})
	Warn(args ...interface{})
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
}

type MacroConfig

type MacroConfig struct {
	SrcDirs    []string
	SrcGenDir  string
	SrcTestDir string
	SrcDir     string
}

type MongoClient

type MongoClient interface {
	DbClient
	GetMongoClient() *mongo.Client
	GetMongoDatabase() *mongo.Database
}

type MysqlClient

type MysqlClient interface {
	DbClient
	GetMysqlClient() *sql.DB
}

type RedisClient

type RedisClient interface {
	DbClient
	GetRedisClient() *redis.Client
}

type ResourceHandler

type ResourceHandler interface {
	OnResourcePreLoad(reload bool)
	OnResourcePostLoad(reload bool)
}

loader加载完成后,由handler进行转换处理

type ResourceLoader

type ResourceLoader interface {
	// 加载资源
	LoadResource(ctx context.Context, client DbClient, dir string, compress bool) error
	// 加载资源
	ReloadResource(ctx context.Context, client DbClient, dir string, compress bool) error
	// 配置版本
	GetResVersion() string
	// loader版本
	GetLoaderVersion() string
}

loader由gen生成

type ResourceSource

type ResourceSource interface {
	// 返回资源加载器
	GetResourceLoader() ResourceLoader
	OnResourcePreLoad(reload bool)
	// 资源加载完成
	OnResourcePostLoad(reload bool)
}

application需要实现的接口,返回loader,和接收loader的事件回调

type TagList

type TagList struct {
	Kv map[string]string
}

func ExplodeTag

func ExplodeTag(lit *ast.BasicLit) (*TagList, error)

func (*TagList) Int

func (self *TagList) Int(k string) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL