UNPKG

4.88 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 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;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var __metadata = (this && this.__metadata) || function (k, v) {
9 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10};
11var __param = (this && this.__param) || function (paramIndex, decorator) {
12 return function (target, key) { decorator(target, key, paramIndex); }
13};
14var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15 return new (P || (P = Promise))(function (resolve, reject) {
16 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
19 step((generator = generator.apply(thisArg, _arguments || [])).next());
20 });
21};
22Object.defineProperty(exports, "__esModule", { value: true });
23const common_1 = require("@nestjs/common");
24const graphql_1 = require("@nestjs/graphql");
25const http_1 = require("http");
26const exception_interceptor_1 = require("../interceptor/exception.interceptor");
27const func_service_1 = require("../service/func.service");
28let FuncResolver = class FuncResolver {
29 constructor(funcService) {
30 this.funcService = funcService;
31 }
32 createFunc(req, body) {
33 return __awaiter(this, void 0, void 0, function* () {
34 const { moduleToken, name } = body;
35 if (!moduleToken || !name) {
36 throw new common_1.HttpException("缺少参数", 400);
37 }
38 yield this.funcService.createFunc(moduleToken, name);
39 return { code: 200, message: "创建功能成功" };
40 });
41 }
42 updateFunc(req, body) {
43 return __awaiter(this, void 0, void 0, function* () {
44 const { id, name } = body;
45 if (!id || !name) {
46 throw new common_1.HttpException("缺少参数", 400);
47 }
48 yield this.funcService.updateFunc(id, name);
49 return { code: 200, message: "更新功能成功" };
50 });
51 }
52 deleteFunc(req, body) {
53 return __awaiter(this, void 0, void 0, function* () {
54 const { id } = body;
55 if (!id) {
56 throw new common_1.HttpException("缺少参数", 400);
57 }
58 yield this.funcService.deleteFunc(id);
59 return { code: 200, message: "删除功能成功" };
60 });
61 }
62 setPermissions(req, body) {
63 return __awaiter(this, void 0, void 0, function* () {
64 const { id, permissionIds } = body;
65 if (!id) {
66 throw new common_1.HttpException("缺少参数", 400);
67 }
68 yield this.funcService.setPermissions(id, permissionIds);
69 return { code: 200, message: "设置功能权限成功" };
70 });
71 }
72};
73__decorate([
74 graphql_1.Mutation("createFunc"),
75 __metadata("design:type", Function),
76 __metadata("design:paramtypes", [http_1.IncomingMessage, Object]),
77 __metadata("design:returntype", Promise)
78], FuncResolver.prototype, "createFunc", null);
79__decorate([
80 graphql_1.Mutation("updateFunc"),
81 __metadata("design:type", Function),
82 __metadata("design:paramtypes", [http_1.IncomingMessage, Object]),
83 __metadata("design:returntype", Promise)
84], FuncResolver.prototype, "updateFunc", null);
85__decorate([
86 graphql_1.Mutation("deleteFunc"),
87 __metadata("design:type", Function),
88 __metadata("design:paramtypes", [http_1.IncomingMessage, Object]),
89 __metadata("design:returntype", Promise)
90], FuncResolver.prototype, "deleteFunc", null);
91__decorate([
92 graphql_1.Mutation("setPermissions"),
93 __metadata("design:type", Function),
94 __metadata("design:paramtypes", [http_1.IncomingMessage, Object]),
95 __metadata("design:returntype", Promise)
96], FuncResolver.prototype, "setPermissions", null);
97FuncResolver = __decorate([
98 graphql_1.Resolver("Func"),
99 common_1.UseInterceptors(exception_interceptor_1.ExceptionInterceptor),
100 __param(0, common_1.Inject(func_service_1.FuncService)),
101 __metadata("design:paramtypes", [func_service_1.FuncService])
102], FuncResolver);
103exports.FuncResolver = FuncResolver;