zs 8 달 전
부모
커밋
d283205342
4개의 변경된 파일40개의 추가작업 그리고 46개의 파일을 삭제
  1. 9 0
      src/controller/util.controller.ts
  2. 2 0
      src/entity/users/incubator.entity.ts
  3. 7 0
      src/interface/users/incubator.interface.ts
  4. 22 46
      src/service/util.service.ts

+ 9 - 0
src/controller/util.controller.ts

@@ -0,0 +1,9 @@
+import { Controller, Get, Inject } from '@midwayjs/core';
+import { ApiTags } from '@midwayjs/swagger';
+import { UtilService } from '../service/util.service';
+@ApiTags(['工具'])
+@Controller('/util')
+export class UtilController {
+  @Inject()
+  service: UtilService;
+}

+ 2 - 0
src/entity/users/incubator.entity.ts

@@ -17,6 +17,8 @@ export class Incubator extends BaseModel {
   brief: string;
   @Column({ type: 'character varying', nullable: true, comment: '是否公开' })
   is_show: string;
+  @Column({ type: 'character varying', nullable: true, comment: '是否和平台合作标识' })
+  cooperate: string;
   @Column({ type: 'character varying', nullable: true, comment: '状态', default: '0' })
   status: string;
 }

+ 7 - 0
src/interface/users/incubator.interface.ts

@@ -21,6 +21,8 @@ export class FVO_incubator {
   'brief': string = undefined;
   @ApiProperty({ description: '是否公开' })
   'is_show': string = undefined;
+  @ApiProperty({ description: '是否和平台合作标识' })
+  'cooperate': string = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -34,6 +36,8 @@ export class QDTO_incubator {
   'person_phone': string = undefined;
   @ApiProperty({ description: '是否公开' })
   'is_show': string = undefined;
+  @ApiProperty({ description: '是否和平台合作标识' })
+  'cooperate': string = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -67,6 +71,9 @@ export class CDTO_incubator {
   @ApiProperty({ description: '是否公开' })
   @Rule(RuleType['string']().empty(''))
   'is_show': string = undefined;
+  @ApiProperty({ description: '是否和平台合作标识' })
+  @Rule(RuleType['string']().empty(''))
+  'cooperate': string = undefined;
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;

+ 22 - 46
src/service/util.service.ts

@@ -1,54 +1,30 @@
 import { Inject, Provide } from '@midwayjs/core';
-// import { Achievement } from '../entity/platform/achievement.entity';
-import { TypeORMDataSourceManager } from '@midwayjs/typeorm';
+import { get, union } from 'lodash';
+import { UserService } from './system/user.service';
 import { Context } from '@midwayjs/koa';
-import { Test } from '../entity/test.entity';
+import { AchievementService } from './platform/achievement.service';
+import { ProjectService } from './platform/project.service';
+import { DemandService } from './platform/demand.service';
+import { SupplyService } from './platform/supply.service';
+import { CompanyService } from './users/company.service';
+
+/**
+ * 工具类服务,为其他地方提供一些通用的函数
+ */
 @Provide()
 export class UtilService {
   @Inject()
   ctx: Context;
-  randomStr(len = 6) {
-    return Math.random().toString(36).slice(-len);
-  }
-
-  // 修改后信息后用户重新审核
-  async updateUserAfter(id, body, role_type) {
-    // const { status } = body;
-    // if (status === '0') {
-    //   const model = GetModel(upperFirst(role_type));
-    //   const data = await model.findById(id).lean();
-    //   await this.uModel.updateOne({ _id: data.user }, { status: '0' });
-    // }
-  }
   @Inject()
-  dataSourceManager: TypeORMDataSourceManager;
-  async DBTransaction() {
-    const dataSource = this.dataSourceManager.getDataSource('default');
-    const data: any = {
-      nick_name: '测试',
-      account: `test-${new Date().getTime()}`, //
-      hobby: ['睡觉'],
-      props: { hobby: '睡觉' },
-      array_props: [{ hobby: '睡觉', lik: 'nothing' }],
-    };
-    await dataSource.transaction(async em => {
-      // 事务中的操作会依次做好,并且下一步会在上一步的基础上进行.只有整个函数执行完,才会落实到数据库中
-      // const res = await em.update(Test, { id: 1 }, { account: 'test' });
-      // const ri = await em.insert(Test, data);
-      // const r2 = await em.count(Test, { where: { account: 'test-2' } });
-      // if (r2 > 0) throw new ServiceError('data exists');
-      // const r = await em.getRepository(Test).query('select json_query(\'{"a": [1, 2, 3, 4, 5], "b": ["2", "a b"], "c": {"d": 4, "e": "ab c"}}\'::jsonb,\'$.b\');');
-      const tb = em
-        .getRepository(Test)
-        .createQueryBuilder()
-        // .where('props @> :hobby', { hobby: { hobby: '睡觉' } });
-        .where('hobby @> :hobby', { hobby: '睡觉' });
-      const tres = await tb.getOne();
-      console.log(tres);
-      // const builder = em.getRepository(Test).createQueryBuilder('test').select(['test.id', 'test.array_props']).where({ id: 1 });
-      // console.log(builder.getSql());
-      // const res = await builder.getOne();
-      // console.log(res);
-    });
-  }
+  userService: UserService;
+  @Inject()
+  achievementService: AchievementService;
+  @Inject()
+  projectService: ProjectService;
+  @Inject()
+  demandService: DemandService;
+  @Inject()
+  supplyService: SupplyService;
+  @Inject()
+  companyService: CompanyService;
 }