Skip to content

Commit 1f8a3fd

Browse files
committed
新增不导出指定表格
1 parent a20e1e0 commit 1f8a3fd

File tree

9 files changed

+136
-33
lines changed

9 files changed

+136
-33
lines changed

README.md

+35-12
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,35 @@ ID | #名称
612612

613613
表头中, 列字段首字符为#时,该列所有数据按默认值导出
614614

615+
## 不导出指定表
616+
实现此功能需要使用到TagAction, 参考下面例子配置:
617+
618+
在Index表中:
619+
620+
模式 | 表类型 | 表文件名 | 标记
621+
---|---|---|---|
622+
数据表 | Effect | Effect.csv | client
623+
数据表 | Password | Server.csv | server
624+
625+
* 客户端数据导出
626+
导出参数中新增参数
627+
```shell script
628+
--tag_action=nogentable:server
629+
```
630+
表示, 不导出带有server标记的所有表格
631+
632+
* 服务器数据导出
633+
导出参数中新增参数
634+
```shell script
635+
--tag_action=nogentable:client
636+
```
637+
表示, 不导出带有client标记的所有表格
638+
615639
## 不输出指定列数据
616640
实现此功能需要使用到TagAction, 参考下面例子配置:
617641

642+
在Type表中:
643+
618644
种类 | 对象类型 | 标识名 | 字段名 | 字段类型 | 数组切割| 值 | 索引 | 标记
619645
---|---|---|---|---|---|---|---|---
620646
表头 | ExampleData | 特效ID| EffectID | int32 | | | | client
@@ -630,14 +656,14 @@ ID | #名称
630656
* 客户端数据导出
631657
导出参数中新增参数
632658
```shell script
633-
--tag_action=nogen_binary:server
659+
--tag_action=nogenfield_binary:server
634660
```
635661
表示: server标记的字段不导出到二进制
636662

637663
* 服务器数据导出
638664
导出参数中新增参数
639665
```shell script
640-
--tag_action=nogen_json:client
666+
--tag_action=nogenfield_json:client
641667
```
642668
表示: client标记的字段不导出到json完整文件
643669

@@ -651,16 +677,13 @@ ID | #名称
651677
* 被标记的tag, 将被对应action处理
652678

653679
###action类型
654-
action | 功能
655-
---|---|
656-
nogen_json | 被标记的字段不导出到json完整文件中
657-
nogen_jsondir | 被标记的字段不导出到每个表文件json
658-
nogen_binary | 被标记的字段不导出到二进制中
659-
nogen_pbbin | 被标记的字段不导出到Protobuf二进制中
660-
661-
### tag
662-
tag在Type表中的"标记"字段绑定
663-
680+
action | 适用范围 | 功能
681+
---|---|---|
682+
nogenfield_json | Type表 | 被标记的字段不导出到json完整文件中
683+
nogenfield_jsondir| Type表 | 被标记的字段不导出到每个表文件json
684+
nogenfield_binary| Type表 | 被标记的字段不导出到二进制中
685+
nogenfield_pbbin| Type表 | 被标记的字段不导出到Protobuf二进制中
686+
nogentable| Index表 | 被标记的表不会导出到任何输出中
664687

665688
## 启用缓冲
666689
命令行中加入-usecache=true, 将启用缓存功能, 加速导出速度

v3/compiler/variant.go

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ func loadVariantTables(globals *model.Globals, kvList, dataList *model.DataTable
1111
// 遍历索引里的每一行配置
1212
for _, pragma := range globals.IndexList {
1313

14+
if globals.CanDoAction(model.ActionNoGenTable, pragma) {
15+
report.Log.Debugf(" (%s) %s action=nogentable, ignored(tag: %v)", pragma.TableType, pragma.TableFileName, pragma.Tags)
16+
continue
17+
}
18+
1419
report.Log.Debugf(" (%s) %s", pragma.TableType, pragma.TableFileName)
1520

1621
switch pragma.Kind {

v3/example/java/cfg/table_gen.json

+81-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,87 @@
11
{
22
"@Tool": "github.com/davyxu/tabtoy",
3-
"@Version": "3.0.1",
4-
"ExampleData":[
5-
{ "ID": 100, "Name": "扎克镇", "Rate": 3.14, "Accuracy": 1.602176, "Type": 2, "Skill": [3,1,2], "Buff": 100, "TagList": ["a","b"], "Multi": [1,3] },
6-
{ "ID": 200, "Name": "阿努比斯神庙", "Rate": 1.2, "Accuracy": 3.14159, "Type": 1, "Skill": [100,0,90], "Buff": 1, "TagList": ["c"], "Multi": [4,0] },
7-
{ "ID": 300, "Name": "花村", "Rate": 79.4, "Accuracy": 0, "Type": 3, "Skill": [], "Buff": 0, "TagList": [], "Multi": [] },
8-
{ "ID": 400, "Name": "艾兴瓦尔德", "Rate": 0.63, "Accuracy": 0, "Type": 4, "Skill": [], "Buff": 0, "TagList": [], "Multi": [] }
3+
"@Version": "3.1.0",
4+
"ExampleData": [
5+
{
6+
"Accuracy": 1.602176,
7+
"Buff": 100,
8+
"ID": 100,
9+
"Multi": [
10+
1,
11+
3
12+
],
13+
"Name": "扎克镇",
14+
"Rate": 3.14,
15+
"Skill": [
16+
3,
17+
1,
18+
2
19+
],
20+
"TagList": [
21+
"a",
22+
"b"
23+
],
24+
"Type": 2
25+
},
26+
{
27+
"Accuracy": 3.14159,
28+
"Buff": 1,
29+
"ID": 200,
30+
"Multi": [
31+
4,
32+
0
33+
],
34+
"Name": "阿努比斯神庙",
35+
"Rate": 1.2,
36+
"Skill": [
37+
100,
38+
0,
39+
90
40+
],
41+
"TagList": [
42+
"c"
43+
],
44+
"Type": 1
45+
},
46+
{
47+
"Accuracy": 0,
48+
"Buff": 0,
49+
"ID": 300,
50+
"Multi": [],
51+
"Name": "花村",
52+
"Rate": 79.4,
53+
"Skill": [],
54+
"TagList": [],
55+
"Type": 3
56+
},
57+
{
58+
"Accuracy": 0,
59+
"Buff": 0,
60+
"ID": 400,
61+
"Multi": [],
62+
"Name": "艾兴瓦尔德",
63+
"Rate": 0.63,
64+
"Skill": [],
65+
"TagList": [],
66+
"Type": 4
67+
}
968
],
10-
"ExtendData":[
11-
{ "Additive": 1.1 },
12-
{ "Additive": 1.2 }
69+
"ExampleKV": [
70+
{
71+
"GroupID": [
72+
10,
73+
20
74+
],
75+
"ServerIP": "8.8.8.8",
76+
"ServerPort": 1024
77+
}
1378
],
14-
"ExampleKV":[
15-
{ "ServerIP": "8.8.8.8", "ServerPort": 1024, "GroupID": [10,20] }
79+
"ExtendData": [
80+
{
81+
"Additive": 1.1
82+
},
83+
{
84+
"Additive": 1.2
85+
}
1686
]
1787
}

v3/example/protobuf/table.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Generated by github.com/davyxu/tabtoy
22
// DO NOT EDIT!!
3-
// Version: 3.0.1
3+
// Version: 3.1.0
44
syntax = "proto3";
55
package main;
66

v3/gen/bindata/struct.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func writeStruct(globals *model.Globals, tab *model.DataTable, row int) (*Binary
1616
continue
1717
}
1818

19-
if globals.CanDoAction(model.ActionNoGenBinary, header) {
19+
if globals.CanDoAction(model.ActionNoGenFieldBinary, header) {
2020
continue
2121
}
2222

v3/gen/jsondata/gen.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Output(globals *model.Globals, param string) (err error) {
2828
rowData := map[string]interface{}{}
2929
for col, header := range headers {
3030

31-
if globals.CanDoAction(model.ActionNoGenJsonDir, header) {
31+
if globals.CanDoAction(model.ActionNoGenFieldJsonDir, header) {
3232
continue
3333
}
3434

@@ -81,7 +81,7 @@ func Generate(globals *model.Globals) (data []byte, err error) {
8181
rowData := map[string]interface{}{}
8282
for col, header := range headers {
8383

84-
if globals.CanDoAction(model.ActionNoGenJson, header) {
84+
if globals.CanDoAction(model.ActionNoGenFieldJson, header) {
8585
continue
8686
}
8787

v3/gen/pbdata/gen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func exportTable(globals *model.Globals, pbFile protoreflect.FileDescriptor, tab
2525

2626
for col, field := range headers {
2727

28-
if globals.CanDoAction(model.ActionNoGenPbBinary, field) {
28+
if globals.CanDoAction(model.ActionNoGenFieldPbBinary, field) {
2929
continue
3030
}
3131

v3/model/index.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type IndexDefine struct {
2020
Tags []string `tb_name:"标记"` // | 分割
2121
}
2222

23-
func (self *IndexDefine) MatchTag(tag string) bool {
23+
func (self *IndexDefine) ContainTag(tag string) bool {
2424
for _, s := range self.Tags {
2525
if s == tag {
2626
return true

v3/model/tagaction.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
)
77

88
const (
9-
ActionNoGenJson = "nogen_json"
10-
ActionNoGenJsonDir = "nogen_jsondir"
11-
ActionNoGenBinary = "nogen_binary"
12-
ActionNoGenPbBinary = "nogen_pbbin"
9+
ActionNoGenFieldJson = "nogenfield_json"
10+
ActionNoGenFieldJsonDir = "nogenfield_jsondir"
11+
ActionNoGenFieldBinary = "nogenfield_binary"
12+
ActionNoGenFieldPbBinary = "nogenfield_pbbin"
13+
ActionNoGenTable = "nogentab"
1314
)
1415

1516
// 用tag选中目标, 做action
@@ -55,6 +56,10 @@ func (self *Globals) CanDoAction(action string, obj interface{}) bool {
5556
if v.ContainTag(tag) {
5657
return true
5758
}
59+
case *IndexDefine:
60+
if v.ContainTag(tag) {
61+
return true
62+
}
5863
}
5964
}
6065
}

0 commit comments

Comments
 (0)