-
Notifications
You must be signed in to change notification settings - Fork 55
/
group.js
50 lines (43 loc) 路 1.22 KB
/
group.js
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
43
44
45
46
47
48
49
50
'use strict';
const { Controller } = require('egg');
class GroupController extends Controller {
async create() {
const ctx = this.ctx;
const { belongedUniqId, groupName, groupType } = ctx.request.body;
ctx.assertParam({ belongedUniqId, groupName, groupType });
const res = await ctx.service.group.createGroup({
belongedUniqId,
groupName,
groupType,
});
ctx.success(res);
}
async update() {
const ctx = this.ctx;
const uniqId = ctx.params.uniqId;
const { groupName } = ctx.request.body;
const res = await ctx.service.group.updateGroupName({
uniqId,
groupName,
});
ctx.success(res);
}
async delete() {
const ctx = this.ctx;
const { uniqId } = ctx.params;
const res = await ctx.service.group.deleteGroupByUniqId({ uniqId });
if (res) {
ctx.success(res);
return;
}
ctx.fail(ctx.gettext('common.delete.fail'));
}
async showAll() {
const ctx = this.ctx;
const { belongedUniqId, groupType } = ctx.query;
ctx.assertParam({ belongedUniqId, groupType });
const res = await ctx.service.group.queryGroupByBelongedUniqId({ belongedUniqId, groupType });
ctx.success(res);
}
}
module.exports = GroupController;