{"id":67083,"date":"2025-05-03T17:16:34","date_gmt":"2025-05-03T09:16:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/67083\/"},"modified":"2025-05-03T17:16:34","modified_gmt":"2025-05-03T09:16:34","slug":"%ef%bc%88%e4%b8%80%ef%bc%89%ef%bc%9a%e5%9c%a8typescript%e5%92%8cjava%e4%b8%ad%e5%ba%94%e7%94%a8%e6%8e%a5%e5%8f%a3%e9%9a%94%e7%a6%bb%e5%8e%9f%e5%88%99-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/67083\/","title":{"rendered":"\uff08\u4e00\uff09\uff1a\u5728Typescript\u548cJava\u4e2d\u5e94\u7528\u201c\u63a5\u53e3\u9694\u79bb\u539f\u5219\u201d"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173258338369871.jpg\" class=\"aligncenter\" title=\"\uff08\u4e00\uff09\uff1a\u5728Typescript\u548cJava\u4e2d\u5e94\u7528\u201c\u63a5\u53e3\u9694\u79bb\u539f\u5219\u201d\u63d2\u56fe\" alt=\"\uff08\u4e00\uff09\uff1a\u5728Typescript\u548cJava\u4e2d\u5e94\u7528\u201c\u63a5\u53e3\u9694\u79bb\u539f\u5219\u201d\u63d2\u56fe\" \/><\/p>\n<h2> \u6982\u5ff5 <\/h2>\n<p>solid \u662f\u4e00\u4e2a\u7f29\u5199\u8bcd\uff0c\u4ee3\u8868\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u4e94\u4e2a\u57fa\u672c\u539f\u5219\uff0c\u7531 robert c. martin\uff08\u9c8d\u52c3\u5927\u53d4\uff09\u63d0\u51fa\u3002\u5728\u8fd9\u91cc\u60a8\u53ef\u4ee5\u9605\u8bfb\u6709\u5173\u4ed6\u7684\u6587\u7ae0\u7684\u66f4\u591a\u4fe1\u606f\u3002<br \/> \u8fd9\u4e9b\u539f\u5219\u65e8\u5728\u6539\u8fdb\u4ee3\u7801\u7684\u7ed3\u6784\u548c\u7ef4\u62a4\uff0c\u4f7f\u5176\u66f4\u52a0\u7075\u6d3b\u3001\u53ef\u6269\u5c55\u4e14\u66f4\u6613\u4e8e\u7406\u89e3\u3002\u8fd9\u4e9b\u539f\u5219\u53ef\u4ee5\u5e2e\u52a9\u7a0b\u5e8f\u5458\u521b\u5efa\u66f4\u6709\u7ec4\u7ec7\u7684\u4ee3\u7801\u3001\u5212\u5206\u804c\u8d23\u3001\u51cf\u5c11\u4f9d\u8d56\u3001\u7b80\u5316\u91cd\u6784\u8fc7\u7a0b\u5e76\u4fc3\u8fdb\u4ee3\u7801\u91cd\u7528\u3002<\/p>\n<p>\u7f29\u5199\u4e2d\u7684\u201ci\u201d\u4ee3\u8868<strong>\u201c\u63a5\u53e3\u9694\u79bb\u539f\u5219\u201d<\/strong>\u3002 bob\u53d4\u53d4\u7528\u6765\u5b9a\u4e49\u8fd9\u4e2a\u539f\u5219\u7684\u4e00\u53e5\u8bdd\u662f\uff1a<\/p>\n<blockquote><p>\n  \u201c\u4efb\u4f55\u5ba2\u6237\u90fd\u4e0d\u5e94\u8be5\u88ab\u8feb\u4f9d\u8d56\u4ed6\u4eec\u4e0d\u4f7f\u7528\u7684\u754c\u9762\u201d\n<\/p><\/blockquote>\n<p><strong>\u63a5\u53e3\u9694\u79bb\u539f\u5219<\/strong>\u89e3\u51b3\u4e86\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\uff1a<strong>\u63a5\u53e3\u8fc7\u5927<\/strong>\u8feb\u4f7f\u4e0d\u9700\u8981\u5b83\u4eec\u7684\u7c7b\u5b9e\u73b0\u4e0d\u5fc5\u8981\u7684\u5b9e\u73b0\u3002<\/p>\n<h2> \u5b9e\u9645\u5e94\u7528 <\/h2>\n<p>\u60f3\u8c61\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8eab\u4efd\u9a8c\u8bc1\u7cfb\u7edf\uff0c\u5176\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u6765\u9a8c\u8bc1\u7528\u6237\u8eab\u4efd\uff08\u4f8b\u5982\uff0c\u901a\u8fc7\u5bc6\u7801\u3001\u901a\u8fc7\u751f\u7269\u8bc6\u522b\u3001\u901a\u8fc7 qr \u7801\uff09\u3002<\/p>\n<p>\u9996\u5148\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u7c7b\u5728java\u548c\u4e2d\u4e0d\u4f7f\u7528isp\u7684\u60c5\u51b5\u4e0b\u7684\u5e94\u7528\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<h4> \u722a\u54c7 <\/h4>\n<pre>interface authenticator {\n    boolean authenticatewithpassword(string userid, string password);\n    boolean authenticatewithbiometrics(string userid);\n    boolean authenticatewithqrcode(string qrcode);\n}\n\nclass passwordauthenticator implements authenticator {\n    @override\n    public boolean authenticatewithpassword(string userid, string password) {\n        system.out.println(\"authenticating with password...\");\n        return true;\n    }\n\n    @override\n    public boolean authenticatewithbiometrics(string userid) {\n        throw new unsupportedoperationexception(\"not implemented\");\n    }\n\n    @override\n    public boolean authenticatewithqrcode(string qrcode) {\n        throw new unsupportedoperationexception(\"not implemented\");\n    }\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> \u6253\u5b57\u7a3f <\/h4>\n<pre>interface authenticator {\n  authenticatewithpassword(userid: string, password: string): boolean;\n  authenticatewithbiometrics(userid: string): boolean;\n  authenticatewithqrcode(qrcode: string): boolean;\n}\n\nclass passwordauthenticator implements authenticator {\n  authenticatewithpassword(userid: string, password: string): boolean {\n    console.log(\"authenticating with password...\");\n    return true;\n  }\n\n  authenticatewithbiometrics(userid: string): boolean {\n    throw new error(\"not implemented\");\n  }\n\n  authenticatewithqrcode(qrcode: string): boolean {\n    throw new error(\"not implemented\");\n  }\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> \u95ee\u9898\uff1a <\/h3>\n<ol>\n<li> <strong>\u672a\u4f7f\u7528\u7684\u65b9\u6cd5<\/strong>\uff1apasswordauthenticator \u7c7b\u5b9e\u73b0\u4e86\u5bf9\u5176\u529f\u80fd\u6ca1\u6709\u610f\u4e49\u7684\u65b9\u6cd5\u3002<\/li>\n<li> <strong>\u7ef4\u62a4\u9ebb\u70e6<\/strong>\uff1a\u5982\u679c\u63a5\u53e3\u53d1\u751f\u53d8\u5316\uff0c\u6240\u6709\u5b9e\u73b0\u7c7b\u90fd\u9700\u8981\u66f4\u6539\uff0c\u5373\u4f7f\u5b83\u4eec\u4e0d\u4f7f\u7528\u65b0\u65b9\u6cd5\u3002<\/li>\n<li> <strong>\u5355\u4e00\u8d23\u4efb\u8fdd\u89c4<\/strong>\uff1a\u73ed\u7ea7\u5f00\u59cb\u5904\u7406\u4e0d\u5e94\u8be5\u5c5e\u4e8e\u4ed6\u4eec\u7684\u95ee\u9898\u3002<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06authenticator\u63a5\u53e3\u62c6\u5206\u4e3a\u66f4\u5c0f\u3001\u66f4\u5177\u4f53\u7684\u63a5\u53e3\u3002<\/p>\n<h4> \u722a\u54c7 <\/h4>\n<pre>interface passwordauth {\n    boolean authenticatewithpassword(string userid, string password);\n}\n\ninterface biometricauth {\n    boolean authenticatewithbiometrics(string userid);\n}\n\ninterface qrcodeauth {\n    boolean authenticatewithqrcode(string qrcode);\n}\n\nclass passwordauthenticator implements passwordauth {\n    @override\n    public boolean authenticatewithpassword(string userid, string password) {\n        system.out.println(\"authenticating with password...\");\n        return true;\n    }\n}\n\nclass biometricauthenticator implements biometricauth {\n    @override\n    public boolean authenticatewithbiometrics(string userid) {\n        system.out.println(\"authenticating with biometrics...\");\n        return true;\n    }\n}\n\nclass qrcodeauthenticator implements qrcodeauth {\n    @override\n    public boolean authenticatewithqrcode(string qrcode) {\n        system.out.println(\"authenticating with qr code...\");\n        return true;\n    }\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> \u6253\u5b57\u7a3f <\/h4>\n<pre>interface PasswordAuth {\n  authenticateWithPassword(userId: string, password: string): boolean;\n}\n\ninterface BiometricAuth {\n  authenticateWithBiometrics(userId: string): boolean;\n}\n\ninterface QRCodeAuth {\n  authenticateWithQRCode(qrCode: string): boolean;\n}\n\nclass PasswordAuthenticator implements PasswordAuth {\n  authenticateWithPassword(userId: string, password: string): boolean {\n    console.log(\"Authenticating with password...\");\n    return true;\n  }\n}\n\nclass BiometricAuthenticator implements BiometricAuth {\n  authenticateWithBiometrics(userId: string): boolean {\n    console.log(\"Authenticating with biometrics...\");\n    return true;\n  }\n}\n\nclass QRCodeAuthenticator implements QRCodeAuth {\n  authenticateWithQRCode(qrCode: string): boolean {\n    console.log(\"Authenticating with QR Code...\");\n    return true;\n  }\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> \u91cd\u6784\u7684\u597d\u5904 <\/h3>\n<ol>\n<li> <strong>\u7279\u5b9a\u63a5\u53e3<\/strong>\uff1a\u6bcf\u4e2a\u7c7b\u4ec5\u5b9e\u73b0\u5b83\u5b9e\u9645\u4f7f\u7528\u7684\u65b9\u6cd5\u3002<\/li>\n<li> <strong>\u7075\u6d3b\u6027<\/strong>\uff1a\u6dfb\u52a0\u65b0\u7684\u8eab\u4efd\u9a8c\u8bc1\u65b9\u6cd5\u6216\u6a21\u5f0f\u4e0d\u4f1a\u5f71\u54cd\u73b0\u6709\u5b9e\u73b0\u3002<\/li>\n<li> <strong>\u66f4\u7b80\u5355\u7684\u7ef4\u62a4<\/strong>\uff1a\u51cf\u5c11\u4ee3\u7801\u66f4\u6539\u7684\u5f71\u54cd\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u91cd\u6784\u3002<\/li>\n<\/ol>\n<h2> \u7ed3\u8bba <\/h2>\n<p>\u4ee5\u4e0a\u5c31\u662f\uff08\u4e00\uff09\uff1a\u5728Typescript\u548cJava\u4e2d\u5e94\u7528\u201c\u63a5\u53e3\u9694\u79bb\u539f\u5219\u201d\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u5ff5 solid \u662f\u4e00\u4e2a\u7f29\u5199\u8bcd\uff0c\u4ee3\u8868\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u4e94\u4e2a\u57fa\u672c\u539f\u5219\uff0c\u7531 robert c. martin\uff08\u9c8d\u52c3\u5927\u53d4\uff09\u63d0\u51fa\u3002\u5728\u8fd9\u91cc\u60a8\u53ef\u4ee5\u9605\u8bfb\u6709\u5173\u4ed6\u7684\u6587\u7ae0\u7684\u66f4\u591a\u4fe1\u606f\u3002 \u8fd9\u4e9b\u539f\u5219\u65e8\u5728\u6539\u8fdb\u4ee3\u7801\u7684\u7ed3\u6784\u548c\u7ef4\u62a4\uff0c\u4f7f\u5176\u66f4\u52a0\u7075\u6d3b\u3001\u53ef\u6269\u5c55\u4e14\u66f4\u6613\u4e8e\u7406\u89e3\u3002\u8fd9\u4e9b\u539f\u5219\u53ef\u4ee5\u5e2e\u52a9\u7a0b\u5e8f\u5458\u521b\u5efa\u66f4\u6709\u7ec4\u7ec7\u7684\u4ee3\u7801\u3001\u5212\u5206\u804c\u8d23\u3001\u51cf\u5c11\u4f9d\u8d56\u3001\u7b80\u5316\u91cd\u6784\u8fc7\u7a0b\u5e76\u4fc3\u8fdb\u4ee3\u7801\u91cd\u7528\u3002 \u7f29\u5199\u4e2d\u7684\u201ci\u201d\u4ee3\u8868\u201c\u63a5\u53e3\u9694\u79bb\u539f\u5219\u201d\u3002 bob\u53d4\u53d4\u7528\u6765\u5b9a\u4e49\u8fd9\u4e2a\u539f\u5219\u7684\u4e00\u53e5\u8bdd\u662f\uff1a \u201c\u4efb\u4f55\u5ba2\u6237\u90fd\u4e0d\u5e94\u8be5\u88ab\u8feb\u4f9d\u8d56\u4ed6\u4eec\u4e0d\u4f7f\u7528\u7684\u754c\u9762\u201d \u63a5\u53e3\u9694\u79bb\u539f\u5219\u89e3\u51b3\u4e86\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\uff1a\u63a5\u53e3\u8fc7\u5927\u8feb\u4f7f\u4e0d\u9700\u8981\u5b83\u4eec\u7684\u7c7b\u5b9e\u73b0\u4e0d\u5fc5\u8981\u7684\u5b9e\u73b0\u3002 \u5b9e\u9645\u5e94\u7528 \u60f3\u8c61\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8eab\u4efd\u9a8c\u8bc1\u7cfb\u7edf\uff0c\u5176\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u6765\u9a8c\u8bc1\u7528\u6237\u8eab\u4efd\uff08\u4f8b\u5982\uff0c\u901a\u8fc7\u5bc6\u7801\u3001\u901a\u8fc7\u751f\u7269\u8bc6\u522b\u3001\u901a\u8fc7 qr \u7801\uff09\u3002 \u9996\u5148\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u7c7b\u5728java\u548c\u4e2d\u4e0d\u4f7f\u7528isp\u7684\u60c5\u51b5\u4e0b\u7684\u5e94\u7528\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u722a\u54c7 interface authenticator { boolean authenticatewithpassword(string userid, string password); boolean authenticatewithbiometrics(string userid); boolean authenticatewithqrcode(string qrcode); } class passwordauthenticator implements authenticator { @override public boolean authenticatewithpassword(string userid, string password) { system.out.println(&#8220;authenticating with password&#8230;&#8221;); return true; } @override public boolean [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-67083","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=67083"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67083\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=67083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=67083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=67083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}