12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 'use strict';
- const _ = require('lodash');
- const Controller = require('egg').Controller;
- const { CrudController } = require('naf-framework-mongoose/lib/controller');
- // 作业管理
- class TaskController extends Controller {
- constructor(ctx) {
- super(ctx);
- this.service = this.ctx.service.task;
- }
- // POST
- // 新建作业
- async create() {
- const res = await this.service.create(this.ctx.request.body);
- this.ctx.ok({ msg: 'created', data: res });
- }
- // POST
- // 根据id删除
- async delete() {
- const { id } = this.ctx.params;
- await this.service.delete({ id });
- this.ctx.ok({ msg: 'deleted' });
- }
- // POST
- // 根据id更新信息
- async update() {
- await this.service.update(this.ctx.params, this.ctx.request.body);
- this.ctx.ok({ msg: 'accepted' });
- }
- // GET
- // 查询
- async query() {
- const res = await this.service.query(this.ctx.query);
- this.ctx.ok({ msg: 'queried', data: res });
- }
- // GET
- // 查询详情
- async show() {
- const res = await this.service.show(this.ctx.params);
- this.ctx.ok({ msg: 'queried', data: res });
- }
- }
- module.exports = TaskController;
|