【优化】优化 cfg go的生成代码
parent
7ff3467d35
commit
b0d64bb967
|
|
@ -10,30 +10,25 @@ namespace Luban.Job.Cfg.Generate
|
|||
{
|
||||
public override string Render(DefBean b)
|
||||
{
|
||||
string package = DefAssembly.LocalAssebmly.TopModule;
|
||||
|
||||
var template = StringTemplateUtil.GetTemplate("config/go_bin/bean");
|
||||
var result = template.RenderCode(b, new Dictionary<string, object>() { ["package"] = package });
|
||||
var result = template.RenderCode(b);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string Render(DefTable p)
|
||||
{
|
||||
string package = DefAssembly.LocalAssebmly.TopModule;
|
||||
var template = StringTemplateUtil.GetTemplate("config/go_bin/table");
|
||||
var result = template.RenderCode(p, new Dictionary<string, object>() { ["package"] = package });
|
||||
var result = template.RenderCode(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string RenderService(string name, string module, List<DefTable> tables)
|
||||
{
|
||||
string package = DefAssembly.LocalAssebmly.TopModule;
|
||||
var template = StringTemplateUtil.GetTemplate("config/go_bin/tables");
|
||||
var result = template.Render(new {
|
||||
Name = name,
|
||||
Namespace = module,
|
||||
Tables = tables,
|
||||
Package = package,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,34 +10,27 @@ namespace Luban.Job.Cfg.Generate
|
|||
{
|
||||
public override string Render(DefBean b)
|
||||
{
|
||||
string package = "cfg";
|
||||
|
||||
var template = StringTemplateUtil.GetTemplate("config/go_json/bean");
|
||||
var result = template.RenderCode(b, new Dictionary<string, object>() { ["package"] = package });
|
||||
var result = template.RenderCode(b);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string Render(DefTable p)
|
||||
{
|
||||
// TODO 目前只有普通表支持多态. 单例表和双key表都不支持
|
||||
string package = "cfg";
|
||||
var template = StringTemplateUtil.GetTemplate("config/go_json/table");
|
||||
var result = template.RenderCode(p, new Dictionary<string, object>() { ["package"] = package });
|
||||
var result = template.RenderCode(p);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string RenderService(string name, string module, List<DefTable> tables)
|
||||
{
|
||||
string package = "cfg";
|
||||
|
||||
var template = StringTemplateUtil.GetTemplate("config/go_json/tables");
|
||||
var result = template.Render(new {
|
||||
Name = name,
|
||||
Namespace = module,
|
||||
Tables = tables,
|
||||
Package = package,
|
||||
});
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ namespace Luban.Job.Proto.Generate
|
|||
|
||||
protected override string Render(DefEnum e)
|
||||
{
|
||||
return RenderUtil.RenderCsEnumClass(e);
|
||||
var template = StringTemplateUtil.GetTemplate($"common/{RenderTemplateDir}/enum");
|
||||
var result = template.Render(e);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override string Render(DefBean b)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package {{package}}
|
||||
package {{x.top_module}}
|
||||
|
||||
const (
|
||||
{{~for item in x.items ~}}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
hierarchy_not_abstract_children = x.hierarchy_not_abstract_children
|
||||
-}}
|
||||
|
||||
package {{package}}
|
||||
package {{x.top_module}}
|
||||
|
||||
import (
|
||||
"bright/serialization"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
index_field2 = x.index_field2
|
||||
-}}
|
||||
|
||||
package {{package}}
|
||||
package {{x.top_module}}
|
||||
|
||||
import "bright/serialization"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
package {{package}}
|
||||
package {{namespace}}
|
||||
|
||||
import "bright/serialization"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
hierarchy_not_abstract_children = x.hierarchy_not_abstract_children
|
||||
-}}
|
||||
|
||||
package {{package}}
|
||||
package {{x.top_module}}
|
||||
|
||||
{{x.go_json_import}}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
index_field2 = x.index_field2
|
||||
-}}
|
||||
|
||||
package {{package}}
|
||||
package {{x.top_module}}
|
||||
|
||||
{{~if x.is_map_table~}}
|
||||
type {{go_full_name}} struct {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
package {{package}}
|
||||
package {{namespace}}
|
||||
|
||||
type JsonLoader func(string) ([]map[string]interface{}, error)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue