فهرست منبع

修改行研产研

zs 9 ماه پیش
والد
کامیت
2dc0b793a6

+ 2 - 2
src/config/config.self.ts

@@ -12,7 +12,7 @@ const dbPwd = '1234qwer!@#$';
 /**redis ip */
 const redisHost = 'localhost';
 /**redis 密码 */
-const redisPwd = '1234qwer!@#$';
+const redisPwd = '123456';
 /**redis 使用第几个数据库 */
 const redisDB = 0;
 /**redis 记录登录的key */
@@ -52,7 +52,7 @@ export default {
         port: 54321,
         entities: ['./entity'],
         type: 'postgres',
-        synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
+        synchronize: true, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
         logging: false,
       },
       logs: {

+ 64 - 0
src/controller/platform/directory.controller.ts

@@ -0,0 +1,64 @@
+import { DirectoryService } from '../../service/platform/directory.service';
+import { CVO_directory, FVO_directory, QVO_directory, UVAO_directory } from '../../interface/platform/directory.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import { Controller, Inject, Get, Param, Post, Body, Del, Query } from '@midwayjs/core';
+import { omit, pick } from 'lodash';
+import { ServiceError, ErrorCode } from '../../error/service.error';
+import { BaseController } from '../../frame/BaseController';
+const namePrefix = '目录';
+@ApiTags(['目录'])
+@Controller('/directory', { tagName: namePrefix })
+export class DirectoryController implements BaseController {
+  @Inject()
+  service: DirectoryService;
+
+  @Get('/')
+  @ApiTags('列表查询')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_directory })
+  async index(@Query() query: object) {
+    const qobj = omit(query, ['skip', 'limit']);
+    const others = pick(query, ['skip', 'limit']);
+    const result = await this.service.query(qobj, others);
+    return result;
+  }
+
+  @Get('/:id')
+  @ApiTags('单查询')
+  @ApiResponse({ type: FVO_directory })
+  async fetch(@Param('id') id: number) {
+    const data = await this.service.fetch({ id });
+    const result = new FVO_directory(data);
+    return result;
+  }
+
+  @Post('/', { routerName: `创建${namePrefix}` })
+  @ApiTags('创建数据')
+  @Validate()
+  @ApiResponse({ type: CVO_directory })
+  async create(@Body() data: object) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_directory(dbData);
+    return result;
+  }
+
+  @Post('/:id', { routerName: `修改${namePrefix}` })
+  @ApiTags('修改数据')
+  @Validate()
+  @ApiResponse({ type: UVAO_directory })
+  async update(@Param('id') id: number, @Body() data: object) {
+    if (!id) throw new ServiceError(ErrorCode.ID_NOT_FOUND);
+    const result = await this.service.update({ id }, data);
+    return result;
+  }
+
+  @Del('/:id', { routerName: `删除${namePrefix}` })
+  @ApiTags('删除数据')
+  @Validate()
+  async delete(@Param('id') id: number) {
+    if (!id) throw new ServiceError(ErrorCode.ID_NOT_FOUND);
+    const result = await this.service.delete({ id });
+    return result;
+  }
+}

+ 24 - 0
src/entity/platform/directory.entity.ts

@@ -0,0 +1,24 @@
+import { Entity, Column } from 'typeorm';
+import { BaseModel } from '../../frame/BaseModel';
+// 目录
+@Entity('directory')
+export class Directory extends BaseModel {
+  @Column({ type: 'integer', nullable: true, comment: '所属行研产研' })
+  journal: number;
+  @Column({ type: 'integer', nullable: true, comment: '所属期刊' })
+  notes: number;
+  @Column({ type: 'character varying', nullable: true, comment: '名称' })
+  name: string;
+  @Column({ type: 'character varying', nullable: true, comment: '委托方' })
+  client: string;
+  @Column({ type: 'character varying', nullable: true, comment: '合作方' })
+  partner: string;
+  @Column({ type: 'character varying', nullable: true, comment: '研究主旨' })
+  brief: string;
+  @Column({ type: 'character varying', nullable: true, comment: '详情' })
+  detail: string;
+  @Column({ type: 'character varying', nullable: true, comment: '是否使用', default: '0' })
+  is_use: string;
+  @Column({ type: 'character varying', nullable: true, comment: '状态', default: '0' })
+  status: string;
+}

+ 0 - 4
src/entity/platform/notes.entity.ts

@@ -9,10 +9,6 @@ export class Notes extends BaseModel {
   name: string;
   @Column({ type: 'jsonb', nullable: true, comment: '封面', default: [] })
   file: Array<any>;
-  @Column({ type: 'character varying', nullable: true, comment: '委托方' })
-  client: string;
-  @Column({ type: 'character varying', nullable: true, comment: '合作方' })
-  partner: string;
   @Column({ type: 'character varying', nullable: true, comment: '简介' })
   brief: string;
   @Column({ type: 'character varying', nullable: true, comment: '是否使用', default: '0' })

+ 103 - 0
src/interface/platform/directory.interface.ts

@@ -0,0 +1,103 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from '../../frame/SearchBase';
+import { dealVO } from '../../frame/VOBase';
+export class FVO_directory {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  id: number = undefined;
+  @ApiProperty({ description: '所属行研产研' })
+  'journal': number = undefined;
+  @ApiProperty({ description: '所属期刊' })
+  'notes': number = undefined;
+  @ApiProperty({ description: '名称' })
+  'name': string = undefined;
+  @ApiProperty({ description: '委托方' })
+  'client': string = undefined;
+  @ApiProperty({ description: '合作方' })
+  'partner': string = undefined;
+  @ApiProperty({ description: '研究主旨' })
+  'brief': string = undefined;
+  @ApiProperty({ description: '研究主旨' })
+  'detail': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_directory extends SearchBase {
+  @ApiProperty({ description: '所属行研产研' })
+  'journal': number = undefined;
+  @ApiProperty({ description: '所属期刊' })
+  'notes': number = undefined;
+  @ApiProperty({ description: '名称' })
+  'name': string = undefined;
+  @ApiProperty({ description: '委托方' })
+  'client': string = undefined;
+  @ApiProperty({ description: '合作方' })
+  'partner': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_directory extends FVO_directory {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_directory {
+  @ApiProperty({ description: '所属行研产研' })
+  @Rule(RuleType['number']().empty(''))
+  'journal': number = undefined;
+  @ApiProperty({ description: '所属期刊' })
+  @Rule(RuleType['number']().empty(''))
+  'notes': number = undefined;
+  @ApiProperty({ description: '名称' })
+  @Rule(RuleType['string']().empty(''))
+  'name': string = undefined;
+  @ApiProperty({ description: '委托方' })
+  @Rule(RuleType['string']().empty(''))
+  'client': string = undefined;
+  @ApiProperty({ description: '合作方' })
+  @Rule(RuleType['string']().empty(''))
+  'partner': string = undefined;
+  @ApiProperty({ description: '研究主旨' })
+  @Rule(RuleType['string']().empty(''))
+  'brief': string = undefined;
+  @ApiProperty({ description: '详情' })
+  @Rule(RuleType['string']().empty(''))
+  'detail': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_directory extends FVO_directory {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_directory extends CDTO_directory {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['number']().empty(''))
+  id: number = undefined;
+}
+
+export class UVAO_directory extends FVO_directory {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 0 - 14
src/interface/platform/notes.interface.ts

@@ -14,10 +14,6 @@ export class FVO_notes {
   'file': Array<any> = undefined;
   @ApiProperty({ description: '名称' })
   'name': string = undefined;
-  @ApiProperty({ description: '委托方' })
-  'client': string = undefined;
-  @ApiProperty({ description: '合作方' })
-  'partner': string = undefined;
   @ApiProperty({ description: '简介' })
   'brief': string = undefined;
   @ApiProperty({ description: '是否使用' })
@@ -31,10 +27,6 @@ export class QDTO_notes extends SearchBase {
   'journal': number = undefined;
   @ApiProperty({ description: '名称' })
   'name': string = undefined;
-  @ApiProperty({ description: '委托方' })
-  'client': string = undefined;
-  @ApiProperty({ description: '合作方' })
-  'partner': string = undefined;
   @ApiProperty({ description: '是否使用' })
   'is_use': string = undefined;
   @ApiProperty({ description: '状态' })
@@ -58,12 +50,6 @@ export class CDTO_notes {
   @ApiProperty({ description: '名称' })
   @Rule(RuleType['string']().empty(''))
   'name': string = undefined;
-  @ApiProperty({ description: '委托方' })
-  @Rule(RuleType['string']().empty(''))
-  'client': string = undefined;
-  @ApiProperty({ description: '合作方' })
-  @Rule(RuleType['string']().empty(''))
-  'partner': string = undefined;
   @ApiProperty({ description: '简介' })
   @Rule(RuleType['string']().empty(''))
   'brief': string = undefined;

+ 10 - 0
src/service/platform/directory.service.ts

@@ -0,0 +1,10 @@
+import { Provide } from '@midwayjs/core';
+import { InjectEntityModel } from '@midwayjs/typeorm';
+import { Repository } from 'typeorm';
+import { Directory } from '../../entity/platform/directory.entity';
+import { BaseServiceV2 } from '../../frame/BaseServiceV2';
+@Provide()
+export class DirectoryService extends BaseServiceV2 {
+  @InjectEntityModel(Directory)
+  model: Repository<Directory>;
+}