{"id":266760,"date":"2020-12-29T00:39:56","date_gmt":"2020-12-28T16:39:56","guid":{"rendered":"http:\/\/4563.org\/?p=266760"},"modified":"2020-12-29T00:39:56","modified_gmt":"2020-12-28T16:39:56","slug":"%e5%9f%ba%e4%ba%8e%e5%8e%9f%e7%94%9f-js-%e5%ae%9e%e7%8e%b0%e7%9a%84-bean-%e5%ae%b9%e5%99%a8%e5%92%8c-aop-%e7%bc%96%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=266760","title":{"rendered":"\u57fa\u4e8e\u539f\u751f JS \u5b9e\u73b0\u7684 Bean \u5bb9\u5668\u548c AOP \u7f16\u7a0b"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u57fa\u4e8e\u539f\u751f JS \u5b9e\u73b0\u7684 Bean \u5bb9\u5668\u548c AOP \u7f16\u7a0b               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h2>Bean \u662f\u4ec0\u4e48<\/h2>\n<p>\u6211\u4eec\u77e5\u9053<code>Bean<\/code>\u662f<code>Spring<\/code>\u6700\u57fa\u7840\u7684\u6838\u5fc3\u6784\u4ef6\uff0c\u5927\u591a\u6570\u903b\u8f91\u4ee3\u7801\u90fd\u901a\u8fc7<code>Bean<\/code>\u8fdb\u884c\u7ba1\u7406\u3002<code>NestJS<\/code>\u57fa\u4e8e<code>TypeScript<\/code>\u548c<code>\u4f9d\u8d56\u6ce8\u5165<\/code>\u4e5f\u5b9e\u73b0\u4e86\u7c7b\u4f3c\u4e8e<code>Spring Bean<\/code>\u7684\u673a\u5236\uff1a\u670d\u52a1\u63d0\u4f9b\u8005\uff08 Provider \uff09<\/p>\n<p>CabloyJS \u5219\u662f\u5728<code>\u539f\u751f JS \uff08 Vanilla JS \uff09<\/code>\u4e0a\u5b9e\u73b0\u4e86\u66f4\u8f7b\u91cf\u3001\u66f4\u7075\u6d3b\u7684 Bean \u5bb9\u5668<\/p>\n<h2>\u7406\u5ff5<\/h2>\n<p>CabloyJS \u5728\u8bbe\u8ba1 Bean \u5bb9\u5668\u673a\u5236\u65f6\uff0c\u9075\u5faa\u4e86\u4ee5\u4e0b 3 \u4e2a\u7406\u5ff5\uff1a<\/p>\n<h3>1. \u51e0\u4e4e\u6240\u6709\u4e8b\u7269\u90fd\u662f Bean<\/h3>\n<p>\u6211\u4eec\u7edd\u5927\u591a\u6570\u903b\u8f91\u4ee3\u7801\u90fd\u901a\u8fc7 Bean \u7ec4\u4ef6\u8fdb\u884c\u7ba1\u7406\uff0c\u6bd4\u5982\uff1aController \u3001Service \u3001Model \u3001Middleware \u3001Event \u3001Queue \u3001Broadcast \u3001Schedule \u3001Startup \u3001Flow \u3001Flow Task\uff0c\u7b49\u7b49<\/p>\n<blockquote>\n<p>CabloyJS 4.0 \u5728\u5b9e\u73b0\u4e86 Bean \u5bb9\u5668\u4e4b\u540e\uff0c\u57fa\u672c\u4e0a\u6240\u6709\u6838\u5fc3\u7ec4\u4ef6\u90fd\u4ee5 Bean \u4e3a\u57fa\u7840\u8fdb\u884c\u4e86\u91cd\u6784\u3002\u6bd4\u5982\u57fa\u4e8e EggJS \u7684 Controller \u3001Service \u3001Middleware\uff0c\u4e5f\u5b9e\u73b0\u4e86 Bean \u7ec4\u4ef6\u5316<\/p>\n<\/blockquote>\n<h3>2. Bean \u652f\u6301 AOP<\/h3>\n<p>\u6240\u6709 Bean \u7ec4\u4ef6\u90fd\u53ef\u4ee5\u901a\u8fc7 AOP \u7ec4\u4ef6\u8fdb\u884c\u903b\u8f91\u6269\u5c55<\/p>\n<h3>3. AOP \u4e5f\u662f\u4e00\u79cd Bean<\/h3>\n<p>AOP \u7ec4\u4ef6\u65e2\u7136\u4e5f\u662f Bean\uff0c\u90a3\u4e48\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6 AOP \u7ec4\u4ef6\u8fdb\u884c\u903b\u8f91\u6269\u5c55<\/p>\n<blockquote>\n<p>\u8fd9\u79cd\u9012\u5f52\u8bbe\u8ba1\uff0c\u4e3a\u7cfb\u7edf\u7684\u53ef\u5b9a\u5236\u6027\u548c\u5ef6\u5c55\u6027\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u60f3\u8c61\u7a7a\u95f4<\/p>\n<\/blockquote>\n<h2>\u5b9a\u4e49 Bean<\/h2>\n<p>CabloyJS \u7ea6\u5b9a\u4e86\u4e24\u79cd\u5b9a\u4e49 Bean \u7684\u6a21\u5f0f\uff1aapp \u548c ctx \u3002\u7531\u4e8e Bean \u88ab\u5bb9\u5668\u6258\u7ba1\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u8de8\u6a21\u5757\u8c03\u7528\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u6e05\u6670\u7684\u8fa8\u8bc6 Bean \u88ab\u5e94\u7528\u7684\u573a\u666f\uff0c\u4e00\u822c\u7ea6\u5b9a\uff1a\u5982\u679c Bean \u53ea\u88ab\u672c\u6a21\u5757\u5185\u90e8\u8c03\u7528\uff0c\u90a3\u4e48\u5c31\u4f7f\u7528 app \u6a21\u5f0f\uff1b\u5982\u679c\u5927\u6982\u7387\u4f1a\u88ab\u5176\u4ed6\u6a21\u5757\u8c03\u7528\uff0c\u90a3\u4e48\u5c31\u4f7f\u7528 ctx \u6a21\u5f0f<\/p>\n<h3>1. app \u6a21\u5f0f<\/h3>\n<p>\u6bd4\u5982\uff1aController \u3001Service \u90fd\u91c7\u7528 app \u6a21\u5f0f<\/p>\n<p><code>src\/module\/test-party\/backend\/src\/bean\/test.app.js<\/code><\/p>\n<pre><code>module.exports = app =&gt; {    class appBean extends app.meta.BeanBase {      actionSync({ a, b }) {       return a + b;     }      async actionAsync({ a, b }) {       return Promise.resolve(a + b);     }    }    return appBean; }; <\/code><\/pre>\n<h3>2. ctx \u6a21\u5f0f<\/h3>\n<p>\u6bd4\u5982\uff1a<code>ctx.bean.atom<\/code>\u3001<code>ctx.bean.user<\/code>\u3001<code>ctx.bean.role<\/code>\u90fd\u91c7\u7528 ctx \u6a21\u5f0f<\/p>\n<p><code>src\/module\/test-party\/backend\/src\/bean\/test.ctx.js<\/code><\/p>\n<pre><code>module.exports = ctx =&gt; {   class ctxBean {      constructor(moduleName) {       this._name = moduleName || ctx.module.info.relativeName;     }      get name() {       return this._name;     }      set name(value) {       this._name = value;     }      actionSync({ a, b }) {       return a + b;     }      async actionAsync({ a, b }) {       return Promise.resolve(a + b);     }    }    return ctxBean; };  <\/code><\/pre>\n<blockquote>\n<p>ctx.module.info.relativeName: \u7531\u4e8e ctx \u6a21\u5f0f\u7684 Bean \u7ecf\u5e38\u88ab\u5176\u4ed6\u6a21\u5757\u8c03\u7528\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u6b64\u5c5e\u6027\u53d6\u5f97\u8c03\u7528\u65b9\u6a21\u5757\u7684\u540d\u79f0<\/p>\n<\/blockquote>\n<h2>\u6ce8\u518c Bean<\/h2>\n<p>\u5bf9\u4e8e\u5927\u591a\u6570\u7ec4\u4ef6\uff0cEggJS \u91c7\u7528<code>\u7ea6\u5b9a\u4f18\u5148<\/code>\u7684\u7b56\u7565\uff0c\u4f1a\u5728\u6307\u5b9a\u7684\u4f4d\u7f6e\u67e5\u627e\u8d44\u6e90\uff0c\u5e76\u81ea\u52a8\u52a0\u8f7d\u3002\u800c CabloyJS \u91c7\u7528<code>\u663e\u5f0f\u6ce8\u518c<\/code>\uff0c\u4ece\u800c Webpack \u53ef\u4ee5\u6536\u96c6\u6240\u6709\u540e\u7aef\u6e90\u7801\uff0c\u5b9e\u73b0\u6a21\u5757\u7f16\u8bd1\u7684\u7279\u6027<\/p>\n<p><code>src\/module\/test-party\/backend\/src\/beans.js<\/code><\/p>\n<pre><code>const testApp = require('.\/bean\/test.app.js'); const testCtx = require('.\/bean\/test.ctx.js');  module.exports = app =&gt; {   const beans = {     \/\/ test     'test.app': {       mode: 'app',       bean: testApp,     },     testctx: {       mode: 'ctx',       bean: testCtx,       global: true,     },   };   return beans; }; <\/code><\/pre>\n<table>\n<thead>\n<tr>\n<th>\u540d\u79f0<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>mode<\/td>\n<td>\u6a21\u5f0f\uff1aapp\/ctx<\/td>\n<\/tr>\n<tr>\n<td>bean<\/td>\n<td>bean \u7ec4\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>global<\/td>\n<td>\u662f\u5426\u662f\u5168\u5c40\u7ec4\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4f7f\u7528 Bean<\/h2>\n<h3>1. beanFullName<\/h3>\n<p>\u6bcf\u4e00\u4e2a\u6ce8\u518c\u7684 Bean \u7ec4\u4ef6\u90fd\u88ab\u5206\u914d\u4e86\u5168\u79f0\uff0c\u5177\u4f53\u89c4\u5219\u5982\u4e0b<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6ce8\u518c\u540d\u79f0<\/th>\n<th>\u573a\u666f<\/th>\n<th>\u6240\u5c5e\u6a21\u5757<\/th>\n<th>global<\/th>\n<th>beanFullName<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>test.app<\/td>\n<td>test<\/td>\n<td>test-party<\/td>\n<td>false<\/td>\n<td>test-party.test.app<\/td>\n<\/tr>\n<tr>\n<td>testctx<\/td>\n<td><\/td>\n<td>test-party<\/td>\n<td>true<\/td>\n<td>testctx<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>\u5168\u5c40 Bean \uff08<code>global:true<\/code>\uff09: \u5f53\u4e00\u4e2a Bean \u7ec4\u4ef6\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u6838\u5fc3\u7684\u57fa\u7840\u7ec4\u4ef6\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u5168\u5c40 Bean\uff0c\u65b9\u4fbf\u5176\u4ed6\u6a21\u5757\u7684\u8c03\u7528\uff0c\u6bd4\u5982: <code>atom<\/code>\u3001<code>user<\/code>\u3001<code>role<\/code>\u3001<code>flow<\/code>\u3001<code>flowTask<\/code>\uff0c\u7b49\u7b49<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u672c\u5730 Bean \uff08<code>global:false<\/code>\uff09: \u5f53\u4e00\u4e2a Bean \u7ec4\u4ef6\u4e00\u822c\u53ea\u7528\u4e8e\u672c\u6a21\u5757\u65f6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u672c\u5730 Bean\uff0c\u4ece\u800c\u907f\u514d\u547d\u540d\u51b2\u7a81<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u573a\u666f\uff1a\u5bf9\u4e8e<code>\u672c\u5730 Bean<\/code>\uff0c\u6211\u4eec\u4e00\u822c\u4e3a\u5176\u5206\u914d\u4e00\u4e2a<code>\u573a\u666f\u540d\u79f0<\/code>\u4f5c\u4e3a\u524d\u7f00\uff0c\u4e00\u65b9\u9762\u4fbf\u4e8e Bean \u7684\u5206\u7c7b\u7ba1\u7406\uff0c\u53e6\u4e00\u65b9\u9762\u4e5f\u4fbf\u4e8e\u8fa8\u8bc6 Bean \u7684\u7528\u9014<\/p>\n<\/blockquote>\n<h3>2. \u57fa\u672c\u8c03\u7528<\/h3>\n<p>\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7<code>this.ctx.bean<\/code>\u53d6\u5f97 Bean \u5bb9\u5668\uff0c\u7136\u540e\u901a\u8fc7<code>beanFullName<\/code>\u83b7\u53d6 Bean \u5b9e\u4f8b<\/p>\n<p><code>src\/module\/test-party\/backend\/src\/controller\/test\/feat\/bean.js<\/code><\/p>\n<pre><code>   \/\/ global: false   this.ctx.bean['test-party.test.app'].actionSync({ a, b });    await this.ctx.bean['test-party.test.app'].actionAsync({ a, b });    \/\/ global: true   this.ctx.bean.testctx.actionSync({ a, b });   await this.ctx.bean.testctx.actionAsync({ a, b }); <\/code><\/pre>\n<h3>3. \u65b0\u5efa Bean \u5b9e\u4f8b<\/h3>\n<p>\u901a\u8fc7<code>this.ctx.bean<\/code>\u83b7\u53d6 Bean \u5b9e\u4f8b\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5b9e\u4f8b\u5bf9\u5f53\u524d<code>ctx<\/code>\u800c\u8a00\u662f\u5355\u4f8b\u7684\u3002\u5982\u679c\u9700\u8981\u65b0\u5efa Bean \u5b9e\u4f8b\uff0c\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u8fdb\u884c\uff1a<\/p>\n<pre><code>ctx.bean._newBean(beanFullName, ...args) <\/code><\/pre>\n<p>\u6bd4\u5982\u6211\u4eec\u8981\u65b0\u5efa\u4e00\u4e2a Flow \u5b9e\u4f8b\uff1a<\/p>\n<p><code>src\/module-system\/a-flow\/backend\/src\/bean\/bean.flow.js<\/code><\/p>\n<pre><code>    _createFlowInstance({ flowDef }) {       const flowInstance = ctx.bean._newBean(`${moduleInfo.relativeName}.local.flow.flow`, {         flowDef,       });       return flowInstance;     } <\/code><\/pre>\n<h3>4. \u8de8\u6a21\u5757\u8c03\u7528\u672c\u5730 Bean<\/h3>\n<p>\u672c\u5730 Bean \u4e5f\u53ef\u4ee5\u88ab\u8de8\u6a21\u5757\u8c03\u7528<\/p>\n<blockquote>\n<p>\u8de8\u6a21\u5757\u8c03\u7528\u7684\u672c\u8d28\uff1a\u65b0\u5efa\u4e00\u4e2a ctx \u4e0a\u4e0b\u6587\u73af\u5883\uff0c\u8be5 ctx \u7684 module \u4fe1\u606f\u4e0e\u672c\u5730 Bean \u4e00\u81f4\uff0c\u7136\u540e\u901a\u8fc7\u65b0\u5bb9\u5668<code>ctx.bean<\/code>\u6765\u8c03\u7528\u672c\u5730 Bean<\/p>\n<\/blockquote>\n<pre><code>await ctx.executeBean({ locale, subdomain, beanModule, beanFullName, context, fn, transaction }) <\/code><\/pre>\n<table>\n<thead>\n<tr>\n<th>\u540d\u79f0<\/th>\n<th>\u53ef\u9009<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>locale<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u9ed8\u8ba4\u7b49\u4e8e ctx.locale<\/td>\n<\/tr>\n<tr>\n<td>subdomain<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u9ed8\u8ba4\u7b49\u4e8e ctx.subdomain<\/td>\n<\/tr>\n<tr>\n<td>beanModule<\/td>\n<td>\u5fc5\u9700<\/td>\n<td>\u672c\u5730 Bean \u6240\u5c5e\u6a21\u5757\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td>beanFullName<\/td>\n<td>\u5fc5\u9700<\/td>\n<td>\u672c\u5730 Bean \u7684\u5168\u79f0<\/td>\n<\/tr>\n<tr>\n<td>context<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u8c03\u7528\u672c\u5730 Bean \u65f6\u4f20\u5165\u7684\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>fn<\/td>\n<td>\u5fc5\u9700<\/td>\n<td>\u8c03\u7528\u672c\u5730 Bean \u7684\u65b9\u6cd5\u540d<\/td>\n<\/tr>\n<tr>\n<td>transaction<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u662f\u5426\u8981\u542f\u7528\u6570\u636e\u5e93\u4e8b\u52a1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6bd4\u5982\u6211\u4eec\u8981\u8c03\u7528\u6a21\u5757<code>a-file<\/code>\u7684\u672c\u5730 Bean: <code>service.file<\/code>\uff0c\u76f4\u63a5\u4e0a\u4f20\u7528\u6237\u7684 avatar\uff0c\u5e76\u8fd4\u56de downloadUrl<\/p>\n<p><code>src\/module-system\/a-base-sync\/backend\/src\/bean\/bean.user.js<\/code><\/p>\n<pre><code>      \/\/ upload       const res2 = await ctx.executeBean({         beanModule: 'a-file',         beanFullName: 'a-file.service.file',         context: { fileContent: res.data, meta, user: null },         fn: '_upload',       });       \/\/ hold       profile._avatar = res2.downloadUrl; <\/code><\/pre>\n<h3>5. app.bean<\/h3>\n<p><code>ctx.bean<\/code>\u662f\u6bcf\u4e2a\u8bf7\u6c42\u521d\u59cb\u5316\u4e00\u4e2a\u5bb9\u5668\uff0c\u800c<code>app.bean<\/code>\u5219\u53ef\u4ee5\u5b9e\u73b0\u6574\u4e2a\u5e94\u7528\u4f7f\u7528\u4e00\u4e2a\u5bb9\u5668\uff0c\u4ece\u800c\u5b9e\u73b0 Bean \u7ec4\u4ef6\u7684\u5e94\u7528\u7ea7\u522b\u7684\u5355\u4f8b\u6a21\u5f0f<\/p>\n<p><code>src\/module\/test-party\/backend\/src\/controller\/test\/feat\/bean.js<\/code><\/p>\n<pre><code>  app.bean['test-party.test.app'].actionSync({ a, b });    await app.bean['test-party.test.app'].actionAsync({ a, b }); <\/code><\/pre>\n<h2>AOP \u7f16\u7a0b<\/h2>\n<p>\u9650\u4e8e\u7bc7\u5e45\uff0c\u5173\u4e8e<code>AOP \u7f16\u7a0b<\/code>\u8bf7\u53c2\u89c1\uff1acabloy-aop<\/p>\n<h2>\u76f8\u5173\u94fe\u63a5<\/h2>\n<ul>\n<li>\u5b98\u7f51: https:\/\/cabloy.com\/<\/li>\n<li>GitHub: https:\/\/github.com\/zhennann\/cabloy<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>19<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4856941\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codespots <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u641e Java \u7684\u8fd9\u5e2e\u4eba\u6bd4 GPL \u8fd8\u6709\u4f20\u67d3\u6027                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856942\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : morrieati <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codespots \u786e\u5b9e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856943\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : foxcell <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b9a\u4e49 Bean \u8fd8\u8981\u60f3\u60f3 \u4ec0\u4e48\u5730\u65b9\u7528\u5230\uff0c\u8fd9\u8fd8\u662f bean \u4e48\uff0c\u8ddf\u7c7b\u6709\u5565\u533a\u522b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856944\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BDC017 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u5199 Java \u90fd\u5199\u9b54\u6014\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856945\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wobuhuicode <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u2026\u2026\u6709\u70b9\u65e0\u8bed                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856946\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhoudaiyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u5185\u5473\u4e86\u5144\u5f1f\u4eec                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856947\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kidlj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6c42\u653e\u8fc7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856948\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CODEWEA <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u5565\u7528\uff1f\u6211\u5c31\u5199\u4e2a\u56fe\u7247\u8f6e\u64ad\u7528\u5f97\u7740\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856949\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zjsxwc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u90fd\u662f\u5bb9\u5668\u53e4\u8001\u7684 require.js \u4f5c\u4e3a\u5bb9\u5668 \u4e5f\u6bd4\u4e3b\u8fd9\u4e2a bean \u597d\u7528\uff0c<br \/>\u4f46\u6211\u8fd8\u662f\u5efa\u8bae\u4f7f\u7528 angular \u57fa\u4e8e ts \u7684\u5bb9\u5668\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856950\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ychost <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81f3\u5c11\u4e5f\u641e\u4e2a\u88c5\u9970\u5668\u5c01\u88c5\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856951\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @foxcell \u4e0d\u9700\u8981\u601d\u8003\u5450\u3002\u4efb\u4f55\u5730\u65b9\u8bbf\u95ee bean\uff0c\u53ea\u9700\u8981`ctx.bean.beanFullName`\u5373\u53ef\u3002<br \/>\u4f60\u6240\u8bf4\u7684\u5e94\u8be5\u662f app \u548c ctx \u4e24\u79cd bean \u6a21\u5f0f\u3002\u7531\u4e8e CabloyJS \u662f\u6a21\u5757\u5316\u7684\u9694\u79bb\u4f53\u7cfb\uff0c\u4e00\u4e2a bean \u7ec4\u4ef6\u65e2\u53ef\u4ee5\u5728\u672c\u6a21\u5757\u7528\uff0c\u4e5f\u53ef\u4ee5\u8de8\u6a21\u5757\u4f7f\u7528\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856952\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u7528\u88c5\u9970\u5668\uff0c\u4efb\u4f55\u5730\u65b9\u5982\u679c\u8981\u4f7f\u7528 Bean\uff0c\u90fd\u9700\u8981\u518d\u7528\u88c5\u9970\u5668\u58f0\u660e\u4e00\u4e0b\u3002\u800c\u57fa\u4e8e\u539f\u751f JS \u7684 Bean\uff0c\u5728\u4efb\u4f55\u5730\u65b9\u53ea\u9700\u8981`ctx.bean.beanFullName`\u5f15\u7528 Bean\uff0c\u544a\u522b\u4e86\u88c5\u9970\u5668\u6ee1\u5929\u98de\u7684\u6a21\u5f0f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856953\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @BDC017 \u4e0d\u662f\u975e\u8981\u5411 Java \u9760\u62e2\u3002Bean \u5bb9\u5668\uff0c\u4e00\u65b9\u9762\u65b9\u4fbf\u7ba1\u7406\u548c\u4f7f\u7528\u7ec4\u4ef6\uff0c\u53e6\u4e00\u65b9\u9762\u53ef\u4ee5\u4f7f\u7528 AOP \u673a\u5236\u8fdb\u884c\u903b\u8f91\u7684\u6269\u5c55\u3002\u5982\u679c\u4e00\u4e2a\u9879\u76ee\u65e2\u5305\u62ec\u81ea\u5b9a\u4e49\u4e1a\u52a1\u6a21\u5757\uff0c\u4e5f\u5305\u62ec\u7cfb\u7edf\u6a21\u5757\uff0c\u4f7f\u7528 aop \u673a\u5236\u5c31\u53ef\u4ee5\u8f7b\u6613\u5bf9\u201c\u7cfb\u7edf\u6a21\u5757\u201d\u505a\u903b\u8f91\u6269\u5c55\u548c\u53d8\u66f4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856954\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @CODEWEA \u8fd9\u7bc7\u6587\u7ae0\u521a\u597d\u5199\u5230 bean \u5bb9\u5668\u3002\u5176\u5b9e\uff0cCabloyJS \u8fd8\u5305\u62ec\u6743\u9650\u7ba1\u7406\u3001\u6570\u636e\u751f\u547d\u5468\u671f\u7ba1\u7406\uff08\u8349\u7a3f-&gt;\u5f52\u6863-&gt;\u5386\u53f2\uff09<br \/>\uff0c\u800c\u4e14\u81ea\u5e26 NodeJS \u5de5\u4f5c\u6d41\u5f15\u64ce\uff0c\u5168\u65b0\u7684\u5e03\u5c40\u81ea\u9002\u5e94\u65b9\u6848 pc=mobile+pad\uff0c\u53ef\u4ee5\u5b98\u7f51\u6216\u8005 github \u67e5\u770b\u76f8\u5173\u5185\u5bb9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856955\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @kidlj \u8c22\u8c22\u3002\u5176\u5b9e\u88ab\u56f4\u527f\u7684\u611f\u89c9\u4e5f\u4e0d\u9519\uff0c\u81f3\u5c11\u6709\u4eba\u5173\u6ce8\u4e86\u3002\u8fd9\u53ea\u662f CabloyJS \u751f\u6001\u5176\u4e2d\u7684\u4e00\u7bc7\u6587\u7ae0\u800c\u5df2\uff0c\u5982\u679c\u53ea\u662f\u5b64\u7acb\u7684\u770b\u8fd9\u7bc7\u6587\u7ae0\uff0c\u786e\u5b9e\u6ca1\u5565\u610f\u4e49\uff0c\u5f53\u7136\u4e5f\u5c31\u9519\u8fc7\u4e86\u4e00\u7247\u8fd8\u7b97\u4e0d\u9519\u7684\u68ee\u6797                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856956\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kidlj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhennann \u55ef\u55ef\uff0c\u522b\u5728\u610f\uff0c\u6211\u5e76\u4e0d\u61c2 Java \u7684 aop \u662f\u4ec0\u4e48\uff0c\u51d1\u4e2a\u70ed\u95f9\u5f00\u4e2a\u73a9\u7b11\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856957\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @kidlj                                                             <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856958\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xcstream <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u559c\u6b22 java \u7684\u539f\u56e0\u5c31\u662f\u56e0\u4e3a aop                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4856959\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhennann <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xcstream \u4f60\u770b\u662f\u5426\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3\u3002aop \u662f\u4e00\u79cd\u80fd\u529b\uff08 bean \u5bb9\u5668\u7684\u526f\u4f5c\u7528\uff09\uff0c\u5982\u679c\u4e0d\u60f3\u7528\u5c31\u5f53\u4ed6\u4e0d\u5b58\u5728\u3002\u56e0\u6b64\uff0c\u4f60\u4e0d\u559c\u6b22 java \u7684\u539f\u56e0\uff0c\u53ef\u80fd\u662f\u5728 java \u91cc\u9762\uff0c\u4e0d\u8bba\u662f bean \u7ec4\u4ef6\u7684\u5b9a\u4e49\u8fd8\u662f\u4f7f\u7528\uff0c\u6ce8\u89e3\u6f2b\u5929\u98de\u7684\u60c5\u51b5\u3002<br \/>\u8fd9\u91cc\u63d0\u5230\u7684\u57fa\u4e8e\u539f\u751f js \u7684 bean \u5bb9\u5668\uff0c\u4e0d\u518d\u9700\u8981\u6ce8\u89e3\u3002\u6bd4\u5982\uff0c\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u4e2a bean \u7ec4\u4ef6\uff1auser, \u90a3\u4e48\u5728\u9879\u76ee\u7684\u4efb\u4f55\u5730\u65b9\uff0c\u53ea\u9700\u4f7f\u7528`ctx.bean.user`\u76f4\u63a5\u5f15\u7528\u8be5 bean \u7ec4\u4ef6\uff0c\u4e0d\u518d\u9700\u8981\u50cf java \u901a\u8fc7\u6ce8\u89e3\u7684\u65b9\u5f0f\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u4e8e\u539f\u751f JS \u5b9e\u73b0\u7684 Bean &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/266760"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266760"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/266760\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266760"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}