zs 6 tháng trước cách đây
mục cha
commit
1f6651637d

+ 1 - 1
src/config/config.local.ts

@@ -11,7 +11,7 @@ export default {
   loginSign,
   koa: {
     port: 9700,
-    globalPrefix: '/ts/frame/api',
+    globalPrefix: '/service/api',
   },
   swagger: {
     swaggerPath: '/doc/api',

+ 48 - 0
src/controller/core/node.controller.ts

@@ -0,0 +1,48 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+} from '@midwayjs/core';
+import { NodeService } from '../../service/core/node.service';
+import { RF } from '../../response/CustomerResponse';
+import { Page, Query } from '../../decorator/page.decorator';
+
+@Controller('/node')
+export class NodeController {
+  @Inject()
+  service: NodeService;
+
+  @Post('/')
+  async create(@Body() body) {
+    const data = await this.service.create(body);
+    return RF.success(data);
+  }
+
+  @Get('/')
+  async query(@Query() query, @Page() page) {
+    const result = await this.service.page(query, page);
+    return RF.success(result);
+  }
+
+  @Get('/:id')
+  async fetch(@Param('id') _id: string) {
+    const result = await this.service.findOne({ _id });
+    return RF.success(result);
+  }
+
+  @Post('/:id')
+  async update(@Param('id') _id: string, @Body() body) {
+    const result = await this.service.update({ _id }, body);
+    return RF.success(result);
+  }
+
+  @Del('/:id')
+  async delete(@Param('id') _id: string) {
+    await this.service.delete({ _id });
+    return RF.success();
+  }
+}

+ 48 - 0
src/controller/core/operate.controller.ts

@@ -0,0 +1,48 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+} from '@midwayjs/core';
+import { OperateService } from '../../service/core/operate.service';
+import { RF } from '../../response/CustomerResponse';
+import { Page, Query } from '../../decorator/page.decorator';
+
+@Controller('/operate')
+export class OperateController {
+  @Inject()
+  service: OperateService;
+
+  @Post('/')
+  async create(@Body() body) {
+    const data = await this.service.create(body);
+    return RF.success(data);
+  }
+
+  @Get('/')
+  async query(@Query() query, @Page() page) {
+    const result = await this.service.page(query, page);
+    return RF.success(result);
+  }
+
+  @Get('/:id')
+  async fetch(@Param('id') _id: string) {
+    const result = await this.service.findOne({ _id });
+    return RF.success(result);
+  }
+
+  @Post('/:id')
+  async update(@Param('id') _id: string, @Body() body) {
+    const result = await this.service.update({ _id }, body);
+    return RF.success(result);
+  }
+
+  @Del('/:id')
+  async delete(@Param('id') _id: string) {
+    await this.service.delete({ _id });
+    return RF.success();
+  }
+}

+ 48 - 0
src/controller/core/partition.controller.ts

@@ -0,0 +1,48 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+} from '@midwayjs/core';
+import { PartitionService } from '../../service/core/partition.service';
+import { RF } from '../../response/CustomerResponse';
+import { Page, Query } from '../../decorator/page.decorator';
+
+@Controller('/partition')
+export class PartitionController {
+  @Inject()
+  service: PartitionService;
+
+  @Post('/')
+  async create(@Body() body) {
+    const data = await this.service.create(body);
+    return RF.success(data);
+  }
+
+  @Get('/')
+  async query(@Query() query, @Page() page) {
+    const result = await this.service.page(query, page);
+    return RF.success(result);
+  }
+
+  @Get('/:id')
+  async fetch(@Param('id') _id: string) {
+    const result = await this.service.findOne({ _id });
+    return RF.success(result);
+  }
+
+  @Post('/:id')
+  async update(@Param('id') _id: string, @Body() body) {
+    const result = await this.service.update({ _id }, body);
+    return RF.success(result);
+  }
+
+  @Del('/:id')
+  async delete(@Param('id') _id: string) {
+    await this.service.delete({ _id });
+    return RF.success();
+  }
+}

+ 48 - 0
src/controller/system/organization.controller.ts

@@ -0,0 +1,48 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+} from '@midwayjs/core';
+import { OrganizationService } from '../../service/system/organization.service';
+import { RF } from '../../response/CustomerResponse';
+import { Page, Query } from '../../decorator/page.decorator';
+
+@Controller('/organization')
+export class OrganizationController {
+  @Inject()
+  service: OrganizationService;
+
+  @Post('/')
+  async create(@Body() body) {
+    const data = await this.service.create(body);
+    return RF.success(data);
+  }
+
+  @Get('/')
+  async query(@Query() query, @Page() page) {
+    const result = await this.service.page(query, page);
+    return RF.success(result);
+  }
+
+  @Get('/:id')
+  async fetch(@Param('id') _id: string) {
+    const result = await this.service.findOne({ _id });
+    return RF.success(result);
+  }
+
+  @Post('/:id')
+  async update(@Param('id') _id: string, @Body() body) {
+    const result = await this.service.update({ _id }, body);
+    return RF.success(result);
+  }
+
+  @Del('/:id')
+  async delete(@Param('id') _id: string) {
+    await this.service.delete({ _id });
+    return RF.success();
+  }
+}

+ 21 - 0
src/entity/core/node.entity.ts

@@ -0,0 +1,21 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from '../../frame/BaseModel';
+@modelOptions({
+  schemaOptions: { collection: 'node' },
+})
+export class Node extends BaseModel {
+  @prop({ required: false, index: false, zh: '节点名称', esType: 'name' })
+  name: string;
+  @prop({ required: false, index: false, zh: '节点类型', esType: 'type' })
+  type: string;
+  @prop({ required: false, index: false, zh: 'CPU已用/总数', esType: 'cpu_num' })
+  cpu_num: string;
+  @prop({ required: false, index: false, zh: 'GPU已用/总数', esType: 'gpu_num' })
+  gpu_num: string;
+  @prop({ required: false, index: false, zh: '分区', esType: 'partition' })
+  partition: string;
+  @prop({ required: false, index: false, zh: '运行状态', esType: 'status' })
+  status: string;
+  @prop({ required: false, index: false, zh: '当前作业数', esType: 'work_num' })
+  work_num: string;
+}

+ 21 - 0
src/entity/core/operate.entity.ts

@@ -0,0 +1,21 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from '../../frame/BaseModel';
+@modelOptions({
+  schemaOptions: { collection: 'operate' },
+})
+export class Operate extends BaseModel {
+  @prop({ required: false, index: false, zh: '操作IP', esType: 'operator_ip' })
+  operator_ip: string;
+  @prop({ required: false, index: false, zh: '操作者', esType: 'work_id' })
+  operator_name: string;
+  @prop({ required: false, index: false, zh: '操作时间', esType: 'time' })
+  time: string;
+  @prop({ required: false, index: false, zh: '模块名称', esType: 'module_name' })
+  module_name: string;
+  @prop({ required: false, index: false, zh: '操作', esType: 'operation' })
+  operation: string;
+  @prop({ required: false, index: false, zh: '操作结果', esType: 'result' })
+  result: string;
+  @prop({ required: false, index: false, zh: '操作详情', esType: 'detail' })
+  detail: string;
+}

+ 21 - 0
src/entity/core/partition.entity.ts

@@ -0,0 +1,21 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from '../../frame/BaseModel';
+@modelOptions({
+  schemaOptions: { collection: 'partition' },
+})
+export class Partition extends BaseModel {
+  @prop({ required: false, index: false, zh: '分区名称', esType: 'name' })
+  name: string;
+  @prop({ required: false, index: false, zh: '当前作业数', esType: 'work_num' })
+  work_num: string;
+  @prop({ required: false, index: false, zh: '节点数', esType: 'num' })
+  num: string;
+  @prop({ required: false, index: false, zh: 'CPU核数', esType: 'cpu_num' })
+  cpu_num: string;
+  @prop({ required: false, index: false, zh: 'GPU核数', esType: 'gpu_num' })
+  gpu_num: string;
+  @prop({ required: false, index: false, zh: '节点', esType: 'node' })
+  node: Array<any>;
+  @prop({ required: false, index: false, zh: '描述', esType: 'remark' })
+  remark: string;
+}

+ 64 - 0
src/entity/system/organization.entity.ts

@@ -0,0 +1,64 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from '../../frame/BaseModel';
+@modelOptions({
+  schemaOptions: { collection: 'organization' },
+})
+export class Organization extends BaseModel {
+  @prop({ required: false, index: false, zh: '组织名称', esType: 'name' })
+  name: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '上级组织',
+    esType: 'manager',
+    default: '---',
+  })
+  manager: string;
+  @prop({ required: false, index: false, zh: '组成员数', esType: 'num' })
+  num: number;
+  @prop({
+    required: false,
+    index: false,
+    zh: '最大运行作业数',
+    esType: 'max_work',
+    default: '未设置',
+  })
+  max_work: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '最大使用核数',
+    esType: 'max_pit',
+    default: '未设置',
+  })
+  max_pit: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '最大使用GPU数',
+    esType: 'max_cpu',
+    default: '未设置',
+  })
+  max_cpu: string;
+  @prop({ required: false, index: false, zh: '计费折扣', esType: 'money' })
+  money: string;
+  @prop({ required: false, index: false, zh: '存储配额(G)', esType: 'quota' })
+  quota: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '已使用存储(G)',
+    esType: 'storage',
+  })
+  storage: string;
+  @prop({ required: false, index: false, zh: '共享文件夹', esType: 'folder' })
+  folder: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '备注',
+    esType: 'remark',
+    default: '---',
+  })
+  remark: string;
+}

+ 12 - 0
src/service/core/node.service.ts

@@ -0,0 +1,12 @@
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from '../../frame/BaseService';
+import { Provide } from '@midwayjs/core';
+import { Node } from '../../entity/core/node.entity';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+type modelType = ReturnModelType<typeof Node>;
+
+@Provide()
+export class NodeService extends BaseService<modelType> {
+  @InjectEntityModel(Node)
+  model: ReturnModelType<modelType>;
+}

+ 12 - 0
src/service/core/operate.service.ts

@@ -0,0 +1,12 @@
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from '../../frame/BaseService';
+import { Provide } from '@midwayjs/core';
+import { Operate } from '../../entity/core/operate.entity';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+type modelType = ReturnModelType<typeof Operate>;
+
+@Provide()
+export class OperateService extends BaseService<modelType> {
+  @InjectEntityModel(Operate)
+  model: ReturnModelType<modelType>;
+}

+ 12 - 0
src/service/core/partition.service.ts

@@ -0,0 +1,12 @@
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from '../../frame/BaseService';
+import { Provide } from '@midwayjs/core';
+import { Partition } from '../../entity/core/partition.entity';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+type modelType = ReturnModelType<typeof Partition>;
+
+@Provide()
+export class PartitionService extends BaseService<modelType> {
+  @InjectEntityModel(Partition)
+  model: ReturnModelType<modelType>;
+}

+ 12 - 0
src/service/system/organization.service.ts

@@ -0,0 +1,12 @@
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from '../../frame/BaseService';
+import { Provide } from '@midwayjs/core';
+import { Organization } from '../../entity/system/organization.entity';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+type modelType = ReturnModelType<typeof Organization>;
+
+@Provide()
+export class OrganizationService extends BaseService<modelType> {
+  @InjectEntityModel(Organization)
+  model: ReturnModelType<modelType>;
+}