Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions service/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,21 @@ func oldRowMap(req *model.RowRequest, rule *global.Rule, primitive bool) map[str
return kv
}

// primaryKey 自适应获取主键
func primaryKey(re *model.RowRequest, rule *global.Rule) interface{} {
if rule.IsCompositeKey { // 组合ID
var key string
if rule.IsCompositeKey {
vList := make([]string, len(rule.TableInfo.PKColumns))
for _, index := range rule.TableInfo.PKColumns {
key += stringutil.ToString(re.Row[index])
vList[index] = stringutil.ToString(re.Row[index])
}
return key
} else {
index := rule.TableInfo.PKColumns[0]
data := re.Row[index]
column := rule.TableInfo.Columns[index]
return convertColumnData(data, &column, rule)
return strings.Join(vList, "_")
}

index := rule.TableInfo.PKColumns[0]
data := re.Row[index]
column := rule.TableInfo.Columns[index]

return convertColumnData(data, &column, rule)
}

func elsHosts(addr string) []string {
Expand Down