UNPKG

youzanyun-devtool-worker

Version:

- web - ws - proxy

122 lines (121 loc) 4.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const spring4js_nodejs_1 = require("spring4js-nodejs"); const BaseController_1 = tslib_1.__importDefault(require("../BaseController")); let AppController = class AppController extends BaseController_1.default { async checkUserAuth(ctx, next) { const { appName } = ctx.query; const loginCheck = await this.customApiService.checkUserAuth({ appName, }); if (!loginCheck || (+loginCheck.code !== 0 && +loginCheck.code !== 200)) { ctx.body = { code: -1, message: '无应用开发权限' }; return; } return true; } async getProjectList(ctx, next) { const result = await this.projectService.getProjectList(); return result; } async saveApp(ctx, next) { const { proAlias, proPath, type } = ctx.request.body; const gitInfo = await this.gitService.getGitInfo(proPath); if (!gitInfo.appName) { ctx.body = { code: -1, message: '请下载正确的有赞云应用' }; return; } const appList = await this.projectService.getProjectsByProName({ proName: gitInfo.appName, type, }); if (appList && appList.length > 0) { ctx.body = { code: -1, message: '项目已存在,可直接打开' }; return; } const loginCheck = await this.customApiService.checkUserAuth({ appName: gitInfo.appName, }); if (!loginCheck || (+loginCheck.code !== 0 && +loginCheck.code !== 200)) { ctx.body = { code: -1, message: '应用不存在或无应用开发权限' }; return; } const params = { proAlias, proPath, type, proName: gitInfo.appName, }; const result = await this.projectService.saveProject(params); return result; } async getAppById(ctx, next) { const { id } = ctx.query; const result = await this.projectService.getProjectById(id); return result; } async getAppDeatilById(ctx, next) { const { id } = ctx.query; let result = await this.projectService.getProjectById(id); if (result.proName) { const data = await this.applicationService.getAppDetail(result.proName); result = Object.assign(Object.assign({}, result), data); } return result; } async deleteApp(ctx, next) { const { id } = ctx.query; const result = await this.projectService.deleteProject(id); return result; } }; tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], AppController.prototype, "userService", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], AppController.prototype, "projectService", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], AppController.prototype, "customApiService", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], AppController.prototype, "gitService", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], AppController.prototype, "applicationService", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Path("auth", spring4js_nodejs_1.HttpMethod.GET) ], AppController.prototype, "checkUserAuth", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("list", spring4js_nodejs_1.HttpMethod.GET) ], AppController.prototype, "getProjectList", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("save", spring4js_nodejs_1.HttpMethod.POST) ], AppController.prototype, "saveApp", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("detail", spring4js_nodejs_1.HttpMethod.GET) ], AppController.prototype, "getAppById", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("app-detail", spring4js_nodejs_1.HttpMethod.GET) ], AppController.prototype, "getAppDeatilById", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("delete", spring4js_nodejs_1.HttpMethod.DELETE) ], AppController.prototype, "deleteApp", null); AppController = tslib_1.__decorate([ spring4js_nodejs_1.Controller("/api/project") ], AppController); exports.default = AppController;