-
Notifications
You must be signed in to change notification settings - Fork 18
/
account.controller.js
222 lines (222 loc) · 8.35 KB
/
account.controller.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const typescript_rest_1 = require("typescript-rest");
const typescript_rest_swagger_1 = require("typescript-rest-swagger");
const account_service_1 = require("./account.service");
const account_dto_1 = require("./dto/account.dto");
const interceptor_1 = require("../../interceptor/interceptor");
/**
* 帐号管理.
*/
let AccountController = class AccountController {
constructor(service = new account_service_1.AccountService()) {
this.service = service;
}
/**
* 创建帐号
* @param entry 帐号信息
*/
create(entry) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.create(entry);
});
}
/**
* 更新帐号
* @param entry 帐号信息
*/
update(entry) {
return __awaiter(this, void 0, void 0, function* () {
const admin = this.context.request.user;
return this.service.update(entry, admin);
});
}
/**
* 获取帐号管理界面配置信息.
*/
getConfig() {
return __awaiter(this, void 0, void 0, function* () {
console.log('test ...');
return this.service.getAppearance();
});
}
/**
* 按关键词查询帐号
*
* @param {string} [keyword]
* @returns {Promise<Account[]>}
* @memberof AccountController
*/
getAccountsByKeyword(keyword, value) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.search(keyword, value);
});
}
/**
* 添加用户到角色
* @param role 角色编号
* @param accountIds 用户编号序列
*/
addAccountsToRole(role, accountIds) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.addAccountsToRole(role, accountIds);
});
}
/**
* 从角色中删除用户
* @param role 角色编号
* @param accountId
*/
removeAccountFromRole(role, accountId) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.removeAccountFromRole(role, accountId);
});
}
/**
* 分页查询帐号数据
* @param keyword 关键词
*/
query(keyword, group, role, page, size, sort) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.query(keyword, group, role, page, size, sort);
});
}
/**
* 帐户信息
*/
profile() {
return __awaiter(this, void 0, void 0, function* () {
return this.service.profile(this.context);
});
}
/**
* 删除帐号
* @param id 帐号编号
*/
remove(id) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.remove(id);
});
}
/**
* 查询帐号
* @param id 编号
*/
get(id) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.get(id);
});
}
};
__decorate([
typescript_rest_1.Context,
__metadata("design:type", typescript_rest_1.ServiceContext)
], AccountController.prototype, "context", void 0);
__decorate([
typescript_rest_1.POST,
__metadata("design:type", Function),
__metadata("design:paramtypes", [account_dto_1.CreateAccountDto]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "create", null);
__decorate([
typescript_rest_1.PUT,
__metadata("design:type", Function),
__metadata("design:paramtypes", [account_dto_1.EditAccountDto]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "update", null);
__decorate([
typescript_rest_1.Path('config'),
typescript_rest_1.GET,
typescript_rest_1.Preprocessor(interceptor_1.interceptor),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], AccountController.prototype, "getConfig", null);
__decorate([
typescript_rest_1.Path('search'),
typescript_rest_1.GET,
__param(0, typescript_rest_1.QueryParam('keyword')),
__param(1, typescript_rest_1.QueryParam('value')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "getAccountsByKeyword", null);
__decorate([
typescript_rest_1.Path('role'),
typescript_rest_1.POST,
__param(0, typescript_rest_1.FormParam('role')), __param(1, typescript_rest_1.FormParam('accountIds')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Object]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "addAccountsToRole", null);
__decorate([
typescript_rest_1.Path('role'),
typescript_rest_1.DELETE,
__param(0, typescript_rest_1.QueryParam('role')), __param(1, typescript_rest_1.QueryParam('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "removeAccountFromRole", null);
__decorate([
typescript_rest_1.Path('query'),
typescript_rest_1.GET,
__param(0, typescript_rest_1.QueryParam('keyword')),
__param(1, typescript_rest_1.QueryParam('group')),
__param(2, typescript_rest_1.QueryParam('role')),
__param(3, typescript_rest_1.QueryParam('page')),
__param(4, typescript_rest_1.QueryParam('size')),
__param(5, typescript_rest_1.QueryParam('sort')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, Number, Number, String]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "query", null);
__decorate([
typescript_rest_1.GET,
typescript_rest_1.Path('profile'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], AccountController.prototype, "profile", null);
__decorate([
typescript_rest_1.Path(':id'),
typescript_rest_1.DELETE,
__param(0, typescript_rest_1.PathParam('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "remove", null);
__decorate([
typescript_rest_1.Path(':id'),
typescript_rest_1.GET,
__param(0, typescript_rest_1.PathParam('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], AccountController.prototype, "get", null);
AccountController = __decorate([
typescript_rest_swagger_1.Tags('core'),
typescript_rest_1.Path('/api/account'),
__metadata("design:paramtypes", [Object])
], AccountController);
exports.AccountController = AccountController;
//# sourceMappingURL=account.controller.js.map