{"id":207175,"date":"2025-07-08T11:00:26","date_gmt":"2025-07-08T03:00:26","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207175\/"},"modified":"2025-07-08T11:00:26","modified_gmt":"2025-07-08T03:00:26","slug":"%e5%a6%82%e4%bd%95%e6%ad%a3%e7%a1%ae%e4%bd%bf%e7%94%a8for%e5%be%aa%e7%8e%af%e8%8e%b7%e5%8f%96db%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207175\/","title":{"rendered":"\u5982\u4f55\u6b63\u786e\u4f7f\u7528for\u5faa\u73af\u83b7\u53d6db\u6570\u636e"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>\u5982\u4f55\u6b63\u786e\u4f7f\u7528for\u5faa\u73af\u83b7\u53d6db\u6570\u636e<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-20 16:30:40<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u6b63\u786e\u4f7f\u7528for\u5faa\u73af\u83b7\u53d6db\u6570\u636e\u300b<\/span>\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u9047\u5230\u4e86\u6a21\u677f\u7684\u95ee\u9898\uff0c\u56e0\u4e3a\u6211\u8fd8\u4e0d\u592a\u660e\u767d\u5b83\u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002<\/p>\n<p>\u6211\u7684\u9879\u76ee\u662f\u4e00\u4e2a\u652f\u6301\u7968\u8bc1\u7cfb\u7edf\uff0c\u6211\u6b63\u5728\u5c1d\u8bd5\u4ece\u6570\u636e\u5e93\u83b7\u53d6\u6240\u6709\u6761\u76ee\u3002\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u4f7f\u7528 boltdb\u3002<\/p>\n<p>\u95ee\u9898\u662f\uff0c\u5f53\u6211\u521b\u5efa for \u5faa\u73af\u65f6\uff0chtml \u6587\u4ef6\u4e2d\u7684\u6240\u6709\u5185\u5bb9\u4e5f\u5c06\u4f4d\u4e8e\u8be5\u5faa\u73af\u7684\u201c\u5185\u90e8\u201d\u3002<\/p>\n<p>\u5982\u4f55\u6b63\u786e\u7f16\u7801\uff0c\u4ee5\u663e\u793a\u6761\u76ee\u800c\u4e0d\u91cd\u590d\u6211\u7684 html\uff1f<\/p>\n<pre>package main\n\nimport (\n    \"encoding\/json\"\n    \"html\/template\"\n    \"log\"\n    \"net\/http\"\n)\n\ntype ManageTicketsPage struct {\n    Nome    string\n    Chamado string\n}\n\nfunc ManageTicketsHandler(w http.ResponseWriter, r *http.Request) {\n    \/\/Pick all tickets from boltdb.\n    entries := system_db_listTable(sysdb, \"tickets\")\n    results := [][]string{[]string{\n        \"Chamado\",\n        \"Nome do Operador\",\n        \"Ativo Retorno\",\n        \"Ativo Saida\",\n        \"Status\",\n        \"Data da Solicita\u00e7\u00e3o\",\n        \"Atualizado em\",\n    }}\n    for _, thisTicket := range entries {\n        ticketObjectJson := thisTicket[1]\n        thisTicketObject := new(ticket)\n        err := json.Unmarshal(ticketObjectJson, &amp;thisTicketObject)\n\n        if err != nil {\n            panic(err)\n        }\n        thisCSVLine := []string{\n            thisTicketObject.Nome,\n            thisTicketObject.AtivoCPU,\n            thisTicketObject.AtivoSaida,\n            thisTicketObject.Status,\n            thisTicketObject.DataEntrada,\n            thisTicketObject.SubmissionTime.Format(\"02\/01\/2006 15:04\"),\n        }\n\n        Nome := thisTicketObject.Nome\n        Chamado := thisTicketObject.AtivoCPU\n\n        p := ManageTicketsPage{Nome: Nome, Chamado: Chamado}\n\n        log.Println(Nome)\n        results = append(results, thisCSVLine)\n        t, _ := template.ParseFiles(\"web\/admin\/tickets.html\")\n        t.Execute(w, p)\n        \/\/log.Println(Nome)\n\n    }\n\n}<\/pre>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u6700\u597d\u521b\u5efa\u4e00\u4e2a Ticket \u7ed3\u6784\uff0c\u89e3\u7ec4\u5230 Ticket \u5207\u7247\u4e2d\uff0c\u4ec5\u5728\u4f20\u5165\u8be5\u5207\u7247\u65f6\u6e32\u67d3\u4e00\u6b21\uff0c\u5e76\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u8303\u56f4\u3002<\/p>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300a\u5982\u4f55\u6b63\u786e\u4f7f\u7528for\u5faa\u73af\u83b7\u53d6db\u6570\u636e\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u516c\u4f17\u53f7\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-207175","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=207175"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207175\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}