|
|
@ -29,22 +29,21 @@ func genCacheKeys(table parser.Table) (map[string]Key, error) {
|
|
|
|
camelTableName := table.Name.ToCamel()
|
|
|
|
camelTableName := table.Name.ToCamel()
|
|
|
|
lowerStartCamelTableName := stringx.From(camelTableName).UnTitle()
|
|
|
|
lowerStartCamelTableName := stringx.From(camelTableName).UnTitle()
|
|
|
|
for _, field := range fields {
|
|
|
|
for _, field := range fields {
|
|
|
|
if !field.IsKey {
|
|
|
|
if field.IsUniqueKey || field.IsPrimaryKey {
|
|
|
|
continue
|
|
|
|
camelFieldName := field.Name.ToCamel()
|
|
|
|
}
|
|
|
|
lowerStartCamelFieldName := stringx.From(camelFieldName).UnTitle()
|
|
|
|
camelFieldName := field.Name.ToCamel()
|
|
|
|
left := fmt.Sprintf("cache%s%sPrefix", camelTableName, camelFieldName)
|
|
|
|
lowerStartCamelFieldName := stringx.From(camelFieldName).UnTitle()
|
|
|
|
right := fmt.Sprintf("cache#%s#%s#", camelTableName, lowerStartCamelFieldName)
|
|
|
|
left := fmt.Sprintf("cache%s%sPrefix", camelTableName, camelFieldName)
|
|
|
|
variable := fmt.Sprintf("%s%sKey", lowerStartCamelTableName, camelFieldName)
|
|
|
|
right := fmt.Sprintf("cache#%s#%s#", camelTableName, lowerStartCamelFieldName)
|
|
|
|
m[field.Name.Source()] = Key{
|
|
|
|
variable := fmt.Sprintf("%s%sKey", lowerStartCamelTableName, camelFieldName)
|
|
|
|
VarExpression: fmt.Sprintf(`%s = "%s"`, left, right),
|
|
|
|
m[field.Name.Source()] = Key{
|
|
|
|
Left: left,
|
|
|
|
VarExpression: fmt.Sprintf(`%s = "%s"`, left, right),
|
|
|
|
Right: right,
|
|
|
|
Left: left,
|
|
|
|
Variable: variable,
|
|
|
|
Right: right,
|
|
|
|
KeyExpression: fmt.Sprintf(`%s := fmt.Sprintf("%s%s", %s,%s)`, variable, "%s", "%v", left, lowerStartCamelFieldName),
|
|
|
|
Variable: variable,
|
|
|
|
DataKeyExpression: fmt.Sprintf(`%s := fmt.Sprintf("%s%s",%s, data.%s)`, variable, "%s", "%v", left, camelFieldName),
|
|
|
|
KeyExpression: fmt.Sprintf(`%s := fmt.Sprintf("%s%s", %s,%s)`, variable, "%s", "%v", left, lowerStartCamelFieldName),
|
|
|
|
RespKeyExpression: fmt.Sprintf(`%s := fmt.Sprintf("%s%s", %s,resp.%s)`, variable, "%s", "%v", left, camelFieldName),
|
|
|
|
DataKeyExpression: fmt.Sprintf(`%s := fmt.Sprintf("%s%s",%s, data.%s)`, variable, "%s", "%v", left, camelFieldName),
|
|
|
|
}
|
|
|
|
RespKeyExpression: fmt.Sprintf(`%s := fmt.Sprintf("%s%s", %s,resp.%s)`, variable, "%s", "%v", left, camelFieldName),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m, nil
|
|
|
|
return m, nil
|
|
|
|