未验证 提交 ea7b2be0 编写于 作者: P Phodal Huang

refactor: move http method out api model

上级 38d2264c
......@@ -53,10 +53,10 @@ var apiCmd *cobra.Command = &cobra.Command{
if apiCmdConfig.ShowCount {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Size", "API", "Caller"})
table.SetHeader([]string{"Size", "Method", "Uri", "Caller"})
for _, v := range counts {
table.Append([]string{strconv.Itoa(v.Size), v.ApiName, replacePackage(v.Caller)})
table.Append([]string{strconv.Itoa(v.Size), v.HttpMethod, v.Uri, replacePackage(v.Caller)})
}
table.Render()
}
......@@ -90,7 +90,6 @@ func replacePackage(content string) string {
return re.ReplaceAllString(content, "")
//return strings.ReplaceAll(content, apiCmdConfig.RemovePackageNames, "")
}
func init() {
......
......@@ -52,7 +52,6 @@ func BuildCallChain(funcName string, methodMap map[string][]string) string {
return "\n"
}
func (c CallGraph) AnalysisByFiles(restApis []api.RestApi, deps []models.JClassNode) (string, []CallApiCount) {
methodMap := c.BuildMethodMap(deps)
var apiCallSCounts []CallApiCount
......@@ -68,9 +67,10 @@ func (c CallGraph) AnalysisByFiles(restApis []api.RestApi, deps []models.JClassN
chain = chain + apiCallChain
count := &CallApiCount{
Caller: caller,
ApiName: restApi.HttpMethod + " " + restApi.Uri,
Size: len(strings.Split(apiCallChain, " -> ")),
HttpMethod: restApi.HttpMethod,
Caller: caller,
Uri: restApi.Uri,
Size: len(strings.Split(apiCallChain, " -> ")),
}
apiCallSCounts = append(apiCallSCounts, *count)
......@@ -101,4 +101,3 @@ func (c CallGraph) BuildMethodMap(clzs []models.JClassNode) map[string][]string
return methodMap
}
package domain
type CallApiCount struct {
Caller string
ApiName string
Size int
HttpMethod string
Uri string
Caller string
Size int
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册