classify.js
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* @Author: huyue
* @Date: 2021-09-09 16:06:39
* @Last Modified by: huyue
* @Last Modified time: 2021-09-10 15:20:12
*/
// app/controller/classify.js
const Controller = require("egg").Controller;
class ClassifyController extends Controller {
constructor(ctx) {
super(ctx);
this.request = ctx.request;
this.classifyService = ctx.service.classify;
this.ServerResponseCode = ctx.response.ServerResponseCode;
this.ServerResponse = ctx.response.ServerResponse;
}
async getList() {
const query = this.ctx.query;
const result = await this.classifyService.findAll(query);
this.ctx.body = this.ServerResponse.Success(result);
}
async create({ request: { body } }) {
const p = body;
// console.log('p: ', p);
const result = await this.classifyService.create(p);
this.ctx.body = this.ServerResponse.Success(result);
}
async update({ request: { body } }) {
const p = body;
const result = await this.classifyService.update(p);
this.ctx.body = this.ServerResponse.Success(result);
}
async delete({ request: { body } }) {
const p = body;
const result = await this.classifyService.delete(p);
this.ctx.body = this.ServerResponse.Success(result);
}
}
module.exports = ClassifyController;