documentation.js 1.3 KB
/*
 * @Author: huyue
 * @Date: 2021-09-09 16:06:39
 * @Last Modified by: huyue
 * @Last Modified time: 2021-09-10 15:20:12
 */
// app/controller/documentation.js
const Controller = require("egg").Controller;

class DocumentationController extends Controller {
  constructor(ctx) {
    super(ctx);
    this.request = ctx.request;
    this.documentationService = ctx.service.documentation;
    this.ServerResponseCode = ctx.response.ServerResponseCode;
    this.ServerResponse = ctx.response.ServerResponse;
  }
  /** 搜索列表 */
  async getList() {
    const query = this.ctx.query;
    const result = await this.documentationService.findAll(query);
    this.ctx.body = this.ServerResponse.Success(result);
  }

  /** 新增文档 */
  async create({ request: { body } }) {
    const p = body;
    const result = await this.documentationService.create(p);
    this.ctx.body = this.ServerResponse.Success(result);
  }
  async update({ request: { body } }) {
    const p = body;
    const result = await this.documentationService.update(p);
    this.ctx.body = this.ServerResponse.Success(result);
  }
  async delete({ request: { body } }) {
    const p = body;
    const result = await this.documentationService.delete(p);
    this.ctx.body = this.ServerResponse.Success(result);
  }
}

module.exports = DocumentationController;