123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 'use strict';
- const await = require('await-stream-ready/lib/await');
- const { bodyHandleByService } = require('../../extend/context');
- const Controller = require('egg').Controller;
- class CourseController extends Controller {
- async list() {
- const {ctx, service} = this;
- let query = ctx.request.query;
- let ret = await service.course.adminList(query);
- ctx.adminOK(ret);
- }
- async delete() {
- const {ctx, service} = this;
- let id = ctx.request.query.id;
- let ret = await service.course.delete(id);
- ctx.adminOK(ret, "删除成功");
- }
- async edit() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.course.edit( data );
- ctx.adminOK(ret, "更新成功");
- }
- async add() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.course.add( data );
- ctx.adminOK(ret, "添加成功");
- }
- async exportXls() {
- const {ctx, service} = this;
- ctx.set("Content-Type", "application/vnd.openxmlformats");
- ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
- let ret = await service.course.exportXls( ctx.request.query );
- ctx.body = ret;
- }
- async lock () {
- const {ctx, service} = this;
-
- await ctx.bodyHandleByService(service.course, "lock", "操作成功");
- }
- }
- module.exports = CourseController;
|