Skip to content
关注公众号,获取新课通知

关闭直播间


控制器:app/controller/admin/live.js

js
	async close(){
        const { ctx, app } = this;
        const id = ctx.params.id

        let live = await app.model.Live.findOne({
            where: {
                id
            }
        });
        
        if (!live) {
            ctx.toast('该直播间不存在','danger');
        } else if(live.status === 3) {
            ctx.toast('该直播间已结束','danger');
        } else {
            live.status = 3
            await live.save()
            ctx.toast('关闭成功','success')
        }
        ctx.redirect(`/admin/live`);
    }

路由:app/router.js

js
router.get("/admin/live/close/:id", controller.admin.live.close);