tegg icon indicating copy to clipboard operation
tegg copied to clipboard

Service 里面怎么拿到context

Open gordanyang opened this issue 1 year ago • 2 comments

在此输入你需要反馈的 Bug 具体信息(Bug in Detail):

Service 里面怎么拿到context

@SingletonProto({ // 如果需要在上层使用,需要把 accessLevel 显示声明为 public accessLevel: AccessLevel.PUBLIC, }) export class DemoService { constructor(){ setInterval(() => { //执行定时任务 // 调用egg-sequelize model更新数据库 ctx.model.Demo.findAll(); }, 100000); } }

可复现问题的仓库地址(Reproduction Repo)

https://github.com/ssss

Node 版本号:

v20.14.0

TEgg 版本号:

3.5.2

相关插件名称与版本号:

"egg-sequelize": "^6.0.0",

操作平台与版本号:

macos 15.1

gordanyang avatar Nov 18 '24 13:11 gordanyang

egg-sequelize 目前还没有适配 tegg,可以先看看 https://github.com/eggjs/tegg/blob/master/plugin/orm/README.md

fengmk2 avatar Mar 03 '25 06:03 fengmk2

在controller层传参过来,声明参数@Context() ctx: EggContext, 传给service

snail-boy avatar Aug 07 '25 02:08 snail-boy