【完善】完善db typescript 生成。补充table key,value序列化函数实现。
【修复】修复Luban.Client连接服务器失败后不退出的问题main
parent
d776373ee8
commit
050310c15c
|
|
@ -185,9 +185,18 @@ Options:
|
||||||
conn.Wait();
|
conn.Wait();
|
||||||
profile.EndPhaseAndLog();
|
profile.EndPhaseAndLog();
|
||||||
|
|
||||||
|
if (GenClient.Ins.Session.Channel.IsOpen)
|
||||||
|
{
|
||||||
profile.StartPhase("gen job");
|
profile.StartPhase("gen job");
|
||||||
exitCode = SubmitGenJob(options);
|
exitCode = SubmitGenJob(options);
|
||||||
profile.EndPhaseAndLog();
|
profile.EndPhaseAndLog();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s_logger.Error("connect fail");
|
||||||
|
exitCode = 2;
|
||||||
|
}
|
||||||
|
|
||||||
profile.EndPhaseAndLog();
|
profile.EndPhaseAndLog();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
||||||
|
|
@ -118,5 +118,15 @@ namespace Luban.Job.Db.Defs
|
||||||
return type.Apply(DbTypescriptCompatibleDeserializeVisitor.Ins, bufName, fieldName);
|
return type.Apply(DbTypescriptCompatibleDeserializeVisitor.Ins, bufName, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string DbTsCompatibleSerializeWithoutSegment(string bufName, string fieldName, TType type)
|
||||||
|
{
|
||||||
|
return type.Apply(DbTypescriptCompatibleSerializeVisitor.Ins, bufName, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string DbTsCompatibleDeserializeWithoutSegment(string bufName, string fieldName, TType type)
|
||||||
|
{
|
||||||
|
return type.Apply(DbTypescriptCompatibleDeserializeVisitor.Ins, bufName, fieldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ namespace Luban.Job.Db.Generate
|
||||||
readonly_name = ""IReadOnly"" + name
|
readonly_name = ""IReadOnly"" + name
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
{{x.typescript_namespace_begin}}
|
{{x.typescript_namespace_begin}}
|
||||||
export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x.parent}} {{else}} TxnBeanBase {{end}}{
|
export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x.parent}} {{else}} TxnBeanBase {{end}}{
|
||||||
{{~ for field in fields~}}
|
{{~ for field in fields~}}
|
||||||
|
|
@ -63,23 +62,23 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
|
||||||
}
|
}
|
||||||
|
|
||||||
{{~ for field in fields~}}
|
{{~ for field in fields~}}
|
||||||
{{ctype = field.ctype}}
|
{{~ctype = field.ctype~}}
|
||||||
{{~if has_setter field.ctype~}}
|
{{~if has_setter ctype~}}
|
||||||
|
private static {{field.log_type}} = class extends FieldLoggerGeneric2<{{name}}, {{db_ts_define_type ctype}}> {
|
||||||
private static {{field.log_type}} = class extends FieldLoggerGeneric2<{{name}}, {{db_ts_define_type field.ctype}}> {
|
constructor(self:{{name}}, value: {{db_ts_define_type ctype}}) { super(self, value) }
|
||||||
constructor(self:{{name}}, value: {{db_ts_define_type field.ctype}}) { super(self, value) }
|
|
||||||
|
|
||||||
get fieldId(): number { return this.host.getObjectId() + {{field.id}} }
|
get fieldId(): number { return this.host.getObjectId() + {{field.id}} }
|
||||||
|
|
||||||
|
get tagId(): number { return FieldTag.{{tag_name ctype}} }
|
||||||
|
|
||||||
commit() { this.host.{{field.internal_name}} = this.value }
|
commit() { this.host.{{field.internal_name}} = this.value }
|
||||||
|
|
||||||
writeBlob(_buf: ByteBuf) {
|
writeBlob(_buf: ByteBuf) {
|
||||||
_buf.WriteInt(FieldTag.{{tag_name field.ctype}});
|
{{ts_write_blob '_buf' 'this.value' ctype}}
|
||||||
{{ts_write_blob '_buf' 'this.value' field.ctype}}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get {{field.ts_style_name}}(): {{db_ts_define_type field.ctype}} {
|
get {{field.ts_style_name}}(): {{db_ts_define_type ctype}} {
|
||||||
if (this.isManaged) {
|
if (this.isManaged) {
|
||||||
var txn = TransactionContext.current
|
var txn = TransactionContext.current
|
||||||
if (txn == null) return {{field.internal_name_with_this}}
|
if (txn == null) return {{field.internal_name_with_this}}
|
||||||
|
|
@ -90,14 +89,14 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set {{field.ts_style_name}}(value: {{db_ts_define_type field.ctype}}) {
|
set {{field.ts_style_name}}(value: {{db_ts_define_type ctype}}) {
|
||||||
{{~if db_field_cannot_null~}}
|
{{~if db_field_cannot_null~}}
|
||||||
if (value == null) throw new Error()
|
if (value == null) throw new Error()
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
if (this.isManaged) {
|
if (this.isManaged) {
|
||||||
let txn = TransactionContext.current
|
let txn = TransactionContext.current
|
||||||
txn.putFieldLong(this.getObjectId() + {{field.id}}, new {{name}}.{{field.log_type}}(this, value))
|
txn.putFieldLong(this.getObjectId() + {{field.id}}, new {{name}}.{{field.log_type}}(this, value))
|
||||||
{{~if field.ctype.need_set_children_root~}}
|
{{~if ctype.need_set_children_root~}}
|
||||||
value?.initRoot(this.getRoot())
|
value?.initRoot(this.getRoot())
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -106,7 +105,7 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
|
||||||
}
|
}
|
||||||
|
|
||||||
{{~else~}}
|
{{~else~}}
|
||||||
get {{field.ts_style_name}}(): {{db_ts_define_type field.ctype}} { return {{field.internal_name_with_this}} }
|
get {{field.ts_style_name}}(): {{db_ts_define_type ctype}} { return {{field.internal_name_with_this}} }
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
|
|
||||||
|
|
@ -198,19 +197,23 @@ export {{x.ts_class_modifier}} class {{name}} extends {{if parent_def_type}} {{x
|
||||||
newValue(): {{db_ts_define_type value_ttype}} { return new {{db_ts_define_type value_ttype}}() }
|
newValue(): {{db_ts_define_type value_ttype}} { return new {{db_ts_define_type value_ttype}}() }
|
||||||
|
|
||||||
serializeKey(buf: ByteBuf, key: {{db_ts_define_type key_ttype}}) {
|
serializeKey(buf: ByteBuf, key: {{db_ts_define_type key_ttype}}) {
|
||||||
throw new Error('Method not implemented.')
|
{{db_ts_compatible_serialize_without_segment 'buf' 'key' key_ttype}}
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeValue(buf: ByteBuf, value: {{db_ts_define_type value_ttype}}) {
|
serializeValue(buf: ByteBuf, value: {{db_ts_define_type value_ttype}}) {
|
||||||
throw new Error('Method not implemented.')
|
{{db_ts_compatible_serialize_without_segment 'buf' 'value' value_ttype}}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializeKey(buf: ByteBuf): {{db_ts_define_type key_ttype}} {
|
deserializeKey(buf: ByteBuf): {{db_ts_define_type key_ttype}} {
|
||||||
throw new Error('Method not implemented.')
|
let key: {{db_ts_define_type key_ttype}}
|
||||||
|
{{db_ts_compatible_deserialize_without_segment 'buf' 'key' key_ttype}}
|
||||||
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializeValue(buf: ByteBuf): {{db_ts_define_type value_ttype}} {
|
deserializeValue(buf: ByteBuf): {{db_ts_define_type value_ttype}} {
|
||||||
throw new Error('Method not implemented.')
|
let value = new {{db_ts_define_type value_ttype}}()
|
||||||
|
{{db_ts_compatible_deserialize_without_segment 'buf' 'value' value_ttype}}
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue