{"id":1218,"date":"2016-05-07T16:14:02","date_gmt":"2016-05-07T08:14:02","guid":{"rendered":"http:\/\/ufqi.com\/blog\/?p=1218"},"modified":"2016-05-07T17:38:29","modified_gmt":"2016-05-07T09:38:29","slug":"gwa2-add-read-write-object-201605","status":"publish","type":"post","link":"https:\/\/ufqi.com\/blog\/gwa2-add-read-write-object-201605\/","title":{"rendered":"-GWA2\u66f4\u65b0\uff1a\u6269\u5c55\u589e\u52a0read\/writeObject to setBy\/getBy"},"content":{"rendered":"<p>\u7ee7\u7eed\u9700\u6c42\u9a71\u52a8\uff0c<a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-gwa2\" target=\"_blank\">-GWA2<\/a>\u00a0\u6269\u5c55\u589e\u52a0read\/writeObject \u5230 setBy\/getBy\u4e2d\uff0c\u5bf9\u6570\u636e\u6301\u4e45\u5316\u5c42\u7684\u8bbf\u95ee\u589e\u52a0\u4e86\u5bf9\u6587\u4ef6\u7cfb\u7edf\u548c\u8fdc\u7a0b\u63a5\u53e3\u7684\u652f\u6301\u3002\u672c\u5468\u8fd8\u6df1\u5165\u4e86\u89e3\u4e86 <a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-thinkphp\" target=\"_blank\">-ThinkPHP<\/a> \u8fd9\u4e00\u5f00\u53d1\u6846\u67b6\uff0c\u968f\u7740\u5bf9\u5176\u6df1\u5165\u7406\u89e3\uff0c\u4e5f\u518d\u6b21\u9677\u5165\u4e86\u4e3a\u4f55\u9700\u8981\uff0c\u4e3a\u4f55\u90a3\u4e48\u591a\u5f00\u53d1\u6846\u67b6\u88ab\u5f00\u53d1\u51fa\u6765 \u8fd9\u6837\u7684\u601d\u8003\u9898\u4e2d\u3002<\/p>\n<p>\u4f46\u8fd9\u4e2a\u95ee\u9898\u73b0\u5728\u8fd8\u6ca1\u6709\u89e3\uff0c\u91c7\u7528\u7c7b\u6bd4\u601d\u8003\u7684\u65b9\u6cd5\uff0c\u4eba\u4eec\u6240\u8bf4\u7684\u8bdd\uff0c\u4e3a\u4f55\u6709\u90a3\u4e48\u591a\u8bed\u8a00\uff1f \u540c\u4e00\u95e8\u8bed\u8a00\uff0c\u4e3a\u4f55\u6709\u90a3\u4e48\u591a\u79cd\u65b9\u8a00\uff1f \u8ba1\u7b97\u673a\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u4f55\u6709\u90a3\u4e48\u591a\u5206\u7c7b\uff1f \u540c\u6837\u662fLinux\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e3a\u4f55\u6709\u90a3\u4e48\u591a\u5206\u652f\u65c1\u7cfb\uff1f<strong>\u4e5f\u8bb8\u4e16\u754c\u539f\u672c\u662f\u591a\u6001\u548c\u4e30\u5bcc\u7684\uff0c\u4e16\u754c\u7684\u591a\u6837\u6027\uff0c\u5927\u591a\u662f\u4e2a\u4f53\u7684\u5dee\u5f02\u6240\u5bfc\u81f4<\/strong>\u3002\u6bd4\u5982\uff0c\u4e16\u754c\u4e0a\u5e94\u8be5\u6709\u6700\u597d\u7684\u67d0\u4e2a\u82f9\u679c\uff0c\u4e5f\u6709\u6700\u5dee\u7684\u67d0\u4e2a\u68a8\u5b50\uff0c\u53ea\u662f\u4e2a\u4f53\u548c\u5b50\u7fa4\u7684\u6240\u5904\u73af\u5883\u3001\u8ba4\u77e5\u5dee\u5f02\u7b49\uff0c\u5bfc\u81f4\u4e00\u4e2a\u7edd\u5bf9\u610f\u4e49\u4e0a\u7684\u597d\u7684\u82f9\u679c\u5728A\u6216\u8005A\u7fa4\u770b\u6765\u662f\u597d\u7684\u6216\u8005\u6700\u597d\u7684\uff0c\u5728B\u6216\u8005B\u7fa4\u770b\u6765\u662f\u5dee\u7684\u6216\u8005\u6700\u5dee\u7684\uff0c\u5728C\u6216\u8005C\u7fa4\u770b\u6765\uff0c\u5f88\u4e00\u822c\u822c\uff0c\u800cD\u6216\u8005D\u7fa4\u53ef\u80fd\u8bf4\uff0c\u8fd9\u662f\u4ec0\u4e48\u4e1c\u897f\u3002\u6ca1\u9519\uff0c\u4ed6\u4eec\u90fd\u6ca1\u6709\u9519\uff0c\u4ece\u4ed6\u4eec\u81ea\u5df1\u7684\u89c2\u70b9\u3001\u89c6\u89d2\u548c\u8ba4\u77e5\u6765\u770b\uff0c\u4ed6\u4eec\u7684\u5224\u65ad\u662f\u7b26\u5408\u4e00\u822c\u903b\u8f91\u63a8\u7406\u8fc7\u7a0b\u7684\u3002<\/p>\n<p>\u5728\u201c\u5316\u5e72\u6208\u4e3a\u7389\u5e1b\uff1a\u5e73\u606f\u4e89\u6267\u7684\u56db\u4e2a\u65b9\u6cd5(\u00a0<b><a href=\"http:\/\/labs.people.com.cn\/url4p\/index.php?sid=725754&amp;act=query&amp;shortkey=X2Tc\" target=\"_blank\">-R\/X2Tc<\/a>\u00a0<\/b>)\u201d\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u66fe\u89c2\u5bdf\u5230\u201c<strong>\u4eba\u5c06\u81ea\u5df1\u89c6\u4e3a\u771f\u7406\uff0c\u53ef\u80fd\u662f\u6240\u6709\u4e89\u6267\u7684\u8d77\u6e90\uff0c\u6240\u6709\u6218\u4e89\u7684\u5bfc\u706b\u7d22<\/strong>\u201d\u3002\u4e5f\u8bb8\u8fd9\u80fd\u5f88\u597d\u5730\u89e3\u91ca\uff0c\u54ea\u79cd\u5f00\u53d1\u6846\u67b6\u597d\uff0c\u4e3a\u4f55\u6709\u90a3\u4e48\u591a\u8f6f\u4ef6\u5f00\u53d1\u6846\u67b6\u88ab\u5f00\u53d1\u51fa\u6765\u3002<\/p>\n<p>\u5f52\u6b63\uff0c\u5728\u6280\u672f\u5b9e\u73b0\u4e0a\uff0c -GWA2 \u7684\u8bbe\u8ba1\u4e2d\uff0c\u6b64\u524d\u5c06\u6240\u6709\u5bf9\u5bf9\u8c61\u7684\u6539\u53d8\uff0c\u9ed8\u8ba4\u6301\u7eed\u5316\u5b58\u50a8\u662f \u6570\u636e\u5e93\uff0c\u6ca1\u6709\u6df1\u5165\u8003\u8651\u6216\u8005\u5b9e\u73b0\u5176\u6269\u5c55\u5c06\u6301\u4e45\u5316\u5b58\u50a8\u5230\u5176\u4ed6\u65b9\u5f0f\u65b9\u6cd5\uff0c\u6bd4\u5982\u7f51\u7edc\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49\uff0c\u672c\u5468\u5728\u7814\u53d1\u4e2d\u9047\u5230\u5b9e\u4f8b\uff0c\u5c31\u987a\u4fbf\u5c06\u6539\u53d8\u72b6\u6001\u7684\u4e3b\u65b9\u6cd5 getBy\/setBy\u505a\u4e86\u6269\u5c55\uff0c\u4f7f\u4e4b\u80fd\u591f\u652f\u6301\u8bfb\u5199\u6587\u4ef6\u548c\u7f51\u7edc\u8bbf\u95ee\u3002\u4e5f\u5373\uff0c\u589e\u52a0\u4e86 readObject\/writeObject\u3002 \u5176\u6280\u672f\u7ec6\u8282\u5982\u4e0b\uff1a<\/p>\n<p><strong>1. readObject<\/strong><br \/>\n\u5728 getBy \u4e2d\u5224\u65ad getBy \u7684\u7b2c\u4e00\u4e2a\u53c2\u6570 $fields \u4e2d\u662f\u5426\u5305\u62ec &#8220;:&#8221;, \u5982\u679c\u5305\u62ec\uff0c\u5219\u89c6\u4e3a\u8bfb\u53d6\u6587\u4ef6\u7cfb\u7edf\u6216\u8005\u7f51\u7edc\u7cfb\u7edf\uff0c\u800c\u4e0d\u662f\u6570\u636e\u5e93\u7cfb\u7edf\u3002<br \/>\n\u8fdb\u4e00\u6b65\u5730\uff0c\u5f53\u5224\u65ad\u6210\u4ece\u975e\u6570\u636e\u5e93\u8bfb\u53d6\u65f6\uff0c\u5219\u5206\u522b\u5224\u65ad\u662f\uff1a<br \/>\na) &#8216;file:&#8217; \uff0c \u8fd9\u4e2a\u5173\u952e\u8bcd\u8868\u793a\uff0c\u4ece\u6587\u4ef6\u7cfb\u7edf\u8bfb\u53d6;<br \/>\nb) &#8216;url:&#8217; , \u8fd9\u4e2a\u5173\u952e\u8bcd\u8868\u793a\uff0c\u4ece\u7f51\u7edc\u8fdc\u7a0b\u901a\u8fc7URL\u8bfb\u53d6\u3002<br \/>\n<a href=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-201605.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1221\" alt=\"-gwa2-readObject-201605\" src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-201605.png\" width=\"742\" height=\"1281\" srcset=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-201605.png 742w, https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-201605-173x300.png 173w, https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-201605-593x1024.png 593w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/a><\/p>\n<p><strong>2. writeObject<\/strong><br \/>\n\u540c\u6837\u5730\uff0c \u5728 -GWA2 \u4e2d\uff0c\u5728 setBy \u65b9\u6cd5\u4e2d\uff0c\u5224\u65ad\u5176\u7b2c\u4e00\u4e2a\u53c2\u6570 $fields, \u5982\u679c\u4fdd\u62a4\u6709 &#8216;:&#8217; \u5173\u952e\u8bcd\uff0c\u5219\u89c6\u4e3a\u5b58\u50a8\u6301\u4e45\u5316\u5230\u975e\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u7531\u6b64\u5c06\u5904\u7f6e\u6743\u4ea4\u7ed9 writeObject. \u5728 writeObject \u4e2d\u8fdb\u4e00\u6b65\u5730\u5224\u65ad:<br \/>\na) \u82e5\u5b58\u50a8\u4e3a &#8216;file:&#8217; \u5173\u952e\u8bcd\uff0c\u5219\u8c03\u7528\u6587\u4ef6\u5199\u64cd\u4f5c\u7cfb\u7edf\uff1b<br \/>\nb) \u82e5\u5b58\u50a8\u4e3a \u2018url:&#8217; \u5173\u952e\u8bcd\uff0c\u5219\u5b58\u50a8\u4e3a\u8fdb\u4e00\u6b65\u8c03\u7528\u8fdc\u7aef\u63a5\u53e3\uff0c\u6b64\u65f6\u4e3a\u89e6\u53d1 HTTP POST\/GET \u65b9\u6cd5\uff0c\u5c01\u88c5\u7ec6\u8282\u89c1\u7a0b\u5e8f\u4ee3\u7801\u3002<\/p>\n<p><strong>3. \u8c03\u7528\u6837\u4f8b<\/strong><br \/>\n\u8c03\u7528\u4e0a\u8ff0\u5199\u5165\u6216\u8005\u8bfb\u53d6\u975e\u6570\u636e\u5e93\u7684\u6301\u4e45\u5316\u8d81\uff0c\u4f7f\u7528:<br \/>\n$obj = $webappInstance-&gt;getBy(&#8216;url:&#8217;, $args);<br \/>\n$obj = $webappInstance-&gt;getBy(&#8216;file:&#8217;, $args);<br \/>\n$obj = $webappInstance-&gt;setBy(&#8216;url:&#8217;, $args);<br \/>\n$obj = $webappInstance-&gt;setBy(&#8216;file:&#8217;, $args);<br \/>\n\u5176\u4e2d\uff0c\u5f53 &#8216;file:&#8217; \u65f6\uff0c<br \/>\n$args = array(&#8216;target&#8217;=&gt;&#8217;xxx&#8217;, &#8216;content&#8217;=&gt;&#8217;xxx&#8217;, &#8216;islock&#8217;=&gt;1, &#8216;isappend&#8217;=&gt;1);<br \/>\n\u5f53 &#8216;url:&#8217; \u65f6\uff0c<br \/>\n$args = array(&#8216;target&#8217;=&gt;&#8217;xxx&#8217;, &#8216;method&#8217;=&gt;&#8217;xxx&#8217;, &#8216;header&#8217;=&gt;array(&#8216;headerxxx&#8217;=&gt;&#8217;headerxxx_value&#8217;), &#8216;parameter&#8217;=&gt;array(&#8216;parameter_1&#8217;=&gt;&#8217;parameter_1_value&#8217;));<br \/>\n\u4e0a\u8ff0\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\uff0c\u9075\u5faa getBy \/ setBy \u7684\u5b9a\u4e49\uff0c\u7edf\u4e00\u89c4\u8303\u4e3a<br \/>\nreturn array(boolean &lt;true|false&gt;, array(&#8216;content&#8217;=&gt;$returnObject, &#8216;errorcode&#8217;=&gt;&#8217;xxxx&#8217;, &#8216;errordesc&#8217;=&gt;&#8217;xxxx&#8217;));<br \/>\n\u5176\u4e2d\uff0c \u6210\u529f true \u65f6\uff0c\u53ea\u6709 content \u7684\u952e\u503c; \u5931\u8d25 false \u65f6\uff0c\u53ea\u6709 errorcode \u548c errordesc \u3002<br \/>\n\u5982\u4e0b\u662f\u51e0\u4e2a\u5b9e\u4f8b:<br \/>\n<a href=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-example-201605.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1223\" alt=\"-gwa2-readObject-example-201605\" src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-example-201605.png\" width=\"538\" height=\"678\" srcset=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-example-201605.png 538w, https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/05\/gwa2-readObject-example-201605-238x300.png 238w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/a><\/p>\n<p>\u5176\u4e2d\uff0cerrorcode \u662f -GWA2 \u7279\u6709\u7684\u4e00\u79cd\u6807\u8bb0\u7cfb\u7edf\uff0c\u7cfb\u5168\u5c40\u6240\u6709\uff0c\u7528\u4e8e\u5168\u5c40\u5b9a\u4f4d\u3002 \u9ed8\u8ba4\u91c7\u7528 timestamp \u7684 YYmmddHHMM \u5341\u4f4d\u6570\u5b57\u7cfb\u7edf\u3002<\/p>\n<p>&#8212;- &#8212;- &#8212;- &#8212;-<\/p>\n<p>\u5f53\u7f16\u7a0b\u8bed\u8a00\u4e0d\u518d\u662f\u7f81\u7eca\u65f6\uff0c\u601d\u60f3\u548c\u6587\u5316\u53d8\u4f5c\u4e3a\u4e3b\u56e0\uff0c\u6bd4\u5982\u4e0a\u9762\u4fee\u6539\u4e2d\uff0c\u4e3a\u4f55\u8981\u5c06 read\/writeObject \u878d\u5165\u5230 getBy\/setBy \u4e2d\uff0c\u800c\u4e0d\u662f\u5728 WebApp \u4e2d\u76f4\u63a5\u8c03\u7528?<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ee7\u7eed\u9700\u6c42\u9a71\u52a8\uff0c-GWA2\u00a0\u6269\u5c55\u589e\u52a0read\/writeObject \u5230 setB &hellip; <a href=\"https:\/\/ufqi.com\/blog\/gwa2-add-read-write-object-201605\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41,42,6,2],"tags":[20,136,86,133,135,134],"_links":{"self":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1218"}],"collection":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/comments?post=1218"}],"version-history":[{"count":8,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1218\/revisions"}],"predecessor-version":[{"id":1220,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1218\/revisions\/1220"}],"wp:attachment":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media?parent=1218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/categories?post=1218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/tags?post=1218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}