* get service * @param {String} name * @param {String} m
(...args)
| 246 | * @param {String} m |
| 247 | */ |
| 248 | service(...args) { |
| 249 | const {modules, services} = think.app; |
| 250 | if (!modules.length) { |
| 251 | return think.service(...args); |
| 252 | } |
| 253 | |
| 254 | const {module} = this.ctx; |
| 255 | const haveSetModule = args.length > 1 && modules.includes(args[1]); |
| 256 | const existInContextModule = services[module] && services[module][args[0]]; |
| 257 | if (haveSetModule || !existInContextModule) { |
| 258 | return think.service(...args); |
| 259 | } |
| 260 | |
| 261 | const name = args.shift(); |
| 262 | return think.service(name, module, ...args); |
| 263 | }, |
| 264 | /** |
| 265 | * execute action |
| 266 | * @param {String} controller |