guhongwei před 2 roky
rodič
revize
29aeae6e83

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

@@ -3,7 +3,7 @@ import { MidwayConfig } from '@midwayjs/core';
 export default {
   keys: '1679015772536_8873',
   koa: {
-    port: 10111,
+    port: 16001,
   },
   jwt: {
     secret: 'Ziyouyanfa!@#',

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

@@ -1,13 +1,13 @@
 import { MidwayConfig } from '@midwayjs/core';
 const ip = '127.0.0.1';
-const project = 'testproject';
+const project = 'studioadmin';
 export default {
   keys: '1672292154640_555',
   koa: {
-    globalPrefix: `/${project}/v1/api`,
+    globalPrefix: `/${project}/api`,
   },
   swagger: {
-    swaggerPath: `/dev/${project}/v1/api/doc`,
+    swaggerPath: `/dev/${project}/api/doc`,
   },
   mongoose: {
     dataSource: {

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

@@ -1,10 +1,10 @@
 import { MidwayConfig } from '@midwayjs/core';
 const ip = '127.0.0.1';
-const project = 'testproject';
+const project = 'studioadmin';
 export default {
   keys: '1672292154640_555',
   koa: {
-    globalPrefix: `/${project}/v1/api`,
+    globalPrefix: `/${project}/api`,
   },
   swagger: {
     swaggerPath: `/${project}/v1/api/doc`,

+ 67 - 0
src/controller/builddesire.controller.ts

@@ -0,0 +1,67 @@
+
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { BuilddesireService } from '../service/builddesire.service';
+import { CDTO_builddesire, CVO_builddesire, FVO_builddesire, QDTO_builddesire, QVO_builddesire, UDTO_builddesire, UVAO_builddesire } from '../interface/builddesire.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['发布工作室建设意愿'])
+@Controller('/builddesire')
+export class BuilddesireController extends BaseController {
+  @Inject()
+  service: BuilddesireService;
+
+
+  @Post('/') @Validate() @ApiResponse({ type: CVO_builddesire })
+  async create(@Body() data: CDTO_builddesire) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_builddesire(dbData);
+    return result;
+  }
+  @Get('/') @ApiQuery({ name: 'query' }) @ApiResponse({ type: QVO_builddesire })
+  async query(@Query() filter: QDTO_builddesire, @Query('skip') skip: number, @Query('limit') limit: number) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_builddesire(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+
+  @Get('/:id') @ApiResponse({ type: FVO_builddesire })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_builddesire(data);
+    return result;
+  }
+
+
+  @Post('/:id') @Validate() @ApiResponse({ type: UVAO_builddesire })
+  async update(@Param('id') id: string, @Body() body: UDTO_builddesire) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+
+  @Del('/:id') @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 37 - 0
src/entity/builddesire.entity.ts

@@ -0,0 +1,37 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'builddesire' },
+})
+export class Builddesire extends BaseModel {
+  @prop({ 'required': false, 'index': true, 'zh': '绑定用户' })
+  user_id: string
+  @prop({ 'required': false, 'index': true, 'zh': '单位id' })
+  company_id: string
+  @prop({ 'required': false, 'index': true, 'zh': '单位名称' })
+  company_name: string
+  @prop({ 'required': false, 'index': false, 'zh': '单位所在地' })
+  address: string
+  @prop({ 'required': false, 'index': true, 'zh': '单位性质', 'remark': '字典表:s-builddesire-nature' })
+  nature: string
+  @prop({ 'required': false, 'index': false, 'zh': '拟解决技术难题或战略发展问题' })
+  development: string
+  @prop({ 'required': false, 'index': true, 'zh': '所属领域', 'remark': '字典表:' })
+  fields: Array<any>
+  @prop({ 'required': false, 'index': false, 'zh': '建设目标' })
+  target: string
+  @prop({ 'required': false, 'index': true, 'zh': '联系人' })
+  contact: string
+  @prop({ 'required': false, 'index': false, 'zh': '联系电话' })
+  phone: string
+  @prop({ 'required': false, 'index': true, 'zh': '专业技术职称', 'remark': '字典表:s-builddesire-zc' })
+  zc: string
+  @prop({ 'required': false, 'index': false, 'zh': '专业领域', 'remark': '字典表:' })
+  zy_fields: Array<any>
+  @prop({ 'required': false, 'index': false, 'zh': '研究方向' })
+  direction: Array<any>
+  @prop({ 'required': false, 'index': false, 'zh': '其它要求' })
+  other: string
+  @prop({ 'required': false, 'index': true, 'zh': '是否启用', 'remark': '字典表' })
+  is_use: string
+}

+ 154 - 0
src/interface/builddesire.interface.ts

@@ -0,0 +1,154 @@
+
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_builddesire {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '绑定用户' })
+  'user_id': string = undefined;
+  @ApiProperty({ description: '单位id' })
+  'company_id': string = undefined;
+  @ApiProperty({ description: '单位名称' })
+  'company_name': string = undefined;
+  @ApiProperty({ description: '单位所在地' })
+  'address': string = undefined;
+  @ApiProperty({ description: '单位性质' })
+  'nature': string = undefined;
+  @ApiProperty({ description: '拟解决技术难题或战略发展问题' })
+  'development': string = undefined;
+  @ApiProperty({ description: '所属领域' })
+  'fields': Array<any> = undefined;
+  @ApiProperty({ description: '建设目标' })
+  'target': string = undefined;
+  @ApiProperty({ description: '联系人' })
+  'contact': string = undefined;
+  @ApiProperty({ description: '联系电话' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '专业技术职称' })
+  'zc': string = undefined;
+  @ApiProperty({ description: '专业领域' })
+  'zy_fields': Array<any> = undefined;
+  @ApiProperty({ description: '研究方向' })
+  'direction': Array<any> = undefined;
+  @ApiProperty({ description: '其它要求' })
+  'other': string = undefined;
+  @ApiProperty({ description: '是否启用' })
+  'is_use': string = undefined;
+}
+
+
+export class QDTO_builddesire extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['user_id', 'company_id', 'company_name', 'nature', 'fields', 'contact', 'zc', 'is_use'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '绑定用户' })
+  'user_id': string = undefined;
+  @ApiProperty({ description: '单位id' })
+  'company_id': string = undefined;
+  @ApiProperty({ description: '单位名称' })
+  'company_name': string = undefined;
+  @ApiProperty({ description: '单位性质' })
+  'nature': string = undefined;
+  @ApiProperty({ description: '所属领域' })
+  'fields': Array<any> = undefined;
+  @ApiProperty({ description: '联系人' })
+  'contact': string = undefined;
+  @ApiProperty({ description: '专业技术职称' })
+  'zc': string = undefined;
+  @ApiProperty({ description: '是否启用' })
+  'is_use': string = undefined;
+}
+
+
+export class QVO_builddesire extends FVO_builddesire {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+
+export class CDTO_builddesire {
+  @ApiProperty({ description: '绑定用户' })
+  @Rule(RuleType['string']().empty(''))
+  'user_id': string = undefined;
+  @ApiProperty({ description: '单位id' })
+  @Rule(RuleType['string']().empty(''))
+  'company_id': string = undefined;
+  @ApiProperty({ description: '单位名称' })
+  @Rule(RuleType['string']().empty(''))
+  'company_name': string = undefined;
+  @ApiProperty({ description: '单位所在地' })
+  @Rule(RuleType['string']().empty(''))
+  'address': string = undefined;
+  @ApiProperty({ description: '单位性质' })
+  @Rule(RuleType['string']().empty(''))
+  'nature': string = undefined;
+  @ApiProperty({ description: '拟解决技术难题或战略发展问题' })
+  @Rule(RuleType['string']().empty(''))
+  'development': string = undefined;
+  @ApiProperty({ description: '所属领域' })
+  @Rule(RuleType['array']().empty(''))
+  'fields': Array<any> = undefined;
+  @ApiProperty({ description: '建设目标' })
+  @Rule(RuleType['string']().empty(''))
+  'target': string = undefined;
+  @ApiProperty({ description: '联系人' })
+  @Rule(RuleType['string']().empty(''))
+  'contact': string = undefined;
+  @ApiProperty({ description: '联系电话' })
+  @Rule(RuleType['string']().empty(''))
+  'phone': string = undefined;
+  @ApiProperty({ description: '专业技术职称' })
+  @Rule(RuleType['string']().empty(''))
+  'zc': string = undefined;
+  @ApiProperty({ description: '专业领域' })
+  @Rule(RuleType['array']().empty(''))
+  'zy_fields': Array<any> = undefined;
+  @ApiProperty({ description: '研究方向' })
+  @Rule(RuleType['array']().empty(''))
+  'direction': Array<any> = undefined;
+  @ApiProperty({ description: '其它要求' })
+  @Rule(RuleType['string']().empty(''))
+  'other': string = undefined;
+  @ApiProperty({ description: '是否启用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+
+export class CVO_builddesire extends FVO_builddesire {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+
+export class UDTO_builddesire extends CDTO_builddesire {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+
+export class UVAO_builddesire extends FVO_builddesire {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 11 - 0
src/service/builddesire.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { Builddesire } from '../entity/builddesire.entity';
+type modelType = ReturnModelType<typeof Builddesire>;
+@Provide()
+export class BuilddesireService extends BaseService<modelType> {
+  @InjectEntityModel(Builddesire)
+  model: modelType;
+}