-
Notifications
You must be signed in to change notification settings - Fork 18
/
article.controller.js
166 lines (166 loc) · 6.38 KB
/
article.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
"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 article_service_1 = require("./article.service");
const article_dto_1 = require("./dto/article.dto");
const interceptor_1 = require("../../interceptor/interceptor");
let ArticleController = class ArticleController {
constructor(service = new article_service_1.ArticleService()) {
this.service = service;
}
/**
* 获取文章管理界面配置信息.
*/
getConfig() {
return __awaiter(this, void 0, void 0, function* () {
return this.service.getAppearance();
});
}
/**
* 查询文章
* @param keyword 关键词
* @param value 已选中的文章编号
*/
search(keyword, value) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.search(keyword, value);
});
}
/**
* 创建文章
* @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* () {
return this.service.update(entry);
});
}
/**
* 查询文章数据
* @param keyword 关键词
* @param article 第几页
* @param size 页大小
* @param sort 排序
*/
query(keyword, category, page, size, sort) {
return __awaiter(this, void 0, void 0, function* () {
return this.service.query(keyword, category, page, size, sort);
});
}
/**
* 删除文章
* @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)
], ArticleController.prototype, "context", void 0);
__decorate([
typescript_rest_1.Path('config'),
typescript_rest_1.GET,
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], ArticleController.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)
], ArticleController.prototype, "search", null);
__decorate([
typescript_rest_1.POST,
__metadata("design:type", Function),
__metadata("design:paramtypes", [article_dto_1.CreateArticleDto]),
__metadata("design:returntype", Promise)
], ArticleController.prototype, "create", null);
__decorate([
typescript_rest_1.PUT,
__metadata("design:type", Function),
__metadata("design:paramtypes", [article_dto_1.EditArticleDto]),
__metadata("design:returntype", Promise)
], ArticleController.prototype, "update", null);
__decorate([
typescript_rest_1.Path('query'),
typescript_rest_1.GET,
__param(0, typescript_rest_1.QueryParam('keyword')),
__param(1, typescript_rest_1.QueryParam('category')),
__param(2, typescript_rest_1.QueryParam('page')),
__param(3, typescript_rest_1.QueryParam('size')),
__param(4, typescript_rest_1.QueryParam('sort')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, Number, Number, String]),
__metadata("design:returntype", Promise)
], ArticleController.prototype, "query", 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)
], ArticleController.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)
], ArticleController.prototype, "get", null);
ArticleController = __decorate([
typescript_rest_swagger_1.Tags('cms'),
typescript_rest_1.Path('/api/article'),
typescript_rest_1.Preprocessor(interceptor_1.interceptor),
__metadata("design:paramtypes", [Object])
], ArticleController);
exports.ArticleController = ArticleController;
//# sourceMappingURL=article.controller.js.map