5.mapper\u5b9e\u73b0<\/strong><\/div>\n\r\n\/\/\u67e5\u8be2\u7528\u6237\u4e0b\u7684\u6240\u4ee5\u4fe1\u606f\r\nfunc (s *SubnetMapper) SearchAllByUserName(query *query.Query, userName string) (*api.ListResult, error) {\r\n \r\ntotalRow, err := s.Db.Query(\"SELECT COUNT(*) from t_subnet ,t_vpc where t_vpc.id = t_subnet.vpcid and username = ?\", userName)\r\nif err != nil {\r\nklog.Error(\"query orders count error\", err)\r\nreturn nil, err\r\n}\r\ntotal := 0\r\nfor totalRow.Next() {\r\nerr := totalRow.Scan(\r\n&total,\r\n)\r\nif err != nil {\r\nklog.Error(\"query orders count error\", err)\r\ncontinue\r\n}\r\n}\r\ntotalRow.Close()\r\n \r\nrows, err := s.Db.Query(SearchAllByUserNameSql, userName, query.Pagination.Limit, query.Pagination.Offset)\r\ndefer func() {\r\nif rows != nil {\r\nrows.Close()\r\n}\r\n}()\r\nif err != nil {\r\nklog.Error(\"query subnet error\", err)\r\nreturn nil, err\r\n}\r\nitems := make([]interface{}, 0)\r\nfor rows.Next() {\r\nss := new(vpc.SubnetItem)\r\nerr = rows.Scan(&ss.VpcName, &ss.VpcNetwork, &ss.SubnetName, &ss.SubnetNetwork, &ss.CreateTime)\r\nitems = append(items, *ss)\r\n}\r\nreturn &api.ListResult{\r\nTotalItems: total,\r\nItems: items,\r\n}, nil\r\n}\r\n\r\n<\/pre>\n\u53ef\u4ee5\u770b\u5230\u7b2c\u4e00\u6b65\u67e5\u51fa\u4e86\u6240\u6709count\u6570\u76ee\uff1a
\n<\/p>\n
\u67e5\u8be2\u8bed\u53e5\u52a0\u4e0a\u53c2\u6570\u3002\u63a7\u5236\u67e5\u5230\u7684\u9875\u6570\u3002<\/p>\n
\n\u8fd4\u56de\u7684\u662f\u603b\u6570\u91cf\u8ddf\u5f53\u524d\u67e5\u8be2\u9875\u3002<\/p>\n
\u7279\u6b8a\u60c5\u51b5\u7528\u4e0d\u5230\u6570\u636e\u5e93\u5206\u9875\u7684\uff0c\u5c31\u9700\u8981\u7528\u5230\u5185\u5b58\u5206\u9875\u4e86.<\/p>\n","protected":false},"excerpt":{"rendered":"
\/\/\u67e5\u8be2\u4e00\u4e2a\u7528\u6237\u4e0b\u6240\u6709\u7684subnet ws.Route(ws.GET(“\/subnets”). To(sc.L […]<\/p>\n","protected":false},"author":1903,"featured_media":239312,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-239313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/239313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=239313"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/239313\/revisions"}],"predecessor-version":[{"id":239319,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/239313\/revisions\/239319"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/239312"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=239313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=239313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=239313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}