Skip to content

Commit

Permalink
remove pb
Browse files Browse the repository at this point in the history
add pongo2
  • Loading branch information
askuy committed Jul 1, 2022
1 parent 0d0df27 commit cb41036
Show file tree
Hide file tree
Showing 57 changed files with 8,617 additions and 196 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ vim config/local.toml 更改db配置
export EGO_DEBUG=true && go run main.go
```

## 4 DSL配置
## 3 模板
因为前端会使用关键字`{{`, `}}`,而`pongo2`的模板也会使用该关键字,所以`egoctl``pongo2/v6`版本`fork`到项目里,
将模板关键字`{{`,`}}`改为`{$`,`$}`

## 5 DSL配置
```
package egoctl
type User struct {
Expand All @@ -58,8 +62,8 @@ type User struct {
```


## 5 模板配置
### 5.1 根据模型设置模板
## 6 模板配置
### 6.1 根据模型设置模板
DSL配置
```
package egoctl
Expand All @@ -68,30 +72,30 @@ type User struct {
UserName string `gorm:"not null" json:"userName" dto:""` // 昵称
}
```
### 5.2 获取主键
### 6.2 获取主键
模版配置
```
{{modelSchemas|fieldsGetPrimaryKey|snakeString}}
{$modelSchemas|fieldsGetPrimaryKey|snakeString$}
```

### 5.3 生成结构体
### 6.3 生成结构体
模板配置
```
type {{modelName|upperFirst}} struct {
{% for value in modelSchemas %}
{{value.FieldName}} {{value.FieldType}} `gorm:"{{value|fieldGetTag:"gorm"}}"` {{value.Comment}}
{$ value.FieldName $} {$ value.FieldType $} `gorm:"{$ value|fieldGetTag:"gorm" $}"` {$ value.Comment $}
{% endfor %}
}
```

### 5.4 判断某字段是否存在
### 6.4 判断某字段是否存在
模板配置
```
{% if modelSchemas|fieldsExist:Uid %}
{% endif %}
```

## 6 根据单个字段设置模板
## 7 根据单个字段设置模板
DSL配置
```
type User struct {
Expand All @@ -100,14 +104,14 @@ type User struct {
}
```

### 6.1 获取某个字段的驼峰(常用于JSON,前后端对接)
### 7.1 获取某个字段的驼峰(常用于JSON,前后端对接)
```
{{value.FieldName|camelString|lowerFirst}}
{$ value.FieldName|camelString|lowerFirst $}
UserName 变成 userName
```

### 6.2 获取某个字段的蛇形(常用于数据库)
### 7.2 获取某个字段的蛇形(常用于数据库)
```
{{value.FieldName|snakeString|lowerFirst}}
{$ value.FieldName|snakeString|lowerFirst $}
UserName 变成 user_name
```
11 changes: 0 additions & 11 deletions cmd/pb/pb.go

This file was deleted.

104 changes: 54 additions & 50 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,85 @@ module github.com/gotomicro/egoctl
go 1.18

require (
github.com/BurntSushi/toml v0.3.1
github.com/BurntSushi/toml v1.1.0
github.com/davecgh/go-spew v1.1.1
github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915
github.com/fsnotify/fsnotify v1.4.9
github.com/gin-gonic/gin v1.6.3
github.com/fsnotify/fsnotify v1.5.4
github.com/gin-gonic/gin v1.7.7
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/gorilla/websocket v1.4.2
github.com/gotomicro/ego v0.3.10
github.com/gorilla/websocket v1.5.0
github.com/gotomicro/ego v1.1.4
github.com/gotomicro/gotoant v0.0.0-20210105085109-df5f1354ac30
github.com/pelletier/go-toml v1.8.1
github.com/smartwalle/pongo2render v1.0.1
github.com/spf13/cobra v1.1.3
github.com/syndtr/goleveldb v1.0.0
github.com/uber/prototool v1.10.0
go.uber.org/zap v1.16.0
go.uber.org/zap v1.21.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/yaml.v2 v2.4.0
)

require (
cloud.google.com/go v0.46.3 // indirect
github.com/RaMin0/gin-health-check v0.0.0-20180807004848-a677317b3f01 // indirect
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/alibaba/sentinel-golang v1.0.3 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/emicklei/proto v1.9.0 // indirect
github.com/envoyproxy/go-control-plane v0.9.4 // indirect
github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect
github.com/frankban/quicktest v1.13.1 // indirect
github.com/fullstorydev/grpcurl v1.5.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-resty/resty/v2 v2.3.0 // indirect
github.com/gobuffalo/flect v0.2.1 // indirect
github.com/gofrs/flock v0.7.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/cel-go v0.11.3 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/gotomicro/logrotate v0.0.0-20211108034117-46d53eedc960 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jhump/protoreflect v1.6.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.6.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.9.1 // indirect
github.com/prometheus/procfs v0.0.11 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/shirou/gopsutil/v3 v3.21.6 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/uber/jaeger-client-go v2.23.1+incompatible // indirect
github.com/uber/jaeger-lib v2.4.0+incompatible // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.6 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/automaxprocs v1.3.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.7.0 // indirect
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/automaxprocs v1.5.1 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/text v0.3.3 // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98 // indirect
google.golang.org/grpc v1.29.1 // indirect
google.golang.org/protobuf v1.26.0 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3 // indirect
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/uber/prototool v1.10.0 => github.com/gotomicro/prototool v1.10.1-0.20210830042344-7ff76cec90a9
Loading

0 comments on commit cb41036

Please sign in to comment.