panhui 2 lat temu
rodzic
commit
f0352d75d4

+ 3 - 1
src/app.module.ts

@@ -31,6 +31,7 @@ import { ConditionModule } from './condition/condition.module'
 import { OrgModule } from './org/org.module';
 import { OrgModule } from './org/org.module';
 import { KnowledgeBaseModule } from './knowledge-base/knowledge-base.module';
 import { KnowledgeBaseModule } from './knowledge-base/knowledge-base.module';
 import { FormModule } from './form/form.module'
 import { FormModule } from './form/form.module'
+import { WebModule } from './web/web.module'
 @Module({
 @Module({
     imports: [
     imports: [
         DevtoolsModule.register({
         DevtoolsModule.register({
@@ -114,7 +115,8 @@ import { FormModule } from './form/form.module'
         ConditionModule,
         ConditionModule,
         OrgModule,
         OrgModule,
         KnowledgeBaseModule,
         KnowledgeBaseModule,
-        FormModule
+        FormModule,
+        WebModule
     ],
     ],
     providers: [
     providers: [
         {
         {

+ 19 - 0
src/web/entities/Question.entity.ts

@@ -0,0 +1,19 @@
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class Question {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    @Column()
+    question: string
+
+    @Column()
+    answer: string
+
+    @Column()
+    del: number
+
+    @CreateDateColumn()
+    createdAt: Date
+}

+ 26 - 0
src/web/entities/ability.entity.ts

@@ -0,0 +1,26 @@
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class Ability {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    //web id
+    @Column()
+    webId: number
+
+    @Column()
+    logo: string
+
+    @Column()
+    name: string
+
+    @Column()
+    desc: string
+
+    @Column()
+    del: number
+
+    @CreateDateColumn()
+    createdAt: Date
+}

+ 41 - 0
src/web/entities/case.entity.ts

@@ -0,0 +1,41 @@
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class Case {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    @Column()
+    logo: string
+
+    @Column()
+    name: string
+
+    @Column()
+    tags:string
+
+    @Column()
+    desc: string
+
+    //客户概况
+    @Column()
+    info: string
+
+    //需求
+    @Column()
+    needs: string
+
+    //解决方案
+    @Column()
+    solution: string
+
+    //行业类型
+    @Column()
+    type: string
+
+    @Column()
+    del: number
+
+    @CreateDateColumn()
+    createdAt: Date
+}

+ 16 - 0
src/web/entities/connect.entity.ts

@@ -0,0 +1,16 @@
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class Connect {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    @Column()
+    phone: string
+
+    @Column()
+    industry: string
+
+    @CreateDateColumn()
+    createdAt: Date
+}

+ 31 - 0
src/web/entities/homeCase.entity.ts

@@ -0,0 +1,31 @@
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class HomeCase {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    @Column()
+    logo: string
+
+    @Column()
+    name: string
+
+    @Column()
+    type: string
+
+    @Column()
+    icon1: string
+
+    @Column()
+    icon2: string
+
+    @Column()
+    img: string
+
+    @Column()
+    del: number
+
+    @CreateDateColumn()
+    createdAt: Date
+}

+ 25 - 0
src/web/entities/web.entity.ts

@@ -0,0 +1,25 @@
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class Web {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    @Column()
+    name: string
+
+    @Column()
+    desc: string
+
+    @Column()
+    val?: string
+
+    @Column()
+    direction: number
+
+    @Column()
+    del: number
+
+    @CreateDateColumn()
+    createdAt: Date
+}

+ 55 - 0
src/web/web.controller.ts

@@ -0,0 +1,55 @@
+import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common'
+import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'
+import { WebService } from './web.service'
+import { PageRequest } from 'src/common/dto/page-request'
+import { number } from 'yup'
+import { Public } from 'src/auth/public.decorator'
+import { Connect } from './entities/connect.entity'
+
+@ApiTags('web')
+@ApiBearerAuth()
+@Controller('/web')
+export class WebController {
+    constructor(private readonly webService: WebService) {}
+
+    @Get('/cases')
+    @Public()
+    public async getCase() {
+        return await this.webService.getCase()
+    }
+
+    @Get('/homeCases')
+    @Public()
+    public async getHomeCase() {
+        return await this.webService.getHomeCase()
+    }
+
+    @Get('/base')
+    @Public()
+    public async getBase() {
+        return await this.webService.getBase()
+    }
+
+    @Get('/question')
+    @Public()
+    public async getQuestion() {
+        return await this.webService.getQuestion()
+    }
+
+    @Get('/ability/:id')
+    @Public()
+    public async getAbility(@Param('id') id: string) {
+        return await this.webService.getAbility(Number(id))
+    }
+
+    @Put('/connect')
+    @Public()
+    public async createConnect(@Body() connect: Partial<Connect>) {
+        return await this.webService.saveConnect(connect)
+    }
+
+    @Post('/connect')
+    public async list(@Body() page: PageRequest<Connect>) {
+        return await this.webService.findConnect(page)
+    }
+}

+ 18 - 0
src/web/web.module.ts

@@ -0,0 +1,18 @@
+import { Module } from '@nestjs/common'
+import { TypeOrmModule } from '@nestjs/typeorm'
+import { WebService } from './web.service'
+import { Case } from './entities/case.entity'
+import { Web } from './entities/web.entity'
+import { Question } from './entities/Question.entity'
+import { HomeCase } from './entities/homeCase.entity'
+import { WebController } from './web.controller'
+import { Ability } from './entities/ability.entity'
+import { Connect } from './entities/connect.entity'
+
+@Module({
+    imports: [TypeOrmModule.forFeature([Case, Web, Question, HomeCase, Ability, Connect])],
+    controllers: [WebController],
+    providers: [WebService],
+    exports: [WebService]
+})
+export class WebModule {}

+ 78 - 0
src/web/web.service.ts

@@ -0,0 +1,78 @@
+import { Injectable, InternalServerErrorException, NotFoundException } from '@nestjs/common'
+import { FindManyOptions, FindOptionsOrder, In, Repository, UpdateResult } from 'typeorm'
+import { InjectRepository } from '@nestjs/typeorm'
+import { paginate, Pagination } from 'nestjs-typeorm-paginate'
+import { PageRequest } from '../common/dto/page-request'
+import { Case } from './entities/case.entity'
+import { Web } from './entities/web.entity'
+import { HomeCase } from './entities/homeCase.entity'
+import { Question } from './entities/Question.entity'
+import { Ability } from './entities/ability.entity'
+import { Connect } from './entities/connect.entity'
+
+@Injectable()
+export class WebService {
+    constructor(
+        @InjectRepository(Case)
+        private readonly caseRepository: Repository<Case>,
+        @InjectRepository(Web)
+        private readonly webRepository: Repository<Web>,
+        @InjectRepository(Question)
+        private readonly questionRepository: Repository<Question>,
+        @InjectRepository(HomeCase)
+        private readonly homeCaseRepository: Repository<HomeCase>,
+        @InjectRepository(Ability)
+        private readonly abilityRepository: Repository<Ability>,
+        @InjectRepository(Connect)
+        private readonly connectRepository: Repository<Connect>
+    ) {}
+
+    async getCase() {
+        return await this.caseRepository.findBy({
+            del: 0
+        })
+    }
+
+    async getHomeCase() {
+        return await this.homeCaseRepository.findBy({
+            del: 0
+        })
+    }
+
+    async getBase() {
+        return await this.webRepository.find({
+            where: {
+                del: 0
+            },
+            order: { direction: 'ASC' }
+        })
+    }
+
+    async getQuestion() {
+        return await this.questionRepository.findBy({
+            del: 0
+        })
+    }
+
+    async getAbility(webId: number) {
+        return await this.abilityRepository.findBy({
+            del: 0,
+            webId: webId
+        })
+    }
+
+    async saveConnect(connect: Partial<Connect>) {
+        try {
+            return await this.connectRepository.save(connect)
+        } catch (error) {
+            throw new InternalServerErrorException(error.message)
+        }
+    }
+
+
+    public async findConnect(req: PageRequest<Connect>) {
+        try {
+            return await paginate<Connect>(this.connectRepository, req.page, req.search)
+        } catch (error) {}
+    }
+}